diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-10-13 10:15:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 10:15:39 +0200 |
commit | e9627861dde8a3800bd13a64fc8deb5cafaa386c (patch) | |
tree | 6ed6682e4c63874e1d4b55215a0f140053354981 /lib/private | |
parent | 5b7764354c71f79b83394796cb947fef92dfd830 (diff) | |
parent | 3487aeeb1f49b80ed6a9d1441e13c7511e2dc822 (diff) | |
download | nextcloud-server-e9627861dde8a3800bd13a64fc8deb5cafaa386c.tar.gz nextcloud-server-e9627861dde8a3800bd13a64fc8deb5cafaa386c.zip |
Merge pull request #29140 from nextcloud/feature/noid/prepare-for-group-mentions
Prepare for group mentions in talk (and comments?)
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Comments/Comment.php | 20 |
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; |