Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions classes/class-supportflow-email-replies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 );
}

Expand Down
7 changes: 5 additions & 2 deletions supportflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ private function setup_globals() {
'label' => __( 'Pending', 'supportflow' ),
'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'supportflow' ),
),
'sf_spam' => array(
'show_tickets' => false,
'label' => __( 'Spam', 'supportflow' ),
'label_count' => _n_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'supportflow' ),
),
'sf_closed' => array(
'show_tickets' => false,
'label' => __( 'Closed', 'supportflow' ),
Expand Down Expand Up @@ -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
Expand Down