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 );
}
diff --git a/supportflow.php b/supportflow.php
index fb186e3..b660474 100644
--- a/supportflow.php
+++ b/supportflow.php
@@ -189,6 +189,11 @@ private function setup_globals() {
'label' => __( 'Pending', 'supportflow' ),
'label_count' => _n_noop( 'Pending (%s)', 'Pending (%s)', 'supportflow' ),
),
+ 'sf_spam' => array(
+ 'show_tickets' => false,
+ 'label' => __( 'Spam', 'supportflow' ),
+ 'label_count' => _n_noop( 'Spam (%s)', 'Spam (%s)', 'supportflow' ),
+ ),
'sf_closed' => array(
'show_tickets' => false,
'label' => __( 'Closed', 'supportflow' ),
@@ -237,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