Skip to content

Commit

Permalink
Improve "state"
Browse files Browse the repository at this point in the history
  • Loading branch information
janboddez committed Jan 5, 2024
1 parent aaaa1ec commit 0d806fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 7 additions & 3 deletions includes/collection/class-interactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function () {
*
* @param array $activity The activity-object
*
* @return array|string|false The commentdata or false on failure
* @return array|string|int|\WP_Error|false The commentdata or false on failure
*/
public static function update_comment( $activity ) {
$meta = get_remote_metadata_by_actor( $activity['actor'] );
Expand Down Expand Up @@ -135,14 +135,18 @@ function () {
);
\add_filter( 'wp_kses_allowed_html', array( self::class, 'allowed_comment_html' ), 10, 2 );

\wp_update_comment( $commentdata, true );
$state = \wp_update_comment( $commentdata, true );

\remove_filter( 'wp_kses_allowed_html', array( self::class, 'allowed_comment_html' ), 10 );
\remove_filter( 'pre_option_require_name_email', '__return_false' );
// re-add flood control
\add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );

return $commentdata;
if ( 1 === $state ) {
return $commentdata;
} else {
return $state; // Either `false` or a `WP_Error` instance or `0` or `1`!
}
}

/**
Expand Down
4 changes: 1 addition & 3 deletions includes/handler/class-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ public static function update_interaction( $activity ) {
if ( ! empty( $commentdata['comment_ID'] ) ) {
$state = 1;
$reaction = \get_comment( $commentdata['comment_ID'] );
} elseif ( 'inactive' === $commentdata ) {
$state = $commentdata;
} else {
$state = 0;
$state = $commentdata;
}

\do_action( 'activitypub_handled_update', $activity, null, $state, $reaction );
Expand Down

0 comments on commit 0d806fe

Please sign in to comment.