Allow guest mentions of talk to be parsed
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
ad51857e54
commit
77918356d6
|
@ -226,14 +226,19 @@ class Comment implements IComment {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getMentions() {
|
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])) {
|
if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$uids = array_unique($mentions[0]);
|
$uids = array_unique($mentions[0]);
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($uids as $uid) {
|
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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue