/**
  * Classify a post as spam (and report it) or ham
  *
  * @param \mod_forum\event\post_created $event The event.
  * @return void
  */
 protected static function classifyAndReportSpam(\mod_forum\event\post_created $event)
 {
     $snapshot = $event->get_record_snapshot('forum_posts', $event->objectid);
     $text = $snapshot->subject . ' ' . $snapshot->message;
     $config = get_config('local_solr');
     $curl = new \curl();
     $result = $curl->post($config->spamclassifierhost . ':' . $config->spamclassifierport, array('text' => $text));
     if ($result_decoded = json_decode($result)) {
         if ($result_decoded['cat'] == 'spam') {
             require_once $CFG->dirroot . '/blocks/spam_deletion/lib.php';
             $postspam = new \forum_post_spam($event->objectid);
             $postspam->register_vote(2);
         }
     }
 }