Skip to content

Commit 4016b7e

Browse files
Merge pull request #18487 from nextcloud/backport/18433/stable34
[stable34] feat: Add last-common-read to chat relay
2 parents 88da8cb + 7d9d6e1 commit 4016b7e

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

lib/Signaling/Listener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ protected function notifyMessageSent(AMessageSentEvent $event): void {
530530
$thread = null;
531531
}
532532
$data['chat']['comment'] = $message->toArray('json', $thread);
533+
$data['chat']['comment']['lastCommonRead'] = $this->participantService->getLastCommonReadChatMessage($room);
533534

534535
$parent = $event->getParent();
535536
if ($parent !== null) {
@@ -593,6 +594,7 @@ protected function notifySystemMessageSent(ASystemMessageSentEvent $event): void
593594
}
594595

595596
$data['chat']['comment'] = $message->toArray('json', $thread);
597+
$data['chat']['comment']['lastCommonRead'] = $this->participantService->getLastCommonReadChatMessage($room);
596598

597599
if ($messageType === 'call_started') {
598600
$metaData = $comment->getMetaData() ?? [];
@@ -701,6 +703,7 @@ protected function notifyReactionSent(AReactionEvent $event): void {
701703
'markdown' => false ,
702704
'expirationTimestamp' => $message->getExpirationDateTime()?->getTimestamp() ?? 0,
703705
'threadId' => $threadId,
706+
'lastCommonRead' => $this->participantService->getLastCommonReadChatMessage($room),
704707
];
705708

706709
$data['chat']['comment']['parent'] = $message->toArray('json', $thread);

tests/php/Signaling/ListenerTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ public function testChatMessageSentEvent(): void {
290290
$comment->method('getId')->willReturn(1);
291291
$message = $this->createConfiguredMock(Message::class, [
292292
'getVisibility' => true,
293-
'toArray' => [],
293+
'toArray' => [
294+
'id' => 123,
295+
],
294296
'getMessageId' => 123,
295297
]);
296298
$l10n = $this->createMock(IL10N::class);
@@ -317,7 +319,10 @@ public function testChatMessageSentEvent(): void {
317319
'type' => 'chat',
318320
'chat' => [
319321
'refresh' => true,
320-
'comment' => [],
322+
'comment' => [
323+
'id' => 123,
324+
'lastCommonRead' => 0,
325+
],
321326
],
322327
]);
323328

@@ -333,7 +338,9 @@ public function testChatMessageSentWithThreadEvent(): void {
333338
$comment->method('getId')->willReturn(1);
334339
$message = $this->createConfiguredMock(Message::class, [
335340
'getVisibility' => true,
336-
'toArray' => [],
341+
'toArray' => [
342+
'id' => 123,
343+
],
337344
'getMessageId' => 123,
338345
]);
339346

@@ -365,7 +372,10 @@ public function testChatMessageSentWithThreadEvent(): void {
365372
'type' => 'chat',
366373
'chat' => [
367374
'refresh' => true,
368-
'comment' => [],
375+
'comment' => [
376+
'id' => 123,
377+
'lastCommonRead' => 0,
378+
],
369379
],
370380
]);
371381

0 commit comments

Comments
 (0)