Fix: don't send accept or reject again as answer to a follow request on bulk action
Some checks failed
PHP_CodeSniffer / phpcs (push) Has been cancelled
Unit Testing / phpunit (5.6, 6.2) (push) Has been cancelled
Unit Testing / phpunit (7.0) (push) Has been cancelled
Unit Testing / phpunit (7.2) (push) Has been cancelled
Unit Testing / phpunit (7.3) (push) Has been cancelled
Unit Testing / phpunit (7.4) (push) Has been cancelled
Unit Testing / phpunit (8.0) (push) Has been cancelled
Unit Testing / phpunit (8.1) (push) Has been cancelled
Unit Testing / phpunit (8.2) (push) Has been cancelled
Unit Testing / phpunit (latest) (push) Has been cancelled

This commit is contained in:
André Menrath 2024-01-04 16:02:14 +01:00
parent 35fa38b6b7
commit d046c4f713
3 changed files with 19 additions and 7 deletions

View file

@ -75,11 +75,11 @@ class Follow {
* @return void
*/
public static function send_follow_response( $user_id, $inbox, $object, $type ) {
// send activity
$activity = new Activity();
$activity->set_type( $type );
$activity->set_object( $object );
$activity->set_actor( $user_id );
$activity->set_actor( Users::get_by_id( $user_id )->get_url() );
$activity->set_to( $object['actor'] );
$activity->set_id( $user_id . '#accept-' . \preg_replace( '~^https?://~', '', $object['actor'] ) . '-' . \time() );

View file

@ -43,6 +43,12 @@ class Follow_Request extends Base_Object {
*/
protected $_actor;
/**
* The status: 'approved', 'pending', 'rejected'<div class=""></div>
* @var string
*/
protected $_status;
/**
* @param int $id
* @return Follow_Request $follow_request
@ -110,6 +116,7 @@ class Follow_Request extends Base_Object {
$follow_request = new static();
$follow_request->set_id( $post->guid );
$follow_request->set__id( $post->ID );
$follow_request->set__status( $post->post_status );
$follow_request->set_type( 'Follow' );
return $follow_request;
@ -238,8 +245,6 @@ class Follow_Request extends Base_Object {
$user_id = get_post_meta( $this->get__id(), 'activitypub_user_id', true );
}
$user = Users::get_by_id( $user_id );
if ( ! $follower_id ) {
$follower_id = $this->get_follower_id();
}
@ -250,6 +255,7 @@ class Follow_Request extends Base_Object {
$follow_object = array(
'id' => $this->get_id(),
'type' => $this->get_type(),
'actor' => get_post_field( 'guid', $follower_id ),
);
do_action( 'activitypub_send_follow_response', $user_id, $follower_inbox, $follow_object, $type );

View file

@ -256,7 +256,7 @@ class Follow_Requests extends WP_List_Table {
break;
case 'reject':
$follow_request->reject();
wp_die( 'rejected' );
wp_die( 'rejected' );
break;
case 'delete':
$follow_request->delete();
@ -352,7 +352,10 @@ class Follow_Requests extends WP_List_Table {
$follow_requests = array( $follow_requests );
}
foreach ( $follow_requests as $follow_request ) {
Follow_Request::from_wp_id( $follow_request )->reject();
$follow_request = Follow_Request::from_wp_id( $follow_request );
if ( $follow_request->can_handle_follow_request() && $follow_request->get__status() != 'rejected' ) {
$follow_request->reject();
}
}
break;
case 'approve':
@ -360,7 +363,10 @@ class Follow_Requests extends WP_List_Table {
$follow_requests = array( $follow_requests );
}
foreach ( $follow_requests as $follow_request ) {
Follow_Request::from_wp_id( $follow_request )->approve();
$follow_request = Follow_Request::from_wp_id( $follow_request );
if ( $follow_request->can_handle_follow_request() && $follow_request->get__status() != 'approved' ) {
$follow_request->approve();
}
}
break;
}