updated plugin ActivityPub version 8.3.0
This commit is contained in:
@ -7,6 +7,8 @@
|
||||
|
||||
namespace Activitypub\Scheduler;
|
||||
|
||||
use Activitypub\Comment as Comment_Utils;
|
||||
|
||||
use function Activitypub\add_to_outbox;
|
||||
use function Activitypub\should_comment_be_federated;
|
||||
|
||||
@ -25,6 +27,7 @@ class Comment {
|
||||
// Comment transitions.
|
||||
\add_action( 'transition_comment_status', array( self::class, 'schedule_comment_activity' ), 20, 3 );
|
||||
\add_action( 'wp_insert_comment', array( self::class, 'schedule_comment_activity_on_insert' ), 10, 2 );
|
||||
\add_action( 'delete_comment', array( self::class, 'schedule_comment_delete_activity' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,6 +51,24 @@ class Comment {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check against supported comment types.
|
||||
* Only federate registered ActivityPub comment types and standard WordPress comments.
|
||||
*/
|
||||
$comment_type = $comment->comment_type;
|
||||
if ( '' === $comment_type ) {
|
||||
// Be backwards compatible with comments that have an empty type by treating them as standard comments.
|
||||
$comment_type = 'comment';
|
||||
}
|
||||
|
||||
$allowed_types = Comment_Utils::get_comment_type_slugs();
|
||||
$allowed_types[] = 'comment'; // Add core WordPress comment types.
|
||||
|
||||
// Check if comment type is in allowed list.
|
||||
if ( ! in_array( $comment_type, $allowed_types, true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$type = false;
|
||||
|
||||
if (
|
||||
@ -60,6 +81,7 @@ class Comment {
|
||||
\update_comment_meta( $comment->comment_ID, 'activitypub_comment_modified', time(), true );
|
||||
} elseif (
|
||||
'trash' === $new_status ||
|
||||
( 'delete' === $new_status && '' === $old_status ) || // Went through schedule_comment_delete_activity().
|
||||
'spam' === $new_status
|
||||
) {
|
||||
$type = 'Delete';
|
||||
@ -88,4 +110,17 @@ class Comment {
|
||||
self::schedule_comment_activity( 'approved', '', $comment );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule Delete activity when a comment is permanently deleted.
|
||||
*
|
||||
* @param int $comment_id Comment ID.
|
||||
* @param \WP_Comment $comment Comment object.
|
||||
*/
|
||||
public static function schedule_comment_delete_activity( $comment_id, $comment ) {
|
||||
// Only send Delete activities for comments that were previously federated.
|
||||
if ( Comment_Utils::was_sent( $comment ) ) {
|
||||
self::schedule_comment_activity( 'delete', '', $comment );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user