X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FActivitySpam%2FActivitySpamPlugin.php;h=978f8b4cf8cf3c6f59b1a56bdfc189aa0be4182f;hb=707076fca9d4355673e3d570caa19ceb99a1064d;hp=a905e72ccaf34605c03a9bf7ac0b8a6b6c3c83c9;hpb=10ea912785cac4ccd7ec4d42d431c89157b94611;p=quix0rs-gnu-social.git diff --git a/plugins/ActivitySpam/ActivitySpamPlugin.php b/plugins/ActivitySpam/ActivitySpamPlugin.php index a905e72cca..978f8b4cf8 100644 --- a/plugins/ActivitySpam/ActivitySpamPlugin.php +++ b/plugins/ActivitySpam/ActivitySpamPlugin.php @@ -65,6 +65,11 @@ class ActivitySpamPlugin extends Plugin $this->hideSpam = common_config('activityspam', 'hidespam'); + // Let DB_DataObject find Spam_score + + common_config_set('db', 'class_location', + common_config('db', 'class_location') .':'.dirname(__FILE__)); + return true; } @@ -180,11 +185,12 @@ class ActivitySpamPlugin extends Plugin if (!empty($notice)) { - $score = $this->getScore($notice); + $score = Spam_score::staticGet('notice_id', $notice->id); if (empty($score)) { - $this->debug("No score for notice " . $notice->id); - // XXX: show a question-mark or something + // If it's empty, we can train it. + $form = new TrainSpamForm($out, $notice); + $form->show(); } else if ($score->is_spam) { $form = new TrainHamForm($out, $notice); $form->show(); @@ -252,37 +258,6 @@ class ActivitySpamPlugin extends Plugin return true; } - function getScore($notice) - { - $score = Spam_score::staticGet('notice_id', $notice->id); - - if (!empty($score)) { - return $score; - } - - try { - - $result = $this->filter->test($notice); - - $score = Spam_score::saveNew($notice, $result); - - $this->log(LOG_INFO, "Notice " . $notice->id . " has spam score " . $score->score); - - } catch (Exception $e) { - // Log but continue - $this->log(LOG_ERR, $e->getMessage()); - $score = null; - } - - return $score; - } - - function onStartReadWriteTables(&$alwaysRW, &$rwdb) { - $alwaysRW[] = 'spam_score'; - return true; - } - - function onEndNoticeInScope($notice, $profile, &$bResult) { if ($this->hideSpam) {