Skip to content

Commit c7100d9

Browse files
authored
Inbox: Replace debug call with action (#1620)
1 parent 11f508e commit c7100d9

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

includes/class-debug.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public static function init() {
2020
if ( \WP_DEBUG && \WP_DEBUG_LOG ) {
2121
\add_action( 'activitypub_safe_remote_post_response', array( self::class, 'log_remote_post_responses' ), 10, 2 );
2222
\add_action( 'activitypub_inbox', array( self::class, 'log_inbox' ), 10, 3 );
23+
\add_action( 'activitypub_rest_inbox_disallowed', array( self::class, 'log_inbox' ), 10, 3 );
2324

2425
\add_action( 'activitypub_sent_to_inbox', array( self::class, 'log_sent_to_inbox' ), 10, 2 );
2526
}

includes/rest/class-actors-inbox-controller.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,15 @@ public function create_item( $request ) {
178178

179179
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput
180180
if ( \wp_check_comment_disallowed_list( $activity->to_json( false ), '', '', '', $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'] ?? '' ) ) {
181-
Debug::write_log( 'Blocked activity from: ' . $activity->get_actor() );
181+
/**
182+
* ActivityPub inbox disallowed activity.
183+
*
184+
* @param array $data The data array.
185+
* @param int|null $user_id The user ID.
186+
* @param string $type The type of the activity.
187+
* @param Activity|\WP_Error $activity The Activity object.
188+
*/
189+
do_action( 'activitypub_rest_inbox_disallowed', $data, $user->get__id(), $type, $activity );
182190
} else {
183191
/**
184192
* ActivityPub inbox action.

includes/rest/class-inbox-controller.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ public function create_item( $request ) {
136136

137137
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput
138138
if ( \wp_check_comment_disallowed_list( $activity->to_json( false ), '', '', '', $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'] ?? '' ) ) {
139-
Debug::write_log( 'Blocked activity from: ' . $activity->get_actor() );
139+
/**
140+
* ActivityPub inbox disallowed activity.
141+
*
142+
* @param array $data The data array.
143+
* @param null $user_id The user ID.
144+
* @param string $type The type of the activity.
145+
* @param Activity|\WP_Error $activity The Activity object.
146+
*/
147+
do_action( 'activitypub_rest_inbox_disallowed', $data, null, $type, $activity );
140148
} else {
141149
$recipients = extract_recipients_from_activity( $data );
142150

0 commit comments

Comments
 (0)