preserve link to original add activity

This commit is contained in:
Mike Macgirvin 2024-03-07 08:28:50 +11:00
parent deb012a945
commit 2a874e0111
6 changed files with 18 additions and 1 deletions

View file

@ -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);

View file

@ -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"';

View file

@ -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()) {

View file

@ -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);
}

View file

@ -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

View file

@ -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');