From 325f43fc70d7466ca05dfa5876cf4fc8c373c29e Mon Sep 17 00:00:00 2001 From: Terence Eden Date: Fri, 15 Mar 2024 09:13:06 +0000 Subject: [PATCH] Ignore certain messages. Prevent duplicate updates being saved --- index.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index e278efd..6c57b5c 100644 --- a/index.php +++ b/index.php @@ -296,6 +296,12 @@ // Some servers are very chatty. They send lots of irrelevant messages. // Before even bothering to validate them, we can delete them. + // This server doesn't handle Add, Remove, or Reject + // See https://www.w3.org/wiki/ActivityPub/Primer + if ( "Add" == $inbox_type || "Remove" == $inbox_type || "Reject" == $inbox_type ) { + die(); + } + // Messages from accounts which aren't being followed. // Some servers send delete messages about users we don't follow. // Lemmy sends messages even after unfollowing or blocking a channel @@ -335,6 +341,7 @@ $reply = false; } + // As long as one of these is true, the server will process it if ( !$reply && !$from_following && !$from_follower ) { // Don't bother processing it at all. die(); @@ -1750,11 +1757,6 @@ HTML; break; } } - - // If the message is valid, save the message in `/data/inbox/` - $uuid = uuid( $message ); - $filename = $uuid . "." . urlencode( $type ) . ".json"; - file_put_contents( $directories["inbox"] . "/{$filename}", json_encode( $message ) ); } // "One to stun, two to kill, three to make sure"