diff --git a/src/Module/Objects.php b/src/Module/Objects.php index 1658507d5..cbe2e53fe 100644 --- a/src/Module/Objects.php +++ b/src/Module/Objects.php @@ -103,6 +103,10 @@ class Objects extends BaseModule if (empty($parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) { $activity = ActivityPub\Transmitter::createActivityFromItem($item['id'], true); + if (empty($activity['type'])) { + throw new HTTPException\NotFoundException(); + } + $activity['type'] = $activity['type'] == 'Update' ? 'Create' : $activity['type']; // Only display "Create" activity objects here, no reshares or anything else diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 7f5f51c38..c1443bc33 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1003,10 +1003,10 @@ class Transmitter * @param integer $item_id * @param boolean $object_mode Is the activity item is used inside another object? * - * @return array of activity + * @return false|array * @throws \Exception */ - public static function createActivityFromItem($item_id, $object_mode = false) + public static function createActivityFromItem(int $item_id, bool $object_mode = false) { Logger::info('Fetching activity', ['item' => $item_id]); $item = Item::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);