29 lines
868 B
PHP
29 lines
868 B
PHP
<?php
|
|
namespace Misuzu\Storage\Denylist;
|
|
|
|
use Index\Db\DbConnection;
|
|
use Misuzu\Storage\Files\FileInfo;
|
|
|
|
class DenylistContext {
|
|
public private(set) DenylistData $list;
|
|
|
|
public function __construct(DbConnection $dbConn) {
|
|
$this->list = new DenylistData($dbConn);
|
|
}
|
|
|
|
public function denyFile(FileInfo|string $infoOrHash, DenylistReason|string $reason): void {
|
|
if($infoOrHash instanceof FileInfo)
|
|
$infoOrHash = $infoOrHash->hash;
|
|
if(is_string($reason))
|
|
$reason = DenylistReason::from($reason);
|
|
|
|
$this->list->createDenylistEntry($infoOrHash, $reason);
|
|
}
|
|
|
|
public function getDenylistEntry(FileInfo|string $infoOrHash): ?DenylistInfo {
|
|
if($infoOrHash instanceof FileInfo)
|
|
$infoOrHash = $infoOrHash->hash;
|
|
|
|
return $this->list->getDenylistEntry($infoOrHash);
|
|
}
|
|
}
|