From 556cc3fb13bf4ba8f597178e7bf7b55947323f94 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 9 May 2020 08:08:33 +0000 Subject: [PATCH] Always mention the parent author --- mod/item.php | 26 ++++---------------------- src/Model/Tag.php | 7 ++++--- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/mod/item.php b/mod/item.php index acce4ecee8..f074111442 100644 --- a/mod/item.php +++ b/mod/item.php @@ -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; -} diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 5a62aae91b..bbe516e49b 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -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']); } /** -- 2.39.5