diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index 9843720dd65..d59075c6e17 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -705,7 +705,7 @@ public function getUnreadCount(Room $chat, int $lastReadMessage): int { $key = $chat->getId() . '-' . $lastReadMessage; $unreadCount = $this->unreadCountCache->get($key); if ($unreadCount === null) { - $unreadCount = $this->commentsManager->getNumberOfCommentsWithVerbsForObjectSinceComment('chat', (string)$chat->getId(), $lastReadMessage, [self::VERB_MESSAGE, 'object_shared']); + $unreadCount = $this->commentsManager->getNumberOfCommentsWithVerbsForObjectSinceComment('chat', (string)$chat->getId(), $lastReadMessage, [self::VERB_MESSAGE, self::VERB_OBJECT_SHARED]); $this->unreadCountCache->set($key, $unreadCount, 1800); } return $unreadCount; diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 2aa44cdccac..25489c9b648 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -1123,8 +1123,8 @@ public function markUnread(): DataResponse { $previousMessage = $this->chatManager->getPreviousMessageWithVerb( $this->room, (int)$message->getId(), - [ChatManager::VERB_MESSAGE], - $message->getVerb() === ChatManager::VERB_MESSAGE + [ChatManager::VERB_MESSAGE, ChatManager::VERB_OBJECT_SHARED], + $message->getVerb() === ChatManager::VERB_MESSAGE || $message->getVerb() === ChatManager::VERB_OBJECT_SHARED ); $unreadId = (int)$previousMessage->getId(); } catch (NotFoundException $e) { diff --git a/tests/integration/features/chat-4/unread-messages.feature b/tests/integration/features/chat-4/unread-messages.feature index ca91b95e474..ff068e93c08 100644 --- a/tests/integration/features/chat-4/unread-messages.feature +++ b/tests/integration/features/chat-4/unread-messages.feature @@ -202,3 +202,21 @@ Feature: chat-2/unread-messages Then user "participant2" is participant of room "group room" (v4) | unreadMessages | | 1 | + + Scenario: marking conversation as unread marks last message as unread considering shared file + Given user "participant1" creates room "group room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" sends message "Message 1" to room "group room" with 201 + And user "participant1" sends message "Message 2" to room "group room" with 201 + And user "participant1" shares "welcome.txt" with room "group room" + When user "participant1" marks room "group room" as unread with 200 + Then user "participant1" is participant of room "group room" (v4) + | unreadMessages | + | 1 | + When user "participant1" sends message "Message 3" to room "group room" with 201 + And user "participant1" marks room "group room" as unread with 200 + Then user "participant1" is participant of room "group room" (v4) + | unreadMessages | + | 1 | +