Skip to content

Commit

Permalink
feat(federation): Store metadata and creation time in PCM
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Mar 5, 2024
1 parent 83a6eee commit 43f0b4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Federation/BackendNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ public function sendRoomModifiedUpdate(
* Send information to remote participants that a message was posted
* Sent from Host server to Remote participant server
*
* @param array{remoteMessageId: int, actorType: string, actorId: string, actorDisplayName: string, messageType: string, systemMessage: string, expirationDatetime: string, message: string, messageParameter: string, creationDatetime: string, metaData: string} $messageData
* @param array{unreadMessages: int, unreadMention: bool, unreadMentionDirect: bool} $unreadInfo
*/
public function sendMessageUpdate(
Expand Down
13 changes: 12 additions & 1 deletion lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCA\Talk\Federation\BackendNotifier;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Service\ParticipantService;
use OCP\Comments\IComment;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Federation\ICloudIdManager;
Expand Down Expand Up @@ -78,6 +79,14 @@ public function handle(Event $event): void {
}

$expireDate = $event->getComment()->getExpireDate();
$creationDate = $event->getComment()->getCreationDateTime();

$metaData = $event->getComment()->getMetaData() ?? [];
$parent = $event->getParent();
if ($parent instanceof IComment) {
$metaData['replyToActorType'] = $parent->getActorType();
$metaData['replyToActorId'] = $parent->getActorId();
}

$messageData = [
'remoteMessageId' => (int) $event->getComment()->getId(),
Expand All @@ -88,7 +97,9 @@ public function handle(Event $event): void {
'systemMessage' => $chatMessage->getMessageType() === ChatManager::VERB_SYSTEM ? $chatMessage->getMessageRaw() : '',
'expirationDatetime' => $expireDate ? $expireDate->format(\DateTime::ATOM) : '',
'message' => $chatMessage->getMessage(),
'messageParameter' => json_encode($chatMessage->getMessageParameters()),
'messageParameter' => json_encode($chatMessage->getMessageParameters(), JSON_THROW_ON_ERROR),
'creationDatetime' => $creationDate->format(\DateTime::ATOM),
'metaData' => json_encode($metaData, JSON_THROW_ON_ERROR),
];

$participants = $this->participantService->getParticipantsByActorType($event->getRoom(), Attendee::ACTOR_FEDERATED_USERS);
Expand Down

0 comments on commit 43f0b4c

Please sign in to comment.