- if (!empty($languages)) {
- if (in_array($languages[0], $config->get('system', 'relay_deny_languages'))) {
- Logger::info('Unwanted language found - rejected', ['language' => $languages[0], 'network' => $network, 'url' => $url]);
- return false;
+ Logger::info('No matching hashtags found - rejected', ['network' => $network, 'url' => $url, 'causer' => $causer, 'tags' => $tags]);
+ return false;
+ }
+
+ /**
+ * Get a list of subscribed tags by both the users and the tags that are defined by the admin
+ *
+ * @return array
+ */
+ public static function getSubscribedTags(): array
+ {
+ $systemTags = [];
+ $server_tags = DI::config()->get('system', 'relay_server_tags');
+
+ foreach (explode(',', mb_strtolower($server_tags)) as $tag) {
+ $systemTags[] = trim($tag, '# ');
+ }
+
+ if (DI::config()->get('system', 'relay_user_tags')) {
+ $userTags = Search::getUserTags();
+ } else {
+ $userTags = [];
+ }
+
+ return array_unique(array_merge($systemTags, $userTags));
+ }
+
+ /**
+ * Detect the language of a post and decide if the post should be accepted
+ *
+ * @param string $body
+ * @param int $uri_id
+ * @param int $author_id
+ * @param array $languages
+ * @return boolean
+ */
+ public static function isWantedLanguage(string $body, int $uri_id = 0, int $author_id = 0, array $languages = [])
+ {
+ $detected = [];
+ $quality = DI::config()->get('system', 'relay_language_quality');
+ foreach (Item::getLanguageArray($body, DI::config()->get('system', 'relay_languages'), $uri_id, $author_id) as $language => $reliability) {
+ if (($reliability >= $quality) && ($quality > 0)) {
+ $detected[] = $language;