From 5d0a24a7792abcd72423a16cee16d5e1123c3752 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Jul 2020 22:14:57 -0600 Subject: [PATCH] Add MediaBlocklistService --- app/Services/MediaBlocklistService.php | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 app/Services/MediaBlocklistService.php diff --git a/app/Services/MediaBlocklistService.php b/app/Services/MediaBlocklistService.php new file mode 100644 index 00000000..94778852 --- /dev/null +++ b/app/Services/MediaBlocklistService.php @@ -0,0 +1,44 @@ +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; + } +} \ No newline at end of file