move functions
This commit is contained in:
parent
2d09cf5b45
commit
1353c89b38
2 changed files with 7 additions and 25 deletions
|
@ -18,7 +18,6 @@ class Comments {
|
||||||
\add_filter( 'comment_post', array( self::class, 'postprocess_comment' ), 10, 3 );
|
\add_filter( 'comment_post', array( self::class, 'postprocess_comment' ), 10, 3 );
|
||||||
\add_filter( 'comment_reply_link', array( self::class, 'comment_reply_link' ), 10, 4 );
|
\add_filter( 'comment_reply_link', array( self::class, 'comment_reply_link' ), 10, 4 );
|
||||||
\add_action( 'edit_comment', array( self::class, 'edit_comment' ), 20, 2 ); //schedule_admin_comment_activity
|
\add_action( 'edit_comment', array( self::class, 'edit_comment' ), 20, 2 ); //schedule_admin_comment_activity
|
||||||
\add_action( 'transition_comment_status', array( self::class, 'schedule_comment_activity' ), 20, 3 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,25 +132,4 @@ class Comments {
|
||||||
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $wp_comment, 'Update' ) );
|
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $wp_comment, 'Update' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Schedule Comment Activities
|
|
||||||
*
|
|
||||||
* transition_comment_status()
|
|
||||||
* @param int $comment
|
|
||||||
*/
|
|
||||||
public static function schedule_comment_activity( $new_status, $old_status, $activitypub_comment ) {
|
|
||||||
if ( 'approved' === $new_status && 'approved' !== $old_status ) {
|
|
||||||
|
|
||||||
// Only federate replies from local actors
|
|
||||||
$ap_object = unserialize( \get_comment_meta( $activitypub_comment->comment_ID, 'ap_object', true ) );
|
|
||||||
if ( empty( $ap_object ) ) {
|
|
||||||
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $activitypub_comment, 'Create' ) );
|
|
||||||
}
|
|
||||||
} elseif ( 'trash' === $new_status ) {
|
|
||||||
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $activitypub_comment, 'Delete' ) );
|
|
||||||
} elseif ( 'update' === $new_status ) {
|
|
||||||
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $activitypub_comment, 'Update' ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Scheduler {
|
||||||
*/
|
*/
|
||||||
public static function init() {
|
public static function init() {
|
||||||
\add_action( 'transition_post_status', array( self::class, 'schedule_post_activity' ), 33, 3 );
|
\add_action( 'transition_post_status', array( self::class, 'schedule_post_activity' ), 33, 3 );
|
||||||
\add_action( 'transition_comment_status', array( self::class, 'schedule_comment_activity' ), 33, 3 );
|
\add_action( 'transition_comment_status', array( self::class, 'schedule_comment_activity' ), 20, 3 );
|
||||||
|
|
||||||
\add_action( 'activitypub_update_followers', array( self::class, 'update_followers' ) );
|
\add_action( 'activitypub_update_followers', array( self::class, 'update_followers' ) );
|
||||||
\add_action( 'activitypub_cleanup_followers', array( self::class, 'cleanup_followers' ) );
|
\add_action( 'activitypub_cleanup_followers', array( self::class, 'cleanup_followers' ) );
|
||||||
|
@ -116,10 +116,14 @@ class Scheduler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'approved' === $new_status && 'approved' !== $old_status ) {
|
if ( 'approved' === $new_status && 'approved' !== $old_status ) {
|
||||||
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $comment, 'Create' ) );
|
// Only federate replies from local actors
|
||||||
|
$activity_object = unserialize( \get_comment_meta( $comment->comment_ID, 'ap_object', true ) );
|
||||||
|
if ( empty( $activity_object ) ) {
|
||||||
|
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $comment, 'Create' ) );
|
||||||
|
}
|
||||||
} elseif ( 'trash' === $new_status ) {
|
} elseif ( 'trash' === $new_status ) {
|
||||||
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $comment, 'Delete' ) );
|
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $comment, 'Delete' ) );
|
||||||
} elseif ( $old_status === $new_status ) {
|
} elseif ( 'update' === $new_status ) {
|
||||||
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $comment, 'Update' ) );
|
\wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $comment, 'Update' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue