send activities for blog-wide user
This commit is contained in:
parent
3e969c859a
commit
ced8cd0e29
2 changed files with 22 additions and 14 deletions
|
@ -68,35 +68,35 @@ class Scheduler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$activitypub_post = new Post( $post );
|
$type = false;
|
||||||
|
|
||||||
$activity_type = false;
|
|
||||||
|
|
||||||
if ( 'publish' === $new_status && 'publish' !== $old_status ) {
|
if ( 'publish' === $new_status && 'publish' !== $old_status ) {
|
||||||
$activity_type = 'Create';
|
$type = 'Create';
|
||||||
} elseif ( 'publish' === $new_status ) {
|
} elseif ( 'publish' === $new_status ) {
|
||||||
$activity_type = 'Update';
|
$type = 'Update';
|
||||||
} elseif ( 'trash' === $new_status ) {
|
} elseif ( 'trash' === $new_status ) {
|
||||||
$activity_type = 'Delete';
|
$type = 'Delete';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $activity_type ) {
|
if ( ! $type ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send User activities
|
// send User activities
|
||||||
if ( ! is_user_disabled( $activitypub_post->get_user_id() ) ) {
|
if ( ! is_user_disabled( $post->post_author ) ) {
|
||||||
|
$activitypub_post = new Post( $post );
|
||||||
|
|
||||||
\wp_schedule_single_event(
|
\wp_schedule_single_event(
|
||||||
\time(),
|
\time(),
|
||||||
'activitypub_send_activity',
|
'activitypub_send_activity',
|
||||||
array( $activitypub_post, $activity_type )
|
array( $activitypub_post, $type )
|
||||||
);
|
);
|
||||||
|
|
||||||
\wp_schedule_single_event(
|
\wp_schedule_single_event(
|
||||||
\time(),
|
\time(),
|
||||||
sprintf(
|
sprintf(
|
||||||
'activitypub_send_%s_activity',
|
'activitypub_send_%s_activity',
|
||||||
\strtolower( $activity_type )
|
\strtolower( $type )
|
||||||
),
|
),
|
||||||
array( $activitypub_post )
|
array( $activitypub_post )
|
||||||
);
|
);
|
||||||
|
@ -104,19 +104,19 @@ class Scheduler {
|
||||||
|
|
||||||
// send Blog-User activities
|
// send Blog-User activities
|
||||||
if ( ! is_user_disabled( User_Factory::BLOG_USER_ID ) ) {
|
if ( ! is_user_disabled( User_Factory::BLOG_USER_ID ) ) {
|
||||||
$activitypub_post->set_post_author( User_Factory::BLOG_USER_ID );
|
$activitypub_post = new Post( $post, User_Factory::BLOG_USER_ID );
|
||||||
|
|
||||||
\wp_schedule_single_event(
|
\wp_schedule_single_event(
|
||||||
\time(),
|
\time(),
|
||||||
'activitypub_send_activity',
|
'activitypub_send_activity',
|
||||||
array( $activitypub_post, $activity_type )
|
array( $activitypub_post, $type )
|
||||||
);
|
);
|
||||||
|
|
||||||
\wp_schedule_single_event(
|
\wp_schedule_single_event(
|
||||||
\time(),
|
\time(),
|
||||||
sprintf(
|
sprintf(
|
||||||
'activitypub_send_%s_activity',
|
'activitypub_send_%s_activity',
|
||||||
\strtolower( $activity_type )
|
\strtolower( $type )
|
||||||
),
|
),
|
||||||
array( $activitypub_post )
|
array( $activitypub_post )
|
||||||
);
|
);
|
||||||
|
|
|
@ -147,9 +147,17 @@ class Post {
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param WP_Post $post
|
* @param WP_Post $post
|
||||||
|
* @param int $post_author
|
||||||
*/
|
*/
|
||||||
public function __construct( $post ) {
|
public function __construct( $post, $post_author = null ) {
|
||||||
$this->post = \get_post( $post );
|
$this->post = \get_post( $post );
|
||||||
|
|
||||||
|
if ( $post_author ) {
|
||||||
|
$this->post_author = $post_author;
|
||||||
|
} else {
|
||||||
|
$this->post_author = $this->post->post_author;
|
||||||
|
}
|
||||||
|
|
||||||
$path = sprintf( 'users/%d/followers', intval( $this->get_post_author() ) );
|
$path = sprintf( 'users/%d/followers', intval( $this->get_post_author() ) );
|
||||||
$this->add_to( get_rest_url_by_path( $path ) );
|
$this->add_to( get_rest_url_by_path( $path ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue