mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:55:19 +00:00
collections - testing activitypub cont.
This commit is contained in:
parent
e60ee35905
commit
69411bab64
1 changed files with 21 additions and 6 deletions
|
@ -3897,6 +3897,7 @@ class Activity
|
|||
}
|
||||
|
||||
$allowed = false;
|
||||
$relay = false;
|
||||
$reason = ['init'];
|
||||
$isMail = (bool) (intval($item['item_private']) === 2);
|
||||
if ($is_child_node) {
|
||||
|
@ -3923,6 +3924,8 @@ class Activity
|
|||
if ($parent_item && $parent_item['item_wall']) {
|
||||
// set the owner to the owner of the parent
|
||||
$item['owner_xchan'] = $parent_item['owner_xchan'];
|
||||
// This check may be redundant at this point.
|
||||
$relay = $channel['channel_hash'] === $item['owner_xchan'];
|
||||
|
||||
if ($parent_item['obj_type'] === 'Question') {
|
||||
if ($item['obj_type'] === 'Note' && $item['title'] && (!$item['content'])) {
|
||||
|
@ -4025,9 +4028,7 @@ class Activity
|
|||
}
|
||||
}
|
||||
|
||||
$relay = $channel['channel_hash'] === $item['owner_xchan'];
|
||||
|
||||
if (str_contains($item['tgt_type'], 'Collection') && !$relay && !$isCollectionOperation) {
|
||||
if ($parent_item && str_contains($parent_item['tgt_type'], 'Collection') && !$relay && !$isCollectionOperation) {
|
||||
logger('not a collection activity');
|
||||
return;
|
||||
}
|
||||
|
@ -4386,12 +4387,14 @@ class Activity
|
|||
{
|
||||
logger('fetching parents');
|
||||
|
||||
|
||||
$conversation = [];
|
||||
$seen_mids = [];
|
||||
|
||||
$current_item = $item;
|
||||
|
||||
while ($current_item['parent_mid'] !== $current_item['mid']) {
|
||||
$isCollectionOperation = false;
|
||||
// recursion breaker
|
||||
if (in_array($current_item['parent_mid'], $seen_mids)) {
|
||||
break;
|
||||
|
@ -4410,7 +4413,19 @@ class Activity
|
|||
// This is a relayed/forwarded Activity (as opposed to a shared/boosted object)
|
||||
// Reparse the encapsulated Activity and use that instead
|
||||
logger('relayed activity', LOGGER_DEBUG);
|
||||
$activity = new ActivityStreams($activity->obj, null, true);
|
||||
$rawActivity = json_decode($activity->raw, true);
|
||||
$activity = new ActivityStreams($rawActivity['object'], null, true);
|
||||
}
|
||||
|
||||
if (in_array($activity->type, ['Add', 'Remove'])
|
||||
&& is_array($activity->obj)
|
||||
&& array_key_exists('object', $activity->obj)
|
||||
&& array_key_exists('actor', $activity->obj)
|
||||
&& !empty($activity->tgt)) {
|
||||
logger('relayed collection operation', LOGGER_DEBUG);
|
||||
$isCollectionOperation = true;
|
||||
$rawActivity = json_decode($activity->raw, true);
|
||||
$activity = new ActivityStreams($rawActivity['object'], portable_id: $env['sender']);
|
||||
}
|
||||
|
||||
logger($activity->debug(), LOGGER_DATA);
|
||||
|
@ -4465,7 +4480,7 @@ class Activity
|
|||
if ($conversation && $conversation[0]['item']['mid'] === $conversation[0]['item']['parent_mid']) {
|
||||
foreach ($conversation as $post) {
|
||||
if ($post['activity']->is_valid()) {
|
||||
self::store($channel, $observer_hash, $post['activity'], $post['item'], false);
|
||||
self::store($channel, $observer_hash, $post['activity'], $post['item'], false, isCollectionOperation: $isCollectionOperation);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue