Allow guest mentions of talk to be parsed

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-07-10 15:33:10 +02:00
parent ad51857e54
commit 77918356d6
No known key found for this signature in database
GPG key ID: 7076EA9751AACDDA

View 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;
}