From 717bb5f456fd2b994f4e17f33540557e1fff90d3 Mon Sep 17 00:00:00 2001
From: Evan Prodromou <evan@status.net>
Date: Mon, 19 Mar 2012 10:15:33 -0400
Subject: [PATCH] Get the score if needed on-demand

---
 ActivitySpamPlugin.php | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/ActivitySpamPlugin.php b/ActivitySpamPlugin.php
index b6871d4cd9..35e12dc33d 100644
--- a/ActivitySpamPlugin.php
+++ b/ActivitySpamPlugin.php
@@ -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;
+    }
 }
-- 
2.39.5