]> git.mxchange.org Git - friendica.git/commitdiff
Always mention the parent author
authorMichael <heluecht@pirati.ca>
Sat, 9 May 2020 08:08:33 +0000 (08:08 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 9 May 2020 08:08:33 +0000 (08:08 +0000)
mod/item.php
src/Model/Tag.php

index acce4ecee89d7995773e06390dbfb0f29db3a12f..f074111442268420d50244f51d85546be221f06f 100644 (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;
-}
index 5a62aae91b5fd0b37989f33c78d05a73caedd011..bbe516e49b3105d3cdc96b5ad39057371d9aa2db 100644 (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']);
        }
 
        /**