summaryrefslogtreecommitdiffstats
path: root/lib/Chat
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-11-03 06:29:08 +0100
committerJoas Schilling <coding@schilljs.com>2023-11-03 09:40:49 +0100
commit332eb377a55b3b60adfacbc8a347d9882253ead8 (patch)
treedc255adf5b5afd078da33e05021aec53b2e1d745 /lib/Chat
parentb52da475a83854d73b94579d0f6e739b0293446d (diff)
fix(chat): Fix mentions at the beginning of captions
Set the current message as comment content, so that the message finds mentions which are now part if the message but were not on the original comment, e.g. mentions at the beginning of captions Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Chat')
-rw-r--r--lib/Chat/Parser/UserMention.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Chat/Parser/UserMention.php b/lib/Chat/Parser/UserMention.php
index 377eb1aef..e5f17c4d4 100644
--- a/lib/Chat/Parser/UserMention.php
+++ b/lib/Chat/Parser/UserMention.php
@@ -94,7 +94,14 @@ class UserMention implements IEventListener {
$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']);