summaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-10-08 13:23:18 +0200
committerJoas Schilling <coding@schilljs.com>2021-10-08 13:23:18 +0200
commit6536ff2cecb6f2864b3079a13f559f5164cc60fe (patch)
tree07be53e2d568cb4d6827edfa723c16acd98fd6ad /lib/private/Comments
parent1ea5983568dc99aa80e52f18837629d137b8a03c (diff)
downloadnextcloud-server-6536ff2cecb6f2864b3079a13f559f5164cc60fe.tar.gz
nextcloud-server-6536ff2cecb6f2864b3079a13f559f5164cc60fe.zip
Prepare for group mentions
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Comment.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php
index b15776312db..5cf04092101 100644
--- a/lib/private/Comments/Comment.php
+++ b/lib/private/Comments/Comment.php
@@ -227,21 +227,23 @@ class Comment implements IComment {
*
*/
public function getMentions() {
- $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"guest\/[a-f0-9]+\"|\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions);
+ $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"guest\/[a-f0-9]+\"|\"group\/[a-z0-9_\-@\.\' ]+\"|\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions);
if (!$ok || !isset($mentions[0]) || !is_array($mentions[0])) {
return [];
}
- $uids = array_unique($mentions[0]);
- usort($uids, static function ($uid1, $uid2) {
- return mb_strlen($uid2) <=> mb_strlen($uid1);
+ $mentionIds = array_unique($mentions[0]);
+ usort($mentionIds, static function ($mentionId1, $mentionId2) {
+ return mb_strlen($mentionId2) <=> mb_strlen($mentionId1);
});
$result = [];
- foreach ($uids as $uid) {
- $cleanUid = trim(substr($uid, 1), '"');
- if (strpos($cleanUid, 'guest/') === 0) {
- $result[] = ['type' => 'guest', 'id' => $cleanUid];
+ foreach ($mentionIds as $mentionId) {
+ $cleanId = trim(substr($mentionId, 1), '"');
+ if (strpos($cleanId, 'guest/') === 0) {
+ $result[] = ['type' => 'guest', 'id' => $cleanId];
+ } elseif (strpos($cleanId, 'group/') === 0) {
+ $result[] = ['type' => 'group', 'id' => substr($cleanId, 6)];
} else {
- $result[] = ['type' => 'user', 'id' => $cleanUid];
+ $result[] = ['type' => 'user', 'id' => $cleanId];
}
}
return $result;