From 261ab1364aa40384b0315be60e78cd89ea7fe661 Mon Sep 17 00:00:00 2001 From: winter Date: Sun, 23 Feb 2025 18:32:09 +0000 Subject: implement policies --- Digitigrade/Policy/BlockInstance.php | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Digitigrade/Policy/BlockInstance.php (limited to 'Digitigrade/Policy/BlockInstance.php') diff --git a/Digitigrade/Policy/BlockInstance.php b/Digitigrade/Policy/BlockInstance.php new file mode 100644 index 0000000..5f902f2 --- /dev/null +++ b/Digitigrade/Policy/BlockInstance.php @@ -0,0 +1,37 @@ +blockedHosts = $hosts; + } + + private function isBlocked(PushableModel $obj): bool { + $objHost = hostname_from_uri($obj->uri); + foreach ($this->blockedHosts as $host) { + if (str_ends_with($objHost, $host)) { + return true; + } + } + return false; + } + + public function checkActor(Actor $actor): bool { + return !$this->isBlocked($actor); + } + public function checkInteraction(Interaction $interaction): bool { + return !$this->isBlocked($interaction); + } + public function checkNote(Note $note): bool { + return !$this->isBlocked($note); + } +} \ No newline at end of file -- cgit v1.3