From 914dd137a51d91e6bbf9f32a65d51f0d048865ee Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 9 Oct 2018 11:57:37 -0400 Subject: [PATCH] Handle the public collection and address activities --- includes/client/posts.php | 5 +++++ includes/server/deliver.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/includes/client/posts.php b/includes/client/posts.php index eeff745..b0af23f 100644 --- a/includes/client/posts.php +++ b/includes/client/posts.php @@ -21,6 +21,11 @@ function handle_post_status_change( $new_status, $old_status, $post ) { $activity = \activities\delete\make_delete( $actor_slug, $post_object ); } if ( $activity && ! is_wp_error( $activity ) ) { + $followers = \followers\get_followers_collection( $actor_slug ); + $activity['to'] = array( + 'https://www.w3.org/ns/activitystreams#Public', + $followers['id'] + ); $server = rest_get_server(); $request = \WP_REST_Request::from_url( $actor_outbox ); $request->set_method('POST'); diff --git a/includes/server/deliver.php b/includes/server/deliver.php index 3013bd9..935bae3 100644 --- a/includes/server/deliver.php +++ b/includes/server/deliver.php @@ -51,6 +51,9 @@ a single object id (url), or an array of object ids. If it's a url, it should dereference to one of the above types */ function get_recipient_urls( $object, $depth, $acc ) { + if ( $object === 'https://www.w3.org/ns/activitystreams#Public' ) { + return array( $object ); + } if ( $depth === 30 ) { return $acc; } @@ -118,6 +121,9 @@ function get_recipient_urls( $object, $depth, $acc ) { function post_activity_to_inboxes( $actor_id, $activity, $recipients ) { foreach ( $recipients as $inbox ) { + if ( $inbox === 'https://www.w3.org/ns/activitystreams#Public' ) { + continue; + } if ( \util\is_local_url( $inbox ) ) { $request = \WP_REST_Request::from_url( $inbox ); $request->set_method('POST');