From: Michael Date: Sat, 6 Jan 2024 17:27:42 +0000 (+0000) Subject: New user account type "Channel Relay" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3cb10f036c309a2c12ba7cca1f0d34bd70ce488d;p=friendica.git New user account type "Channel Relay" --- diff --git a/src/Content/Conversation/Repository/UserDefinedChannel.php b/src/Content/Conversation/Repository/UserDefinedChannel.php index b256e34e56..d78d1cc1a0 100644 --- a/src/Content/Conversation/Repository/UserDefinedChannel.php +++ b/src/Content/Conversation/Repository/UserDefinedChannel.php @@ -156,6 +156,8 @@ class UserDefinedChannel extends BaseRepository * * @param string $haystack * @param string $language + * @param array $tags + * @param int $media_type * @return boolean * @throws \Exception */ @@ -174,6 +176,59 @@ class UserDefinedChannel extends BaseRepository if (!empty($channel->languages) && in_array($language, $channel->languages)) { return true; } + if (!empty($channel->languages) && !in_array($channel->uid, $uids)) { + if (!in_array($language, $channel->languages)) { + continue; + } + } elseif (!in_array($language, User::getWantedLanguages($channel->uid))) { + continue; + } + if (!empty($channel->includeTags) && !in_array($channel->uid, $uids)) { + if (empty($tags)) { + continue; + } + $match = false; + foreach (explode(',', $channel->includeTags) as $tag) { + if (in_array($tag, $tags)) { + $match = true; + break; + } + } + if (!$match) { + continue; + } + } + if (!empty($tags) && !empty($channel->excludeTags) && !in_array($channel->uid, $uids)) { + $match = false; + foreach (explode(',', $channel->excludeTags) as $tag) { + if (in_array($tag, $tags)) { + $match = true; + break; + } + } + if ($match) { + continue; + } + } + if (!empty($channel->mediaType) && !in_array($channel->uid, $uids)) { + if (!($channel->mediaType & $media_type)) { + continue; + } + } + if (!empty($channel->fullTextSearch) && !in_array($channel->uid, $uids)) { + $channelsearchtext = $channel->fullTextSearch; + foreach (Engagement::KEYWORDS as $keyword) { + $channelsearchtext = preg_replace('~(' . $keyword . ':.[\w@\.-]+)~', '"$1"', $channelsearchtext); + } + if (!$this->db->exists('check-full-text-search', ["`pid` = ? AND MATCH (`searchtext`) AGAINST (? IN BOOLEAN MODE)", getmypid(), $channelsearchtext])) { + continue; + } + } + $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]); + if (!$relayMode) { + return $uids; + } } $search = ''; diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index b96486ef3a..d977f93f5a 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -2038,7 +2038,7 @@ class Processor $searchtext = Engagement::getSearchTextForActivity($content, $authorid, $messageTags, $receivers); $languages = Item::getLanguageArray($content, 1, 0, $authorid); $language = !empty($languages) ? array_key_first($languages) : ''; - return DI::userDefinedChannel()->match($searchtext, $language); + return DI::userDefinedChannel()->match($searchtext, $language, $messageTags, 0); } /**