Skip to:
Content

BuddyPress.org

Changeset 10860


Ignore:
Timestamp:
06/01/2016 09:23:09 PM (8 years ago)
Author:
r-a-y
Message:

Activity: Set WP error if activity content hits a moderation filter.

One important change we are making here is if the activity content matches
a word from the "Comment Blacklist" discussion option from WordPress, we
now stop recording the activity item.

Previously, we were still recording the activity item, but marking it as
spam.

See #6719.

Location:
trunk/src/bp-activity
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-filters.php

    r10852 r10860  
    156156
    157157    // Only check specific types of activity updates.
    158     if ( !in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
     158    if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) {
    159159        return;
    160 
    161     // Unset the activity component so activity stream update fails
     160    }
     161
     162    // Send back the error so activity update fails.
    162163    // @todo This is temporary until some kind of moderation is built.
    163     if ( !bp_core_check_for_moderation( $activity->user_id, '', $activity->content ) )
     164    $moderate = bp_core_check_for_moderation( $activity->user_id, '', $activity->content, 'wp_error' );
     165    if ( is_wp_error( $moderate ) ) {
     166        $activity->errors = $moderate;
     167
     168        // Backpat.
    164169        $activity->component = false;
     170    }
    165171}
    166172
     
    175181
    176182    // Only check specific types of activity updates.
    177     if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
     183    if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) {
    178184        return;
    179 
    180     // Mark as spam.
    181     if ( ! bp_core_check_for_blacklist( $activity->user_id, '', $activity->content ) )
    182         bp_activity_mark_as_spam( $activity, 'by_blacklist' );
     185    }
     186
     187    // Send back the error so activity update fails.
     188    // @todo This is temporary until some kind of trash status is built.
     189    $blacklist = bp_core_check_for_blacklist( $activity->user_id, '', $activity->content, 'wp_error' );
     190    if ( is_wp_error( $blacklist ) ) {
     191        $activity->errors = $blacklist;
     192
     193        // Backpat.
     194        $activity->component = false;
     195    }
    183196}
    184197
  • trunk/src/bp-activity/bp-activity-functions.php

    r10858 r10860  
    33263326 * @since 1.6.0
    33273327 *
     3328 * @todo We should probably save $source to activity meta.
     3329 *
    33283330 * @param BP_Activity_Activity $activity The activity item to be spammed.
    33293331 * @param string               $source   Optional. Default is "by_a_person" (ie, a person has
Note: See TracChangeset for help on using the changeset viewer.