diff --git a/lib/Signaling/Listener.php b/lib/Signaling/Listener.php index 898522217b3..f4f552eee61 100644 --- a/lib/Signaling/Listener.php +++ b/lib/Signaling/Listener.php @@ -530,6 +530,7 @@ protected function notifyMessageSent(AMessageSentEvent $event): void { $thread = null; } $data['chat']['comment'] = $message->toArray('json', $thread); + $data['chat']['comment']['lastCommonRead'] = $this->participantService->getLastCommonReadChatMessage($room); $parent = $event->getParent(); if ($parent !== null) { @@ -593,6 +594,7 @@ protected function notifySystemMessageSent(ASystemMessageSentEvent $event): void } $data['chat']['comment'] = $message->toArray('json', $thread); + $data['chat']['comment']['lastCommonRead'] = $this->participantService->getLastCommonReadChatMessage($room); if ($messageType === 'call_started') { $metaData = $comment->getMetaData() ?? []; @@ -701,6 +703,7 @@ protected function notifyReactionSent(AReactionEvent $event): void { 'markdown' => false , 'expirationTimestamp' => $message->getExpirationDateTime()?->getTimestamp() ?? 0, 'threadId' => $threadId, + 'lastCommonRead' => $this->participantService->getLastCommonReadChatMessage($room), ]; $data['chat']['comment']['parent'] = $message->toArray('json', $thread); diff --git a/tests/php/Signaling/ListenerTest.php b/tests/php/Signaling/ListenerTest.php index 03255ced205..89e0f2e98c5 100644 --- a/tests/php/Signaling/ListenerTest.php +++ b/tests/php/Signaling/ListenerTest.php @@ -290,7 +290,9 @@ public function testChatMessageSentEvent(): void { $comment->method('getId')->willReturn(1); $message = $this->createConfiguredMock(Message::class, [ 'getVisibility' => true, - 'toArray' => [], + 'toArray' => [ + 'id' => 123, + ], 'getMessageId' => 123, ]); $l10n = $this->createStub(IL10N::class); @@ -317,7 +319,10 @@ public function testChatMessageSentEvent(): void { 'type' => 'chat', 'chat' => [ 'refresh' => true, - 'comment' => [], + 'comment' => [ + 'id' => 123, + 'lastCommonRead' => 0, + ], ], ]); @@ -333,7 +338,9 @@ public function testChatMessageSentWithThreadEvent(): void { $comment->method('getId')->willReturn(1); $message = $this->createConfiguredMock(Message::class, [ 'getVisibility' => true, - 'toArray' => [], + 'toArray' => [ + 'id' => 123, + ], 'getMessageId' => 123, ]); @@ -365,7 +372,10 @@ public function testChatMessageSentWithThreadEvent(): void { 'type' => 'chat', 'chat' => [ 'refresh' => true, - 'comment' => [], + 'comment' => [ + 'id' => 123, + 'lastCommonRead' => 0, + ], ], ]);