Address comments to attributedTo and actor of parents

This commit is contained in:
Jeremy Dormitzer 2018-10-26 06:41:31 -04:00
parent 277c11d8bb
commit aa53db8849
2 changed files with 12 additions and 3 deletions

View File

@ -138,7 +138,7 @@ function get_comment_to( $comment, $followers_id ) {
'https://www.w3.org/ns/activitystreams#Public',
$followers_id,
);
$to = array_unique( array_merge( $to, traverse_reply_chain( $comment ) ) );
$to = array_values( array_unique( array_merge( $to, traverse_reply_chain( $comment ) ) ) );
return $to;
}
@ -164,8 +164,17 @@ function traverse_reply_chain_helper( $object, $depth, $acc ) {
$recipients = array_unique( array_merge( $recipients, $new_recipients ) );
}
}
if ( array_key_exists( 'attributedTo', $parent ) ) {
$attributed_to = \pterotype\util\dereference_object( $parent['attributedTo'] );
$recipients[] = $attributed_to['id'];
}
if ( array_key_exists( 'actor', $parent ) ) {
$actor = \pterotype\util\dereference_object( $parent['actor'] );
$recipients[] = $actor['id'];
}
$recipients = array_values( array_unique( $recipients ) );
return traverse_reply_chain_helper(
$parent, $depth + 1, array_unique( array_merge( $acc, $recipients ) )
$parent, $depth + 1, array_values( array_unique( array_merge( $acc, $recipients ) ) )
);
}
?>

View File

@ -18,7 +18,7 @@ function deliver_activity( $actor_slug, $activity ) {
$recipients, retrieve_recipients_for_field( $field, $activity )
);
}
$recipients = array_unique( $recipients );
$recipients = array_values( array_unique( $recipients ) );
if ( array_key_exists( 'actor', $activity ) ) {
$actor = \pterotype\util\dereference_object( $activity['actor'] );
$recipients = remove_actor_inbox_from_recipients( $actor, $recipients );