mirror of
https://github.com/Automattic/wordpress-activitypub
synced 2024-10-19 03:03:32 +00:00
introduce a filter to check if an activity should be sent or not
This commit is contained in:
parent
bdd8ab804f
commit
62b73d251a
1 changed files with 12 additions and 6 deletions
|
@ -77,7 +77,7 @@ class Activity_Dispatcher {
|
||||||
|
|
||||||
$activity = $transformer->to_activity( $type );
|
$activity = $transformer->to_activity( $type );
|
||||||
|
|
||||||
self::send_activity_to_inboxes( $activity, $user_id );
|
self::send_activity_to_followers( $activity, $user_id, $wp_object );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +103,7 @@ class Activity_Dispatcher {
|
||||||
$user_id = $transformer->get_wp_user_id();
|
$user_id = $transformer->get_wp_user_id();
|
||||||
$activity = $transformer->to_activity( 'Announce' );
|
$activity = $transformer->to_activity( 'Announce' );
|
||||||
|
|
||||||
self::send_activity_to_inboxes( $activity, $user_id );
|
self::send_activity_to_followers( $activity, $user_id, $wp_object );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +130,7 @@ class Activity_Dispatcher {
|
||||||
$activity->set_to( 'https://www.w3.org/ns/activitystreams#Public' );
|
$activity->set_to( 'https://www.w3.org/ns/activitystreams#Public' );
|
||||||
|
|
||||||
// send the update
|
// send the update
|
||||||
self::send_activity_to_inboxes( $activity, $user_id );
|
self::send_activity_to_followers( $activity, $user_id, $user );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,10 +138,16 @@ class Activity_Dispatcher {
|
||||||
*
|
*
|
||||||
* @param Activity $activity The ActivityPub Activity.
|
* @param Activity $activity The ActivityPub Activity.
|
||||||
* @param int $user_id The user ID.
|
* @param int $user_id The user ID.
|
||||||
|
* @param WP_User|WP_Post|WP_Comment $wp_object The WordPress object.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function send_activity_to_inboxes( $activity, $user_id ) {
|
private static function send_activity_to_followers( $activity, $user_id, $wp_object ) {
|
||||||
|
// check if the Activity should be send to the followers
|
||||||
|
if ( ! apply_filters( 'activitypub_send_activity_to_followers', true, $activity, $user_id, $wp_object ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$follower_inboxes = Followers::get_inboxes( $user_id );
|
$follower_inboxes = Followers::get_inboxes( $user_id );
|
||||||
|
|
||||||
$mentioned_inboxes = array();
|
$mentioned_inboxes = array();
|
||||||
|
|
Loading…
Reference in a new issue