diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 073ef0191..44ff7b503 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -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)); } diff --git a/lib/Service/RoomFormatter.php b/lib/Service/RoomFormatter.php index 839f583f1..ca9bf25af 100644 --- a/lib/Service/RoomFormatter.php +++ b/lib/Service/RoomFormatter.php @@ -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