Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/05/2018 04:54:39 PM (7 years ago)
Author:
djpaul
Message:

Activity, Akismet: add support for Akismet's "discard worse spam" feature.

Fixes #6594

Thanks to slaFFik, and via bbPress, netweb and Otto42, for historical contributions towards this change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-akismet.php

    r10516 r11890  
    412412            // Mark as spam.
    413413            bp_activity_mark_as_spam( $activity, 'by_akismet' );
     414
     415            if (
     416                Akismet::allow_discard() &&
     417                ! empty( $activity_data['bp_as_result_headers']['X-akismet-pro-tip'] ) &&
     418                $activity_data['bp_as_result_headers']['X-akismet-pro-tip'] === 'discard'
     419            ) {
     420                // If this is so spammy it's not worth your time, let's just delete it.
     421                if ( $activity->type === 'activity_comment' ) {
     422                    bp_activity_delete_comment( $activity->item_id, $activity->id );
     423                } else {
     424                    bp_activity_delete( array( 'id' => $activity->id ) );
     425                }
     426            }
    414427        }
    415428
     
    547560        remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
    548561
     562        $activity_data['bp_as_result_headers'] = array();
     563        $activity_data['bp_as_result']         = '';
     564
    549565        // Get the response.
    550         if ( ! empty( $response[1] ) && ! is_wp_error( $response[1] ) )
    551             $activity_data['bp_as_result'] = $response[1];
    552         else
    553             $activity_data['bp_as_result'] = false;
     566        if ( ! empty( $response[1] ) && ! is_wp_error( $response[1] ) ) {
     567            $activity_data['bp_as_result_headers'] = $response[0];
     568            $activity_data['bp_as_result']         = $response[1];
     569        }
    554570
    555571        // Perform a daily tidy up.
Note: See TracChangeset for help on using the changeset viewer.