]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow guest mentions of talk to be parsed
authorJoas Schilling <coding@schilljs.com>
Wed, 10 Jul 2019 13:33:10 +0000 (15:33 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 10 Jul 2019 13:33:10 +0000 (15:33 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Comments/Comment.php

index c7cafa0524dc651f9095e4ec09ff03371f94b0a2..c9862c64ca6b25c1b272ed82b63bbc21509313f6 100644 (file)
@@ -226,14 +226,19 @@ class Comment implements IComment {
         *
         */
        public function getMentions() {
-               $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions);
+               $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"guest\/[a-f0-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]);
                $result = [];
                foreach ($uids as $uid) {
-                       $result[] = ['type' => 'user', 'id' => trim(substr($uid, 1), '"')];
+                       $cleanUid = trim(substr($uid, 1), '"');
+                       if (strpos($cleanUid, 'guest/') === 0) {
+                               $result[] = ['type' => 'guest', 'id' => $cleanUid];
+                       } else {
+                               $result[] = ['type' => 'user', 'id' => $cleanUid];
+                       }
                }
                return $result;
        }