diff --git a/src/Model/Event.php b/src/Model/Event.php index 924fc7eca..331a77e3f 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -337,12 +337,12 @@ class Event public static function getItemArrayForId(int $event_id, array $item = []):array { if (empty($event_id)) { - return []; + return $item; } $event = DBA::selectFirst('event', [], ['id' => $event_id]); if ($event['type'] != 'event') { - return []; + return $item; } if ($event['cid']) { @@ -375,7 +375,7 @@ class Event $item['allow_gid'] = $event['allow_gid']; $item['deny_cid'] = $event['deny_cid']; $item['deny_gid'] = $event['deny_gid']; - $item['private'] = intval($event['private'] ?? 0);; + $item['private'] = intval($event['private'] ?? 0); $item['visible'] = 1; $item['verb'] = Activity::POST; $item['object-type'] = Activity\ObjectType::EVENT; @@ -391,6 +391,30 @@ class Event return $item; } + public static function getItemArrayForImportedId(int $event_id, array $item = []):array + { + if (empty($event_id)) { + return $item; + } + + $event = DBA::selectFirst('event', [], ['id' => $event_id]); + if ($event['type'] != 'event') { + return $item; + } + + $item['post-type'] = Item::PT_EVENT; + $item['title'] = ''; + $item['object-type'] = Activity\ObjectType::EVENT; + $item['body'] = self::getBBCode($event); + $item['event-id'] = $event_id; + + $item['object'] = '' . XML::escape(Activity\ObjectType::EVENT) . '' . XML::escape($event['uri']) . ''; + $item['object'] .= '' . XML::escape(self::getBBCode($event)) . ''; + $item['object'] .= '' . "\n"; + + return $item; + } + /** * Create an array with translation strings used for events. * diff --git a/src/Model/Item.php b/src/Model/Item.php index 441808ea9..beb7db576 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1039,7 +1039,7 @@ class Item } $event_id = Event::store($ev); - $item = Event::getItemArrayForId($event_id, $item); + $item = Event::getItemArrayForImportedId($event_id, $item); Logger::info('Event was stored', ['id' => $event_id]); } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index d84453f73..496e73553 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -631,7 +631,7 @@ class Processor if (($item['gravity'] != GRAVITY_ACTIVITY) && ($activity['object_type'] == 'as:Event')) { $event_id = self::createEvent($activity, $item); - $item = Event::getItemArrayForId($event_id, $item); + $item = Event::getItemArrayForImportedId($event_id, $item); } $item_id = Item::insert($item); diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 3c28aca90..832e2bde2 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1978,7 +1978,7 @@ class DFRN $event_id = Event::store($ev); Logger::info('Event was stored', ['id' => $event_id]); - $item = Event::getItemArrayForId($event_id, $item); + $item = Event::getItemArrayForImportedId($event_id, $item); } } }