mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-30 02:03:16 +00:00
44 lines
719 B
PHP
44 lines
719 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Services;
|
||
|
|
||
|
use Cache;
|
||
|
use Illuminate\Support\Facades\File;
|
||
|
use App\Media;
|
||
|
use App\MediaBlocklist;
|
||
|
|
||
|
class MediaBlocklistService
|
||
|
{
|
||
|
public static function get()
|
||
|
{
|
||
|
return MediaBlocklist::whereActive(true)
|
||
|
->pluck('sha256')
|
||
|
->toArray();
|
||
|
}
|
||
|
|
||
|
public static function exists($hash)
|
||
|
{
|
||
|
$hashes = self::get();
|
||
|
return in_array($hash, $hashes) == true;
|
||
|
}
|
||
|
|
||
|
public static function remove($hash)
|
||
|
{
|
||
|
if(!self::exists($hash)) {
|
||
|
return;
|
||
|
}
|
||
|
MediaBlocklist::whereSha256($hash)->delete();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
public static function add($hash, $metadata)
|
||
|
{
|
||
|
$m = new MediaBlocklist;
|
||
|
$m->sha256 = $hash;
|
||
|
$m->active = true;
|
||
|
$m->metadata = json_encode($metadata);
|
||
|
$m->save();
|
||
|
|
||
|
return $m;
|
||
|
}
|
||
|
}
|