Get the score if needed on-demand

This commit is contained in:
Evan Prodromou 2012-03-19 10:15:33 -04:00
parent 6a49e26321
commit 717bb5f456

View 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;
}
}