Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix(Chat): consider shared objects when marking unread #13253

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/features/chat-4/unread-messages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Loading