]> git.mxchange.org Git - friendica.git/commitdiff
Language check added
authorMichael <heluecht@pirati.ca>
Wed, 10 Jan 2024 10:55:18 +0000 (10:55 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 28 Jan 2024 15:37:43 +0000 (16:37 +0100)
src/Content/Conversation/Repository/UserDefinedChannel.php

index e03b28ee89989ee6ea67a84460e63552ad5cb81f..e7b32255feea16fce10c5abd67576656aa77d33a 100644 (file)
@@ -151,7 +151,8 @@ class UserDefinedChannel extends \Friendica\BaseRepository
 
        /**
         * Checks, if one of the user defined channels matches with the given search text
-        * @todo To increase the performance, this functionality should be replaced with a single SQL call.
+        * @todo Combine all the full text statements in a single search text to improve the performance.
+        * Add a "valid" field for the channel that is set when the full text statement doesn't contain errors.
         *
         * @param string $searchtext
         * @param string $language
@@ -166,7 +167,18 @@ class UserDefinedChannel extends \Friendica\BaseRepository
                        return [];
                }
 
-               return !empty($this->getMatches($searchtext, $language, $tags, $media_type, 0, 0, array_column($users, 'uid'), false));
+               $uids = array_column($users, 'uid');
+
+               $condition = ['uid' => $uids];
+               $condition = DBA::mergeConditions($condition, ["`languages` != ? AND `include-tags` = ? AND `full-text-search` = ? AND circle = ?", '', '', '', 0]);
+
+               foreach ($this->select($condition) as $channel) {
+                       if (!empty($channel->languages) && in_array($language, $channel->languages)) {
+                               return true;
+                       }
+               }
+
+               return !empty($this->getMatches($searchtext, $language, $tags, $media_type, 0, 0, $uids, false));
        }
 
        /**