From 1eec93d3420a30e7d3797c3e34db6f2e5fbe86e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 4 Jan 2025 10:01:14 +0100 Subject: [PATCH] Change sequence of checks in handlers. Check for whether we are following the actor first. --- includes/activitypub/handler/class-create.php | 10 +++++----- includes/activitypub/handler/class-undo.php | 2 +- includes/activitypub/handler/class-update.php | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/activitypub/handler/class-create.php b/includes/activitypub/handler/class-create.php index 9a860f4..8c977fb 100644 --- a/includes/activitypub/handler/class-create.php +++ b/includes/activitypub/handler/class-create.php @@ -41,11 +41,6 @@ class Create { return; } - // Check that we are actually following this actor. - if ( ! Event_Sources::actor_is_event_source( $activity['actor'] ) ) { - return false; - } - // Check if Activity is public or not. if ( ! is_activity_public( $activity ) ) { return; @@ -56,6 +51,11 @@ class Create { return; } + // Check that we are actually following this actor. + if ( ! Event_Sources::actor_is_event_source( $activity['actor'] ) ) { + return false; + } + if ( Event_Sources::is_time_passed( $activity['object']['startTime'] ) ) { return new \WP_Error( 'event_bridge_for_activitypub_not_accepting_events_from_the_past', diff --git a/includes/activitypub/handler/class-undo.php b/includes/activitypub/handler/class-undo.php index ed752eb..b2763a3 100644 --- a/includes/activitypub/handler/class-undo.php +++ b/includes/activitypub/handler/class-undo.php @@ -42,7 +42,7 @@ class Undo { return; } - // Check that we are actually following/or have a pending follow request this actor. + // Check that we are actually following/or have a pending follow request for this actor. if ( ! Event_Sources::actor_is_event_source( $activity['actor'] ) ) { return; } diff --git a/includes/activitypub/handler/class-update.php b/includes/activitypub/handler/class-update.php index a1a6372..00bcc37 100644 --- a/includes/activitypub/handler/class-update.php +++ b/includes/activitypub/handler/class-update.php @@ -41,11 +41,6 @@ class Update { return; } - // Check that we are actually following this actor. - if ( ! Event_Sources::actor_is_event_source( $activity['actor'] ) ) { - return; - } - // Check if Activity is public or not. if ( ! is_activity_public( $activity ) ) { return; @@ -56,6 +51,11 @@ class Update { return; } + // Check that we are actually following this actor. + if ( ! Event_Sources::actor_is_event_source( $activity['actor'] ) ) { + return false; + } + if ( Event_Sources::is_time_passed( $activity['object']['startTime'] ) ) { return; }