aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2021-02-11 10:33:15 +0100
committerGitHub <noreply@github.com>2021-02-11 10:33:15 +0100
commitd5dea10517bbceaf141f56b6dde0efb55fc6f4b5 (patch)
tree925e74b2198c129aad4a5a2ea1ddd52feeb13335 /apps/comments
parent02885358a959ddafdc0f4dfa9e3ad3efa9fbc6b7 (diff)
parent98032425b4c57e1d39d46c23f02e7ac55d5badd1 (diff)
downloadnextcloud-server-d5dea10517bbceaf141f56b6dde0efb55fc6f4b5.tar.gz
nextcloud-server-d5dea10517bbceaf141f56b6dde0efb55fc6f4b5.zip
Merge pull request #25378 from nextcloud/bugfix/noid/mention-match-improvements
Improve mention matches
Diffstat (limited to 'apps/comments')
-rw-r--r--apps/comments/lib/Activity/Provider.php12
-rw-r--r--apps/comments/lib/Notification/Notifier.php6
2 files changed, 8 insertions, 10 deletions
diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php
index 527c9c4ca69..fca3b9e75d5 100644
--- a/apps/comments/lib/Activity/Provider.php
+++ b/apps/comments/lib/Activity/Provider.php
@@ -213,17 +213,11 @@ class Provider implements IProvider {
continue;
}
- $pattern = '/(^|\s)(' . '@' . $mention['id'] . ')(\b)/';
- if (strpos($mention['id'], ' ') !== false) {
- $pattern = '/(^|\s)(' . '@"' . $mention['id'] . '"' . ')(\b)?/';
+ $message = str_replace('@"' . $mention['id'] . '"', '{mention' . $mentionCount . '}', $message);
+ if (strpos($mention['id'], ' ') === false && strpos($mention['id'], 'guest/') !== 0) {
+ $message = str_replace('@' . $mention['id'], '{mention' . $mentionCount . '}', $message);
}
- $message = preg_replace(
- $pattern,
- //'${1}' . $this->regexSafeUser($mention['id'], $displayName) . '${3}',
- '${1}' . '{mention' . $mentionCount . '}' . '${3}',
- $message
- );
$mentions['mention' . $mentionCount] = $this->generateUserParameter($mention['id']);
$mentionCount++;
}
diff --git a/apps/comments/lib/Notification/Notifier.php b/apps/comments/lib/Notification/Notifier.php
index 9f69e5599f8..20e0667d143 100644
--- a/apps/comments/lib/Notification/Notifier.php
+++ b/apps/comments/lib/Notification/Notifier.php
@@ -195,7 +195,11 @@ class Notifier implements INotifier {
// could contain characters like '@' for user IDs) but a one-based
// index of the mentions of that type.
$mentionParameterId = 'mention-' . $mention['type'] . $mentionTypeCount[$mention['type']];
- $message = str_replace('@' . $mention['id'], '{' . $mentionParameterId . '}', $message);
+ $message = str_replace('@"' . $mention['id'] . '"', '{' . $mentionParameterId . '}', $message);
+ if (strpos($mention['id'], ' ') === false && strpos($mention['id'], 'guest/') !== 0) {
+ $message = str_replace('@' . $mention['id'], '{' . $mentionParameterId . '}', $message);
+ }
+
try {
$displayName = $this->commentsManager->resolveDisplayName($mention['type'], $mention['id']);
} catch (\OutOfBoundsException $e) {