|
8 | 8 | namespace Activitypub\Rest; |
9 | 9 |
|
10 | 10 | use Activitypub\Activity\Activity; |
| 11 | +use Activitypub\Debug; |
11 | 12 |
|
12 | 13 | /** |
13 | 14 | * Inbox_Controller class. |
@@ -127,27 +128,31 @@ public function register_routes() { |
127 | 128 | public function create_item( $request ) { |
128 | 129 | $data = $request->get_json_params(); |
129 | 130 | $activity = Activity::init_from_array( $data ); |
130 | | - $type = $request->get_param( 'type' ); |
131 | | - $type = \strtolower( $type ); |
132 | | - |
133 | | - /** |
134 | | - * ActivityPub inbox action. |
135 | | - * |
136 | | - * @param array $data The data array. |
137 | | - * @param int|null $user_id The user ID. |
138 | | - * @param string $type The type of the activity. |
139 | | - * @param Activity|\WP_Error $activity The Activity object. |
140 | | - */ |
141 | | - \do_action( 'activitypub_inbox', $data, null, $type, $activity ); |
142 | | - |
143 | | - /** |
144 | | - * ActivityPub inbox action for specific activity types. |
145 | | - * |
146 | | - * @param array $data The data array. |
147 | | - * @param int|null $user_id The user ID. |
148 | | - * @param Activity|\WP_Error $activity The Activity object. |
149 | | - */ |
150 | | - \do_action( 'activitypub_inbox_' . $type, $data, null, $activity ); |
| 131 | + $type = \strtolower( $request->get_param( 'type' ) ); |
| 132 | + |
| 133 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput |
| 134 | + if ( wp_check_comment_disallowed_list( $activity->to_json( false ), '', '', '', $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'] ?? '' ) ) { |
| 135 | + Debug::write_log( 'Blocked activity from: ' . $activity->get_actor() ); |
| 136 | + } else { |
| 137 | + /** |
| 138 | + * ActivityPub inbox action. |
| 139 | + * |
| 140 | + * @param array $data The data array. |
| 141 | + * @param int|null $user_id The user ID. |
| 142 | + * @param string $type The type of the activity. |
| 143 | + * @param Activity|\WP_Error $activity The Activity object. |
| 144 | + */ |
| 145 | + \do_action( 'activitypub_inbox', $data, null, $type, $activity ); |
| 146 | + |
| 147 | + /** |
| 148 | + * ActivityPub inbox action for specific activity types. |
| 149 | + * |
| 150 | + * @param array $data The data array. |
| 151 | + * @param int|null $user_id The user ID. |
| 152 | + * @param Activity|\WP_Error $activity The Activity object. |
| 153 | + */ |
| 154 | + \do_action( 'activitypub_inbox_' . $type, $data, null, $activity ); |
| 155 | + } |
151 | 156 |
|
152 | 157 | $response = \rest_ensure_response( array() ); |
153 | 158 | $response->set_status( 202 ); |
|
0 commit comments