Handle the public collection and address activities

This commit is contained in:
Jeremy Dormitzer 2018-10-09 11:57:37 -04:00
parent a12ea89f92
commit 914dd137a5
No known key found for this signature in database
GPG Key ID: 106FF4BA83EE8202
2 changed files with 11 additions and 0 deletions

View File

@ -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');

View File

@ -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');