Always mention the parent author

This commit is contained in:
Michael 2020-05-09 08:08:33 +00:00
parent bebc6615fc
commit 556cc3fb13
2 changed files with 8 additions and 25 deletions

View file

@ -379,10 +379,6 @@ function item_post(App $a) {
$tags = BBCode::getTags($body);
if ($thread_parent_uriid && !\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions')) {
$tags = item_add_implicit_mentions($tags, $thread_parent_contact, $thread_parent_uriid);
}
$tagged = [];
$private_forum = false;
@ -747,7 +743,10 @@ function item_post(App $a) {
}
Tag::storeFromBody($datarray['uri-id'], $datarray['body']);
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions')) {
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
}
// update filetags in pconfig
FileTag::updatePconfig($uid, $categories_old, $categories_new, 'category');
@ -1000,20 +999,3 @@ function handle_tag(&$body, &$inform, $profile_uid, $tag, $network = "")
return ['replaced' => $replaced, 'contact' => $contact];
}
function item_add_implicit_mentions(array $tags, array $thread_parent_contact, $thread_parent_uriid)
{
if (!DI::config()->get('system', 'disable_implicit_mentions')) {
return $tags;
}
// Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them)
if (in_array($thread_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) {
$contact = Tag::TAG_CHARACTER[Tag::MENTION] . '[url=' . $thread_parent_contact['url'] . ']' . $thread_parent_contact['nick'] . '[/url]';
if (!stripos(implode($tags), '[url=' . $thread_parent_contact['url'] . ']')) {
$tags[] = $contact;
}
}
return $tags;
}

View file

@ -333,6 +333,10 @@ class Tag
*/
public static function createImplicitMentions(int $uri_id, int $parent_uri_id)
{
// Always mention the direct parent author
$parent = Item::selectFirst(['author-link', 'author-name'], ['uri-id' => $parent_uri_id]);
self::store($uri_id, self::IMPLICIT_MENTION, $parent['author-name'], $parent['author-link']);
if (DI::config()->get('system', 'disable_implicit_mentions')) {
return;
}
@ -341,9 +345,6 @@ class Tag
while ($tag = DBA::fetch($tags)) {
self::store($uri_id, self::IMPLICIT_MENTION, $tag['name'], $tag['url']);
}
$parent = Item::selectFirst(['author-link', 'author-name'], ['uri-id' => $parent_uri_id]);
self::store($uri_id, self::IMPLICIT_MENTION, $parent['author-name'], $parent['author-link']);
}
/**