updated plugin ActivityPub version 2.4.0

This commit is contained in:
2024-06-27 12:10:38 +00:00
committed by Gitium
parent eeef5ad6e0
commit 4e493c268e
49 changed files with 1368 additions and 491 deletions

View File

@ -64,7 +64,11 @@ class Activity_Dispatcher {
* @return void
*/
public static function send_activity( $wp_object, $type, $user_id = null ) {
$transformer = Factory::get_transformer( $wp_object );
$transformer = Factory::get_transformer( $wp_object ); // Could potentially return a `\WP_Error` instance.
if ( \is_wp_error( $transformer ) ) {
return;
}
if ( null !== $user_id ) {
$transformer->change_wp_user_id( $user_id );
@ -98,18 +102,22 @@ class Activity_Dispatcher {
return;
}
// do not announce replies
if ( $wp_object instanceof WP_Comment ) {
$transformer = Factory::get_transformer( $wp_object );
if ( \is_wp_error( $transformer ) ) {
return;
}
$transformer = Factory::get_transformer( $wp_object );
$transformer->change_wp_user_id( Users::BLOG_USER_ID );
$user_id = Users::BLOG_USER_ID;
$activity = $transformer->to_activity( $type );
$user = Users::get_by_id( Users::BLOG_USER_ID );
$user_id = $transformer->get_wp_user_id();
$activity = $transformer->to_activity( 'Announce' );
$announce = new Activity();
$announce->set_type( 'Announce' );
$announce->set_object( $activity );
$announce->set_actor( $user->get_id() );
self::send_activity_to_followers( $activity, $user_id, $wp_object );
self::send_activity_to_followers( $announce, $user_id, $wp_object );
}
/**