updated plugin ActivityPub
version 0.17.0
This commit is contained in:
@ -23,16 +23,35 @@ class Activity_Dispatcher {
|
||||
*
|
||||
* @param \Activitypub\Model\Post $activitypub_post
|
||||
*/
|
||||
public static function send_post_activity( $activitypub_post ) {
|
||||
public static function send_post_activity( Model\Post $activitypub_post ) {
|
||||
// get latest version of post
|
||||
$user_id = $activitypub_post->get_post_author();
|
||||
|
||||
$activitypub_activity = new \Activitypub\Model\Activity( 'Create', \Activitypub\Model\Activity::TYPE_FULL );
|
||||
$activitypub_activity->from_post( $activitypub_post->to_array() );
|
||||
$activitypub_activity->from_post( $activitypub_post );
|
||||
|
||||
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {
|
||||
$inboxes = \Activitypub\get_follower_inboxes( $user_id );
|
||||
|
||||
$followers_url = \get_rest_url( null, '/activitypub/1.0/users/' . intval( $user_id ) . '/followers' );
|
||||
foreach ( $activitypub_activity->get_cc() as $cc ) {
|
||||
if ( $cc === $followers_url ) {
|
||||
continue;
|
||||
}
|
||||
$inbox = \Activitypub\get_inbox_by_actor( $cc );
|
||||
if ( ! $inbox || \is_wp_error( $inbox ) ) {
|
||||
continue;
|
||||
}
|
||||
// init array if empty
|
||||
if ( ! isset( $inboxes[ $inbox ] ) ) {
|
||||
$inboxes[ $inbox ] = array();
|
||||
}
|
||||
$inboxes[ $inbox ][] = $cc;
|
||||
}
|
||||
|
||||
foreach ( $inboxes as $inbox => $to ) {
|
||||
$to = array_values( array_unique( $to ) );
|
||||
$activitypub_activity->set_to( $to );
|
||||
$activity = $activitypub_activity->to_json(); // phpcs:ignore
|
||||
$activity = $activitypub_activity->to_json();
|
||||
|
||||
\Activitypub\safe_remote_post( $inbox, $activity, $user_id );
|
||||
}
|
||||
@ -48,7 +67,7 @@ class Activity_Dispatcher {
|
||||
$user_id = $activitypub_post->get_post_author();
|
||||
|
||||
$activitypub_activity = new \Activitypub\Model\Activity( 'Update', \Activitypub\Model\Activity::TYPE_FULL );
|
||||
$activitypub_activity->from_post( $activitypub_post->to_array() );
|
||||
$activitypub_activity->from_post( $activitypub_post );
|
||||
|
||||
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {
|
||||
$activitypub_activity->set_to( $to );
|
||||
@ -68,7 +87,7 @@ class Activity_Dispatcher {
|
||||
$user_id = $activitypub_post->get_post_author();
|
||||
|
||||
$activitypub_activity = new \Activitypub\Model\Activity( 'Delete', \Activitypub\Model\Activity::TYPE_FULL );
|
||||
$activitypub_activity->from_post( $activitypub_post->to_array() );
|
||||
$activitypub_activity->from_post( $activitypub_post );
|
||||
|
||||
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {
|
||||
$activitypub_activity->set_to( $to );
|
||||
|
Reference in New Issue
Block a user