Merge pull request #15545 from nextcloud/bugfix/noid/empty-chat-for-guests

fix(chat): Fix guests in a fully empty chat
This commit is contained in:
Joas Schilling
2025-07-18 16:58:29 +02:00
committed by GitHub
2 changed files with 13 additions and 3 deletions

View File

@ -811,9 +811,14 @@ class ChatController extends AEnvironmentAwareOCSController {
}
$currentUser = $this->userManager->get($this->userId);
$commentsHistory = $this->chatManager->getHistory($this->room, $messageId, $limit, true, $threadId);
$commentsHistory = array_reverse($commentsHistory);
$commentsFuture = $this->chatManager->waitForNewMessages($this->room, $messageId, $limit, 0, $currentUser, false);
if ($messageId === 0) {
// Guest in a fully expired chat, no history, just loading the chat from beginning for now
$commentsHistory = $commentsFuture = [];
} else {
$commentsHistory = $this->chatManager->getHistory($this->room, $messageId, $limit, true, $threadId);
$commentsHistory = array_reverse($commentsHistory);
$commentsFuture = $this->chatManager->waitForNewMessages($this->room, $messageId, $limit, 0, $currentUser, false);
}
return $this->prepareCommentsAsDataResponse(array_merge($commentsHistory, $commentsFuture));
}

View File

@ -418,6 +418,11 @@ class RoomFormatter {
}
}
if ($roomData['lastReadMessage'] === 0) {
// Guest in a fully expired chat, no history, just loading the chat from beginning for now
$roomData['lastReadMessage'] = ChatManager::UNREAD_FIRST_MESSAGE;
}
if ($currentUser instanceof IUser
&& $attendee->getActorType() === Attendee::ACTOR_USERS
&& $roomData['lastReadMessage'] === ChatManager::UNREAD_FIRST_MESSAGE