Merge pull request #6839 from MrPetovan/bug/6829-fix-implicit-mention-regex

Fix implicit mention regex
This commit is contained in:
Philipp 2019-03-09 15:49:43 +01:00 committed by GitHub
commit 792a0f11c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -710,7 +710,7 @@ class Processor
$kept_mentions = []; $kept_mentions = [];
// Extract one prepended mention at a time from the body // Extract one prepended mention at a time from the body
while(preg_match('#^(@\[url=([^\]]+)].*?\[\/url]\s)(.*)#mis', $body, $matches)) { while(preg_match('#^(@\[url=([^\]]+)].*?\[\/url]\s)(.*)#is', $body, $matches)) {
if (!in_array($matches[2], $potential_mentions) ) { if (!in_array($matches[2], $potential_mentions) ) {
$kept_mentions[] = $matches[1]; $kept_mentions[] = $matches[1];
} }
@ -743,30 +743,4 @@ class Processor
return $activity_tags; return $activity_tags;
} }
public static function testImplicitMentions($item, $source)
{
$parent = Item::selectFirst(['id', 'guid', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
$implicit_mentions = self::getImplicitMentionList($parent);
var_dump($implicit_mentions);
$object = json_decode($source, true)['object'];
var_dump($object);
$content = HTML::toBBCode($object['content']);
$content = self::convertMentions($content);
$activity = [
'tags' => $object['tag'],
'content' => $content
];
var_dump($activity);
$activity['content'] = Processor::removeImplicitMentionsFromBody($activity['content'], $implicit_mentions);
$activity['tags'] = Processor::convertImplicitMentionsInTags($activity['tags'], $implicit_mentions);
return $activity;
}
} }