From 0f72f944063e2b9690f5d315242d8bbc6ee41792 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Wed, 31 May 2023 09:39:35 +0200 Subject: [PATCH] small updates --- includes/class-activity-dispatcher.php | 22 ++++++++++++++-------- templates/blog-json.php | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/includes/class-activity-dispatcher.php b/includes/class-activity-dispatcher.php index 811f923..bea6b4e 100644 --- a/includes/class-activity-dispatcher.php +++ b/includes/class-activity-dispatcher.php @@ -76,22 +76,28 @@ class Activity_Dispatcher { self::send_user_activity( $activitypub_post, $activity_type, User_Factory::BLOG_USER_ID ); } + /** + * Send Activities to followers and mentioned users. + * + * @param Post $activitypub_post The ActivityPub Post. + * @param string $activity_type The Activity-Type. + * @param int $user_id The User-ID. + * + * @return void + */ public static function send_user_activity( Post $activitypub_post, $activity_type, $user_id = null ) { if ( $user_id ) { - $user = User_Factory::get_by_id( $user_id ); - $actor = $user->get_url(); + $user = User_Factory::get_by_id( $user_id ); + $user_id = $user->get_id(); + $actor = $user->get_url(); } else { - // get latest version of post $user_id = $activitypub_post->get_post_author(); - $actor = null; + $actor = $activitypub_activity->get_actor(); } $activitypub_activity = new Activity( $activity_type ); $activitypub_activity->from_post( $activitypub_post ); - - if ( $actor ) { - $activitypub_activity->set_actor( $actor ); - } + $activitypub_activity->set_actor( $actor ); $follower_inboxes = Followers::get_inboxes( $user_id ); $mentioned_inboxes = Mention::get_inboxes( $activitypub_activity->get_cc() ); diff --git a/templates/blog-json.php b/templates/blog-json.php index cfa759c..b9c5f96 100644 --- a/templates/blog-json.php +++ b/templates/blog-json.php @@ -1,5 +1,5 @@