Skip to content

Commit 2753297

Browse files
authored
Fix Accept handling for outgoing Follow requests (#1931)
1 parent b3973da commit 2753297

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Fixed a bug in how follow requests were accepted to ensure they work correctly.

includes/collection/class-outbox.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ public static function get_by_guid( $guid ) {
196196
$post_id = $wpdb->get_var(
197197
$wpdb->prepare(
198198
"SELECT ID FROM $wpdb->posts WHERE guid=%s AND post_type=%s",
199-
esc_sql( $guid ),
200-
esc_sql( self::POST_TYPE )
199+
\esc_url( $guid ),
200+
self::POST_TYPE
201201
)
202202
);
203203

includes/handler/class-accept.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function handle_accept( $accept, $user_id ) {
5454
return;
5555
}
5656

57-
$actor_post = Actors::get_remote_by_uri( object_to_uri( $accept['object']['actor'] ) );
57+
$actor_post = Actors::get_remote_by_uri( object_to_uri( $accept['object']['object'] ) );
5858

5959
if ( \is_wp_error( $actor_post ) ) {
6060
return;

tests/includes/collection/class-test-following.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,32 +360,32 @@ public function test_unfollow() {
360360

361361
$accept_1 = array(
362362
'object' => array(
363-
'id' => $outbox_item_1->guid,
364-
'actor' => 'https://example.com/actor/1',
363+
'id' => $outbox_item_1->guid,
364+
'object' => 'https://example.com/actor/1',
365365
),
366366
);
367367
$accept_2 = array(
368368
'object' => array(
369-
'id' => $outbox_item_2->guid,
370-
'actor' => 'https://example.com/actor/1',
369+
'id' => $outbox_item_2->guid,
370+
'object' => 'https://example.com/actor/1',
371371
),
372372
);
373373
$accept_3 = array(
374374
'object' => array(
375-
'id' => $outbox_item_3->guid,
376-
'actor' => 'https://example.com/actor/1',
375+
'id' => $outbox_item_3->guid,
376+
'object' => 'https://example.com/actor/1',
377377
),
378378
);
379379
$accept_4 = array(
380380
'object' => array(
381-
'id' => $outbox_item_4->guid,
382-
'actor' => 'https://example.com/actor/1',
381+
'id' => $outbox_item_4->guid,
382+
'object' => 'https://example.com/actor/1',
383383
),
384384
);
385385
$accept_5 = array(
386386
'object' => array(
387-
'id' => $outbox_item_5->guid,
388-
'actor' => 'https://example.com/actor/1',
387+
'id' => $outbox_item_5->guid,
388+
'object' => 'https://example.com/actor/1',
389389
),
390390
);
391391

0 commit comments

Comments
 (0)