@@ -33,6 +33,8 @@ public static function init() {
3333 \add_action ( 'update_option_activitypub_allow_likes ' , array ( self ::class, 'maybe_update_comment_counts ' ), 10 , 2 );
3434 \add_action ( 'update_option_activitypub_allow_reposts ' , array ( self ::class, 'maybe_update_comment_counts ' ), 10 , 2 );
3535 \add_filter ( 'pre_wp_update_comment_count_now ' , array ( static ::class, 'pre_wp_update_comment_count_now ' ), 10 , 3 );
36+
37+ \add_action ( 'transition_comment_status ' , array ( self ::class, 'maybe_announce_interaction ' ), 20 , 3 );
3638 }
3739
3840 /**
@@ -804,6 +806,38 @@ public static function pre_wp_update_comment_count_now( $new_count, $old_count,
804806 return $ new_count ;
805807 }
806808
809+ /**
810+ * Announce an interaction.
811+ *
812+ * @param string $new_status The new comment status.
813+ * @param string $old_status The old comment status.
814+ * @param \WP_Comment $comment The comment object.
815+ */
816+ public static function maybe_announce_interaction ( $ new_status , $ old_status , $ comment ) {
817+ if ( defined ( 'WP_IMPORTING ' ) && WP_IMPORTING ) {
818+ return ;
819+ }
820+
821+ if ( 'approved ' !== $ new_status || 'approved ' === $ old_status ) {
822+ return ;
823+ }
824+
825+ $ comment = \get_comment ( $ comment );
826+
827+ if ( ! self ::was_received ( $ comment ) ) {
828+ return ;
829+ }
830+
831+ // get activity from comment meta
832+ $ activity = \get_comment_meta ( $ comment ->comment_ID , '_activitypub_activity ' , true );
833+
834+ if ( ! $ activity ) {
835+ return ;
836+ }
837+
838+ add_to_outbox ( $ activity , 'Announce ' , Actors::BLOG_USER_ID , ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC );
839+ }
840+
807841 /**
808842 * Check if a comment type is enabled.
809843 *
0 commit comments