From 937618101e904242073780c13c9e68bb0b34f6ef Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Wed, 27 Nov 2019 08:25:04 +0100 Subject: [PATCH] disable broken delete activity --- includes/class-activity-dispatcher.php | 2 +- includes/class-activitypub.php | 2 -- includes/rest/class-inbox.php | 16 ++++++++-------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/includes/class-activity-dispatcher.php b/includes/class-activity-dispatcher.php index 7457db8..ab4bddd 100644 --- a/includes/class-activity-dispatcher.php +++ b/includes/class-activity-dispatcher.php @@ -15,7 +15,7 @@ class Activity_Dispatcher { public static function init() { \add_action( 'activitypub_send_post_activity', array( '\Activitypub\Activity_Dispatcher', 'send_post_activity' ) ); \add_action( 'activitypub_send_update_activity', array( '\Activitypub\Activity_Dispatcher', 'send_update_activity' ) ); - \add_action( 'activitypub_send_delete_activity', array( '\Activitypub\Activity_Dispatcher', 'send_delete_activity' ) ); + // \add_action( 'activitypub_send_delete_activity', array( '\Activitypub\Activity_Dispatcher', 'send_delete_activity' ) ); } /** diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index 6097265..07d9223 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -24,8 +24,6 @@ class Activitypub { } \add_action( 'transition_post_status', array( '\Activitypub\Activitypub', 'schedule_post_activity' ), 10, 3 ); - - \add_action( 'trash_post', array( '\Activitypub\Activitypub', 'schedule_delete_activity' ), 10 ); } /** diff --git a/includes/rest/class-inbox.php b/includes/rest/class-inbox.php index b9bafba..85d4ba1 100644 --- a/includes/rest/class-inbox.php +++ b/includes/rest/class-inbox.php @@ -90,15 +90,15 @@ class Inbox { $data = \json_decode( $request->get_body(), true ); + if ( ! \is_array( $data ) || ! \array_key_exists( 'type', $data ) ) { + return new \WP_Error( 'rest_invalid_data', \__( 'Invalid payload', 'activitypub' ), array( 'status' => 422 ) ); + } + $type = 'create'; if ( ! empty( $data['type'] ) ) { $type = \strtolower( $data['type'] ); } - if ( ! \is_array( $data ) || ! \array_key_exists( 'type', $data ) ) { - return new \WP_Error( 'rest_invalid_data', \__( 'Invalid payload', 'activitypub' ), array( 'status' => 422 ) ); - } - \do_action( 'activitypub_inbox', $data, $author_id, $type ); \do_action( "activitypub_inbox_{$type}", $data, $author_id ); @@ -155,15 +155,15 @@ class Inbox { $author_id = $author->ID; } + if ( ! \is_array( $data ) || ! \array_key_exists( 'type', $data ) ) { + return new \WP_Error( 'rest_invalid_data', \__( 'Invalid payload', 'activitypub' ), array( 'status' => 422 ) ); + } + $type = 'create'; if ( ! empty( $data['type'] ) ) { $type = \strtolower( $data['type'] ); } - if ( ! \is_array( $data ) || ! \array_key_exists( 'type', $data ) ) { - return new \WP_Error( 'rest_invalid_data', \__( 'Invalid payload', 'activitypub' ), array( 'status' => 422 ) ); - } - \do_action( 'activitypub_inbox', $data, $author_id, $type ); \do_action( "activitypub_inbox_{$type}", $data, $author_id );