mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
fix(pinned): Fix deleting the last pinned message
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
c125402702
commit
6616efa26a
2 changed files with 27 additions and 1 deletions
|
|
@ -645,12 +645,21 @@ class ChatManager {
|
|||
|
||||
$this->commentsManager->save($comment);
|
||||
|
||||
$this->attachmentService->deleteAttachmentByMessageId((int)$comment->getId());
|
||||
$messageId = (int)$comment->getId();
|
||||
$this->attachmentService->deleteAttachmentByMessageId($messageId);
|
||||
|
||||
$this->referenceManager->invalidateCache($chat->getToken());
|
||||
|
||||
$this->unreadCountCache->clear($chat->getId() . '-');
|
||||
|
||||
if ($chat->getLastPinnedId() === $messageId) {
|
||||
$pinnedMessages = $this->attachmentService->getAttachmentsByType($chat, Attachment::TYPE_PINNED, 0, 1);
|
||||
if (!empty($pinnedMessages)) {
|
||||
$pinnedMessage = array_shift($pinnedMessages);
|
||||
$this->roomService->setLastPinnedId($chat, $pinnedMessage->getMessageId());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addSystemMessage(
|
||||
$chat,
|
||||
$participant,
|
||||
|
|
|
|||
|
|
@ -89,3 +89,20 @@ Feature: chat-1/pinned-messages
|
|||
Then user "participant2" is participant of the following rooms (v4)
|
||||
| id | type | lastPinnedId | hiddenPinnedId |
|
||||
| room | 3 | EMPTY | EMPTY |
|
||||
|
||||
Scenario: Deleting last pinned message
|
||||
Given user "participant1" creates room "room" (v4)
|
||||
| roomType | 3 |
|
||||
| roomName | room |
|
||||
And user "participant1" adds user "participant2" to room "room" with 200 (v4)
|
||||
When user "participant1" sends message "Message 1" to room "room" with 201
|
||||
When user "participant1" pins message "Message 1" in room "room" with 200
|
||||
When user "participant1" sends message "Message 2" to room "room" with 201
|
||||
When user "participant1" pins message "Message 2" in room "room" with 200
|
||||
Then user "participant2" is participant of the following rooms (v4)
|
||||
| id | type | lastPinnedId | hiddenPinnedId |
|
||||
| room | 3 | Message 2 | EMPTY |
|
||||
When user "participant1" deletes message "Message 2" from room "room" with 200
|
||||
Then user "participant2" is participant of the following rooms (v4)
|
||||
| id | type | lastPinnedId | hiddenPinnedId |
|
||||
| room | 3 | Message 1 | EMPTY |
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue