From 69ec86a3dce3760abeafa5d7c8916057fb97faf6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Mar 2012 13:21:14 -0400 Subject: [PATCH] Use only stored scores and pre-cache them --- ActivitySpamPlugin.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ActivitySpamPlugin.php b/ActivitySpamPlugin.php index d80f19cf31..a905e72cca 100644 --- a/ActivitySpamPlugin.php +++ b/ActivitySpamPlugin.php @@ -282,14 +282,15 @@ class ActivitySpamPlugin extends Plugin return true; } + function onEndNoticeInScope($notice, $profile, &$bResult) { if ($this->hideSpam) { if ($bResult) { - $score = $this->getScore($notice); + $score = Spam_score::staticGet('notice_id', $notice->id); - if ($score->is_spam) { + if (!empty($score) && $score->is_spam) { if (empty($profile) || ($profile->id !== $notice->profile_id && !$profile->hasRight(self::REVIEWSPAM))) { @@ -301,4 +302,17 @@ class ActivitySpamPlugin extends Plugin return true; } + + /** + * Pre-cache our spam scores if needed. + */ + function onEndNoticeListPrefill(&$notices, &$profiles, $avatarSize) { + if ($this->hideSpam) { + foreach ($notices as $notice) { + $ids[] = $notice->id; + } + Memcached_DataObject::multiGet('Spam_score', 'notice_id', $ids); + } + return true; + } } -- 2.39.5