Code clean up

This commit is contained in:
Michael 2024-01-10 21:51:34 +00:00
parent dfce85a09f
commit 61555657c3

View file

@ -217,11 +217,7 @@ class UserDefinedChannel extends \Friendica\BaseRepository
if (empty($users)) { if (empty($users)) {
return []; return [];
} }
return $this->getMatches($searchtext, $language, $tags, $media_type, $owner_id, $reshare_id, array_column($users, 'uid'), true);
}
private function getMatches(string $searchtext, string $language, array $tags, int $media_type, int $owner_id, int $reshare_id, array $channelUids, bool $relayMode): array
{
if (!in_array($language, User::getLanguages())) { if (!in_array($language, User::getLanguages())) {
$this->logger->debug('Unwanted language found. No matched channel found.', ['language' => $language, 'searchtext' => $searchtext]); $this->logger->debug('Unwanted language found. No matched channel found.', ['language' => $language, 'searchtext' => $searchtext]);
return []; return [];
@ -231,14 +227,7 @@ class UserDefinedChannel extends \Friendica\BaseRepository
$uids = []; $uids = [];
$condition = ['uid' => $channelUids, 'valid' => true]; foreach ($this->select(['uid' => array_column($users, 'uid'), 'publish' => true, 'valid' => true]) as $channel) {
if (!$relayMode) {
$condition = DBA::mergeConditions($condition, ["`full-text-search` != ?", '']);
} else {
$condition = DBA::mergeConditions($condition, ['publish' => true]);
}
foreach ($this->select($condition) as $channel) {
if (in_array($channel->uid, $uids)) { if (in_array($channel->uid, $uids)) {
continue; continue;
} }
@ -276,9 +265,6 @@ class UserDefinedChannel extends \Friendica\BaseRepository
} }
$uids[] = $channel->uid; $uids[] = $channel->uid;
$this->logger->debug('Matching channel found.', ['uid' => $channel->uid, 'label' => $channel->label, 'language' => $language, 'tags' => $tags, 'media_type' => $media_type, 'searchtext' => $searchtext]); $this->logger->debug('Matching channel found.', ['uid' => $channel->uid, 'label' => $channel->label, 'language' => $language, 'tags' => $tags, 'media_type' => $media_type, 'searchtext' => $searchtext]);
if (!$relayMode) {
return $uids;
}
} }
$this->db->delete('check-full-text-search', ['pid' => getmypid()]); $this->db->delete('check-full-text-search', ['pid' => getmypid()]);