]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Blacklist plugin checks PuSH and Salmon notices
authorEvan Prodromou <evan@status.net>
Tue, 26 Oct 2010 15:20:43 +0000 (11:20 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 26 Oct 2010 15:20:43 +0000 (11:20 -0400)
plugins/Blacklist/BlacklistPlugin.php

index 10f89ef72392b20bc602de9f5d0abc0ad4498a33..60b59168fcf553fafbc551dcf4761bd17d474a78 100644 (file)
@@ -463,4 +463,45 @@ class BlacklistPlugin extends Plugin
         $hostname = parse_url($homepage, PHP_URL_HOST);
         return $hostname;
     }
+
+    function onStartHandleFeedEntry($activity)
+    {
+        return $this->_checkActivity($activity);
+    }
+
+    function onStartHandleSalmon($activity)
+    {
+        return $this->_checkActivity($activity);
+    }
+
+    function _checkActivity($activity)
+    {
+        $actor = $activity->actor;
+
+        if (empty($actor)) {
+            return true;
+        }
+
+        $homepage = strtolower($actor->link);
+
+        if (!empty($homepage)) {
+            if (!$this->_checkUrl($homepage)) {
+                $msg = sprintf(_m("Users from '%s' blocked."),
+                               $homepage);
+                throw new ClientException($msg);
+            }
+        }
+
+        $nickname = strtolower($actor->poco->preferredUsername);
+
+        if (!empty($nickname)) {
+            if (!$this->_checkNickname($nickname)) {
+                $msg = sprintf(_m("Posts from nickname '%s' disallowed."),
+                               $nickname);
+                throw new ClientException($msg);
+            }
+        }
+
+        return true;
+    }
 }