Skip to content
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
7 changes: 7 additions & 0 deletions lib/Chat/Parser/UserMention.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ protected function parseMessage(Message $chatMessage): void {

$mentionTypeCount = [];

// Set the current message as comment content, so that the message finds
// mentions which are now part of the message, but were not on the original
// comment, e.g. mentions at the beginning of captions
$originalCommentMessage = $comment->getMessage();
$comment->setMessage($message, ChatManager::MAX_CHAT_LENGTH + 10000);
$mentions = $comment->getMentions();
$comment->setMessage($originalCommentMessage, ChatManager::MAX_CHAT_LENGTH);

// TODO This can be removed once getMentions() returns sorted results (Nextcloud 21+)
usort($mentions, static function (array $m1, array $m2) {
return mb_strlen($m2['id']) <=> mb_strlen($m1['id']);
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/features/chat/file-share.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ Feature: chat/file-share
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| public room | users | participant1 | participant1-displayname | Hello {mention-user1} this is a caption for the attached document | "IGNORE" |

Scenario: Share a file with caption that only is a mention
Given user "participant1" creates room "public room" (v4)
| roomType | 3 |
| roomName | room |
When user "participant1" shares "welcome.txt" with room "public room"
| talkMetaData | {"caption":"@participant2"} |
Then user "participant1" sees the following messages in room "public room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| public room | users | participant1 | participant1-displayname | {mention-user1} | "IGNORE" |

Scenario: Can not share a file without chat permission
Given user "participant1" creates room "public room" (v4)
| roomType | 3 |
Expand Down