From 2a874e01119f32433055f2ed5ac6e3efb2f35882 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Thu, 7 Mar 2024 08:28:50 +1100 Subject: [PATCH] preserve link to original add activity --- Code/Lib/Activity.php | 1 + Code/Lib/ActivityStreams.php | 10 ++++++++++ Code/Lib/Libzot.php | 2 ++ Code/Module/Inbox.php | 3 +++ Code/Module/Outbox.php | 1 + boot.php | 2 +- 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index 6b89aae9f..db72df550 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -4500,6 +4500,7 @@ class Activity $isCollectionOperation = true; $rawActivity = json_decode($activity->raw, true); $activity = new ActivityStreams($rawActivity['object'], null, true); + $activity->setApproveId($rawActivity['id']); } logger($activity->debug(), LOGGER_DATA); diff --git a/Code/Lib/ActivityStreams.php b/Code/Lib/ActivityStreams.php index ce771dfc5..1b2ee2bed 100644 --- a/Code/Lib/ActivityStreams.php +++ b/Code/Lib/ActivityStreams.php @@ -29,6 +29,7 @@ class ActivityStreams public $signer = null; public $edsig = null; public $sigok = false; + public $approveId = null; public $recips = null; public $raw_recips = null; public $saved_recips = null; @@ -536,6 +537,15 @@ class ActivityStreams return var_export($this, true); } + public function setApproveId($approveId) + { + $this->approveId = $approveId; + } + public function getApproveId() + { + return $this->approveId; + } + public static function is_as_request() : bool { $default_accept_header = 'application/activity+json, application/x-zot-activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; diff --git a/Code/Lib/Libzot.php b/Code/Lib/Libzot.php index b9b8249f5..a463f1cd3 100644 --- a/Code/Lib/Libzot.php +++ b/Code/Lib/Libzot.php @@ -1222,6 +1222,7 @@ class Libzot $isCollectionOperation = true; $rawActivity = json_decode($AS->raw, true); $AS = new ActivityStreams($rawActivity['object'], portable_id: $env['sender']); + $AS->setApproveId($rawActivity['id']); } } if (!$AS->valid) { @@ -2217,6 +2218,7 @@ class Libzot $isCollectionOperation = true; $rawActivity = json_decode($AS->raw, true); $AS = new ActivityStreams($rawActivity['object'], null, true); + $AS->setApproveId($rawActivity['id']); } if (!$AS->is_valid()) { diff --git a/Code/Module/Inbox.php b/Code/Module/Inbox.php index d33df5fa8..a37dc684d 100644 --- a/Code/Module/Inbox.php +++ b/Code/Module/Inbox.php @@ -95,7 +95,10 @@ class Inbox extends Controller && !empty($AS->tgt)) { logger('relayed collection operation', LOGGER_DEBUG); $isCollectionOperation = true; + $approveId = $AS->id; $AS = new ActivityStreams($AS->obj, portable_id: $hsig['portable_id']); + // preserve a link to the unwrapped activity + $AS->setApproveId($approveId); } diff --git a/Code/Module/Outbox.php b/Code/Module/Outbox.php index d53de5b03..384f0b893 100644 --- a/Code/Module/Outbox.php +++ b/Code/Module/Outbox.php @@ -387,6 +387,7 @@ class Outbox extends Controller return true; } } + // @fixme for conversation collections - see inbox implementation if (in_array($AS->type, ['Add', 'Remove'])) { // for writeable collections as target, it's best to provide an array and include both the type and the id in the target element. // If it's just a string id, we'll try to fetch the collection when we receive it and that's wasteful since we don't actually need diff --git a/boot.php b/boot.php index 930b773c7..91dcc3ee6 100755 --- a/boot.php +++ b/boot.php @@ -29,7 +29,7 @@ const REPOSITORY_ID = 'streams'; const DB_UPDATE_VERSION = 1276; const PROJECT_BASE = __DIR__; const ACTIVITYPUB_ENABLED = true; -const NOMAD_PROTOCOL_VERSION = '13.0'; +const NOMAD_PROTOCOL_VERSION = '13.3'; // composer autoloader for all namespaced Classes require_once('vendor/autoload.php');