From: Evan Prodromou Date: Mon, 19 Mar 2012 14:15:33 +0000 (-0400) Subject: Get the score if needed on-demand X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=717bb5f456fd2b994f4e17f33540557e1fff90d3;p=quix0rs-gnu-social.git Get the score if needed on-demand --- 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; + } }