From 7a64773ff0b2c265d95680ef0d9a38c64733a7aa Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sun, 29 Jun 2014 17:08:41 +0530 Subject: [PATCH 1/4] Register a new post_status 'sf_spam' for spam messages --- supportflow.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/supportflow.php b/supportflow.php index fb186e3..ccc9481 100644 --- a/supportflow.php +++ b/supportflow.php @@ -189,6 +189,10 @@ private function setup_globals() { 'label' => __( 'Pending', 'supportflow' ), 'label_count' => _n_noop( 'Pending (%s)', 'Pending (%s)', 'supportflow' ), ), + 'sf_spam' => array( + 'label' => __( 'Spam', 'supportflow' ), + 'label_count' => _n_noop( 'Spam (%s)', 'Spam (%s)', 'supportflow' ), + ), 'sf_closed' => array( 'show_tickets' => false, 'label' => __( 'Closed', 'supportflow' ), From 2d50bd6fae0ad931aa3163486d3eed989f603951 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sun, 29 Jun 2014 17:32:01 +0530 Subject: [PATCH 2/4] Using akismet to filter out spam E-Mails --- classes/class-supportflow-email-replies.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/classes/class-supportflow-email-replies.php b/classes/class-supportflow-email-replies.php index a25cf3e..9e895cf 100644 --- a/classes/class-supportflow-email-replies.php +++ b/classes/class-supportflow-email-replies.php @@ -212,6 +212,21 @@ public function process_email( $imap_connection, $email, $i, $to, $email_account SupportFlow()->add_ticket_reply( $ticket_id, $message, $reply_args ); } else { + if ( method_exists( 'Akismet', 'http_post' ) ) { + $akismet_request = array( + 'blog' => get_site_url(), + 'user_ip' => '127.0.0.1', + 'comment_content' => $message, + 'comment_author' => $reply_author, + 'comment_author_email' => $reply_author_email, + ); + $akismet_request = http_build_query( $akismet_request ); + + $akismet_response = Akismet::http_post( $akismet_request, 'comment-check' ); + $is_spam = isset( $akismet_response[1] ) && 'true' == trim( $akismet_response[1] ); + + } + // If this wasn't in reply to an existing message, create a new ticket $new_ticket_args = array( 'subject' => $subject, @@ -222,6 +237,10 @@ public function process_email( $imap_connection, $email, $i, $to, $email_account 'email_account' => $email_account_id, ); + if ( isset( $is_spam ) && $is_spam ) { + $new_ticket_args['status'] = 'sf_spam'; + } + $ticket_id = SupportFlow()->create_ticket( $new_ticket_args ); } From 45885d8af14b9463dff8e0b9772cd43e1d5cb0b6 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sun, 29 Jun 2014 18:10:27 +0530 Subject: [PATCH 3/4] Prevent showing of spam threads in all threads page --- supportflow.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/supportflow.php b/supportflow.php index ccc9481..a3a8a22 100644 --- a/supportflow.php +++ b/supportflow.php @@ -190,8 +190,9 @@ private function setup_globals() { 'label_count' => _n_noop( 'Pending (%s)', 'Pending (%s)', 'supportflow' ), ), 'sf_spam' => array( - 'label' => __( 'Spam', 'supportflow' ), - 'label_count' => _n_noop( 'Spam (%s)', 'Spam (%s)', 'supportflow' ), + 'show_tickets' => false, + 'label' => __( 'Spam', 'supportflow' ), + 'label_count' => _n_noop( 'Spam (%s)', 'Spam (%s)', 'supportflow' ), ), 'sf_closed' => array( 'show_tickets' => false, From 552fe0fde3f10612017e63ebab421846fac5c102 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sat, 26 Jul 2014 02:54:11 +0530 Subject: [PATCH 4/4] Remove akisment integration todo comment It is already done --- supportflow.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/supportflow.php b/supportflow.php index a3a8a22..b660474 100644 --- a/supportflow.php +++ b/supportflow.php @@ -242,8 +242,6 @@ private function includes() { require_once( $this->plugin_dir . '/classes/class-supportflow-wp-cli.php' ); } - # TODO: Akismet plugin? - /** Admin *************************************************************/ // Quick admin check and load if needed