]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Get the score if needed on-demand
authorEvan Prodromou <evan@status.net>
Mon, 19 Mar 2012 14:15:33 +0000 (10:15 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 19 Mar 2012 14:15:33 +0000 (10:15 -0400)
ActivitySpamPlugin.php

index b6871d4cd94c33e286622d552ecf38a4e766ee31..35e12dc33de5987efcb04a7d2444681eb759326f 100644 (file)
@@ -173,7 +173,7 @@ class ActivitySpamPlugin extends Plugin
 
         if (!empty($notice)) {
 
-            $score = Spam_score::staticGet('notice_id', $notice->id);
+            $score = $this->getScore($notice);
 
             if (empty($score)) {
                 $this->debug("No score for notice " . $notice->id);
@@ -243,4 +243,19 @@ class ActivitySpamPlugin extends Plugin
                             _m('Test notices against the Activity Spam service.'));
         return true;
     }
+
+    function getScore($notice)
+    {
+        $score = Spam_score::staticGet('notice_id', $notice->id);
+        
+        if (!empty($score)) {
+            return $score;
+        }
+
+        $result = $this->filter->test($notice);
+
+        $score = Spam_score::saveNew($notice, $result);
+
+        return $score;
+    }
 }