diff options
author | Joas Schilling <coding@schilljs.com> | 2024-10-17 12:34:18 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-10-18 06:21:01 +0000 |
commit | bd30a7ac21bf63cfc117f1fe7798d82978a879ee (patch) | |
tree | 8c9fe1f4b2e4388b9641ef3e914046a8324d7227 /lib/private/Comments | |
parent | 324451cbac6efbd78dbfd5f979a264ffbf36af6a (diff) | |
download | nextcloud-server-bd30a7ac21bf63cfc117f1fe7798d82978a879ee.tar.gz nextcloud-server-bd30a7ac21bf63cfc117f1fe7798d82978a879ee.zip |
feat(comments): Support mentioning emails
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r-- | lib/private/Comments/Comment.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php index 1090cf67078..11b7fb03dc1 100644 --- a/lib/private/Comments/Comment.php +++ b/lib/private/Comments/Comment.php @@ -202,7 +202,7 @@ class Comment implements IComment { * */ public function getMentions(): array { - $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"guest\/[a-f0-9]+\"|\"(?:federated_)?(?:group|team|user){1}\/[a-z0-9_\-@\.\' \/:]+\"|\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions); + $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"(guest|email)\/[a-f0-9]+\"|\"(?:federated_)?(?:group|team|user){1}\/[a-z0-9_\-@\.\' \/:]+\"|\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions); if (!$ok || !isset($mentions[0])) { return []; } @@ -217,6 +217,10 @@ class Comment implements IComment { if (str_starts_with($cleanId, 'guest/')) { $result[] = ['type' => 'guest', 'id' => $cleanId]; + } elseif (str_starts_with($cleanId, 'email/')) { + /** @var non-empty-lowercase-string $cleanId */ + $cleanId = substr($cleanId, 6); + $result[] = ['type' => 'email', 'id' => $cleanId]; } elseif (str_starts_with($cleanId, 'federated_group/')) { $result[] = ['type' => 'federated_group', 'id' => substr($cleanId, 16)]; } elseif (str_starts_with($cleanId, 'group/')) { |