From b710c9127aa63a09a002b7aa0ea68fe563859507 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 10 Sep 2023 09:04:58 +1000 Subject: [PATCH] support pixelfed Story activities --- Code/Lib/Activity.php | 13 ++++++++++--- FEDERATION.md | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index 4443d1952..ef5a2b27f 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -1360,7 +1360,7 @@ class Activity } - if ($activitypub && $has_images && $activity['type'] === 'Note') { + if ($activitypub && $has_images && in_array($activity['type'], ['Note', 'Story']) { foreach ($images as $match) { $img = []; // handle Friendica/Hubzilla style img links with [img=$url]$alttext[/img] @@ -2976,6 +2976,13 @@ class Activity } elseif ($act->objprop('expires')) { $item['expires'] = datetime_convert('UTC', 'UTC', $act->obj['expires']); } + // pixelfed stories + if (array_key_exists('expiresAt', $act->data) && $act->data['expiresAt']) { + $item['expires'] = datetime_convert('UTC', 'UTC', $act->data['expiresAt']); + } elseif ($act->objprop('expiresAt')) { + $item['expires'] = datetime_convert('UTC', 'UTC', $act->obj['expiresAt']); + } + if ($item['expires'] > NULL_DATE && $item['expires'] < datetime_convert()) { // We shouldn't even be seeing this activity. return false; @@ -3332,7 +3339,7 @@ class Activity // Objects that might have media attachments which aren't already provided in the content element. // We'll check specific media objects separately. - if (in_array($act->objprop('type',''), ['Article', 'Document', 'Event', 'Note', 'Page', 'Place', 'Question']) + if (in_array($act->objprop('type',''), ['Article', 'Document', 'Event', 'Note', 'Story', 'Page', 'Place', 'Question']) && isset($item['attach']) && $item['attach']) { $item = self::bb_attach($item); } @@ -3523,7 +3530,7 @@ class Activity } - if (in_array($act->objprop('type'), ['Note', 'Article', 'Page'])) { + if (in_array($act->objprop('type'), ['Note', 'Story', 'Article', 'Page'])) { $ptr = null; if (array_key_exists('url', $act->obj)) { diff --git a/FEDERATION.md b/FEDERATION.md index 0c5af381c..6e0ea1de7 100644 --- a/FEDERATION.md +++ b/FEDERATION.md @@ -1,7 +1,7 @@ Federation ========== -The ActivityPub implementation in this project strives to be compliant to the core spec where possible, while offering a range of services and features which normally aren't provided by ActivityPub projects. +The ActivityPub implementation in this software strives to be compliant to the core spec where possible, while offering a range of services and features which normally aren't provided by ActivityPub projects. Supported activities: