fix missing user_id issue

This commit is contained in:
Matthias Pfefferle 2023-07-10 12:12:12 +02:00
parent 81d0e09f6e
commit 2f5a321474

View file

@ -30,6 +30,28 @@ class Activity_Dispatcher {
\add_action( 'activitypub_send_activity', array( self::class, 'send_activity_or_announce' ), 10, 2 ); \add_action( 'activitypub_send_activity', array( self::class, 'send_activity_or_announce' ), 10, 2 );
} }
/**
* Send Activities to followers and mentioned users or `Announce` (boost) a blog post.
*
* @param WP_Post $wp_post The ActivityPub Post.
* @param string $type The Activity-Type.
*
* @return void
*/
public static function send_activity_or_announce( WP_Post $wp_post, $type ) {
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
return;
}
$wp_post->post_author = Users::BLOG_USER_ID;
if ( is_single_user() ) {
self::send_activity( $wp_post, $type );
} else {
self::send_announce( $wp_post, $type );
}
}
/** /**
* Send Activities to followers and mentioned users. * Send Activities to followers and mentioned users.
* *
@ -58,34 +80,12 @@ class Activity_Dispatcher {
$json = $activity->to_json(); $json = $activity->to_json();
foreach ( $inboxes as $inbox ) { foreach ( $inboxes as $inbox ) {
safe_remote_post( $inbox, $json, $user_id ); safe_remote_post( $inbox, $json, $wp_post->post_author );
} }
} }
/** /**
* Send Activities to followers and mentioned users or `Announce` (boost) a blog post. * Send Announces to followers and mentioned users.
*
* @param WP_Post $wp_post The ActivityPub Post.
* @param string $type The Activity-Type.
*
* @return void
*/
public static function send_activity_or_announce( WP_Post $wp_post, $type ) {
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
return;
}
$wp_post->post_author = Users::BLOG_USER_ID;
if ( is_single_user() ) {
self::send_activity( $wp_post, $type );
} else {
self::send_announce( $wp_post, $type );
}
}
/**
* Send Activities to followers and mentioned users.
* *
* @param WP_Post $wp_post The ActivityPub Post. * @param WP_Post $wp_post The ActivityPub Post.
* @param string $type The Activity-Type. * @param string $type The Activity-Type.
@ -122,7 +122,7 @@ class Activity_Dispatcher {
$json = $activity->to_json(); $json = $activity->to_json();
foreach ( $inboxes as $inbox ) { foreach ( $inboxes as $inbox ) {
safe_remote_post( $inbox, $json, $user_id ); safe_remote_post( $inbox, $json, $wp_post->post_author );
} }
} }
} }