Skip to content

Commit 98824d3

Browse files
committed
tweak federation state a bit
1 parent a4f8c30 commit 98824d3

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

includes/class-activity-dispatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use function Activitypub\is_single_user;
1414
use function Activitypub\is_user_disabled;
1515
use function Activitypub\safe_remote_post;
16-
use function Activitypub\mark_wp_object_as_federated;
16+
use function Activitypub\set_wp_object_state;
1717

1818
/**
1919
* ActivityPub Activity_Dispatcher Class
@@ -170,6 +170,6 @@ private static function send_activity_to_followers( $activity, $user_id, $wp_obj
170170
safe_remote_post( $inbox, $json, $user_id );
171171
}
172172

173-
mark_wp_object_as_federated( $wp_object );
173+
set_wp_object_state( $wp_object, 'federated' );
174174
}
175175
}

includes/class-comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static function was_sent( $comment ) {
118118

119119
$status = \get_comment_meta( $comment->comment_ID, 'activitypub_status', true );
120120

121-
if ( 'federated' === $status ) {
121+
if ( $status ) {
122122
return true;
123123
}
124124

includes/class-scheduler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ public static function schedule_comment_activity( $new_status, $old_status, $com
202202
return;
203203
}
204204

205+
set_wp_object_state( $comment, 'federate' );
206+
205207
\wp_schedule_single_event(
206208
\time(),
207209
'activitypub_send_activity',

includes/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,13 +779,13 @@ function is_local_comment( $comment ) {
779779
* @param WP_Comment|WP_Post|mixed $wp_object
780780
* @return void
781781
*/
782-
function mark_wp_object_as_federated( $wp_object ) {
782+
function set_wp_object_state( $wp_object, $state ) {
783783
$meta_key = 'activitypub_status';
784784

785785
if ( $wp_object instanceof \WP_Post ) {
786-
\update_post_meta( $wp_object->ID, $meta_key, 'federated' );
786+
\update_post_meta( $wp_object->ID, $meta_key, $state );
787787
} elseif ( $wp_object instanceof \WP_Comment ) {
788-
\update_comment_meta( $wp_object->comment_ID, $meta_key, 'federated' );
788+
\update_comment_meta( $wp_object->comment_ID, $meta_key, $state );
789789
} else {
790790
\apply_filters( 'activitypub_mark_wp_object_as_federated', $wp_object );
791791
}

tests/test-class-activitypub-comment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function ability_to_federate_comment() {
5353
'comment_author_email' => '',
5454
),
5555
'expected' => array(
56-
'was_sent' => false,
56+
'was_sent' => true,
5757
'was_received' => false,
5858
'should_be_federated' => true,
5959
),
@@ -203,7 +203,7 @@ public function ability_to_federate_threaded_comment() {
203203
'comment_author_email' => '',
204204
),
205205
'expected' => array(
206-
'was_sent' => false,
206+
'was_sent' => true,
207207
'was_received' => false,
208208
'should_be_federated' => false,
209209
),

0 commit comments

Comments
 (0)