]> git.mxchange.org Git - friendica.git/commitdiff
Compare with lowered tags
authorMichael <heluecht@pirati.ca>
Tue, 9 Jan 2024 06:40:07 +0000 (06:40 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 28 Jan 2024 15:37:43 +0000 (16:37 +0100)
src/Content/Conversation/Repository/UserDefinedChannel.php
src/Model/Item.php
src/Model/Post/Engagement.php

index eb39abefb6c4de1d053bf3df1026708bc1952fa3..f0a0f3efe88fa808c7dbf4a10d49c155f45fe432 100644 (file)
@@ -197,6 +197,10 @@ class UserDefinedChannel extends \Friendica\BaseRepository
                        return [];
                }
 
+               array_walk($tags, function (&$value) {
+                       $value = mb_strtolower($value);
+               });
+
                $this->db->insert('check-full-text-search', ['pid' => getmypid(), 'searchtext' => $searchtext], Database::INSERT_UPDATE);
 
                $uids = [];
index d49d6e2390d71f6dbf87b0842f3c7b2efe0ad4e3..a9361f0fbb0dcd167ad7b0c6bcb970eff6e7a22f 100644 (file)
@@ -1458,25 +1458,34 @@ class Item
 
                $item = Post::selectFirst(['id', 'private', 'network', 'language', 'owner-id'], ['uri-id' => $uri_id, 'uid' => 0]);
                if (empty($item['id'])) {
+                       Logger::debug('Post not found', ['uri-id' => $uri_id]);
                        return;
                }
 
                if (($item['private'] != self::PUBLIC) || !in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) {
+                       Logger::debug('Not a public post or no AP or DFRN post', ['uri-id' => $uri_id]);
                        return;
                }
 
                $engagement = DBA::selectFirst('post-engagement', ['searchtext', 'media-type'], ['uri-id' => $uri_id]);
                if (empty($engagement['searchtext'])) {
+                       Logger::debug('No engagement found', ['uri-id' => $uri_id]);
                        return;
                }
 
                $language = !empty($item['language']) ? array_key_first(json_decode($item['language'], true)) : '';
                $tags     = array_column(Tag::getByURIId($uri_id, [Tag::HASHTAG]), 'name');
 
+               Logger::debug('Prepare check', ['uri-id' => $uri_id, 'language' => $language, 'tags' => $tags, 'searchtext' => $engagement['searchtext'], 'media_type' => $engagement['media-type'], 'owner' => $item['owner-id']]);
+
+               $count = 0;
                foreach (DI::userDefinedChannel()->getMatchingChannelUsers($engagement['searchtext'], $language, $tags, $engagement['media-type'], $item['owner-id']) as $uid) {
-                       Logger::debug('Reshare post', ['uid' => $uid, 'uri-id' => $uri_id, 'language' => $language, 'tags' => $tags, 'searchtext' => $engagement['searchtext'], 'media_type' => $engagement['media-type']]);
+                       Logger::debug('Reshare post', ['uid' => $uid, 'uri-id' => $uri_id]);
                        self::performActivity($item['id'], 'announce', $uid);
+                       $count++;
                }
+
+               Logger::debug('Check done', ['uri-id' => $uri_id, 'count' => $count]);
        }
 
        /**
index 4070112752128e611111aef6fe6975670fffaa42..0476e08ca21eb073310a9cab51881894e894f9e7 100644 (file)
@@ -69,10 +69,14 @@ class Engagement
                        $store = Contact::hasFollowers($parent['owner-id']);
                }
 
+               if (!$store && ($parent['owner-id'] != $parent['author-id'])) {
+                       $store = Contact::hasFollowers($parent['author-id']);
+               }
+
                if (!$store) {
                        $tagList = Relay::getSubscribedTags();
                        foreach (array_column(Tag::getByURIId($item['parent-uri-id'], [Tag::HASHTAG]), 'name') as $tag) {
-                               if (in_array($tag, $tagList)) {
+                               if (in_array(mb_strtolower($tag), $tagList)) {
                                        $store = true;
                                        break;
                                }
@@ -120,7 +124,7 @@ class Engagement
                        $ret = DBA::insert('post-engagement', $engagement);
                        Logger::debug('Engagement inserted', ['uri-id' => $engagement['uri-id'], 'ret' => $ret]);
                }
-               return ($ret || !$exists) ? $engagement['uri-id'] : 0;
+               return ($ret && !$exists) ? $engagement['uri-id'] : 0;
        }
 
        public static function getSearchTextForActivity(string $content, int $author_id, array $tags, array $receivers): string