- $systemTags = [];
- $userTags = [];
-
- if ($scope == SR_SCOPE_TAGS) {
- $server_tags = $config->get('system', 'relay_server_tags', []);
- $tagitems = explode(',', mb_strtolower($server_tags));
-
- foreach ($tagitems AS $tag) {
- $systemTags[] = trim($tag, '# ');
- }
-
- if ($config->get('system', 'relay_user_tags')) {
- $userTags = Search::getUserTags();
- }
- }
-
- $content = mb_strtolower(JsonLD::fetchElement($activity['as:object'], 'as:content', '@value'));
-
- $tagList = array_unique(array_merge($systemTags, $userTags));
- foreach ($messageTags as $tag) {
- if (in_array($tag, $tagList)) {
- Logger::info('Subscribed hashtag found - accepted', ['id' => $id, 'hashtag' => $tag]);
- return true;
- }
- // We check with "strpos" for performance issues. Only when this is true, the regular expression check is used
- // RegExp is taken from here: https://medium.com/@shiba1014/regex-word-boundaries-with-unicode-207794f6e7ed
- if ((strpos($content, $tag) !== false) && preg_match('/(?<=[\s,.:;"\']|^)' . $tag . '(?=[\s,.:;"\']|$)/', $content)) {
- Logger::info('Subscribed hashtag found in content - accepted', ['id' => $id, 'hashtag' => $tag]);
- return true;
- }
- }
-
- Logger::info('No matching hashtags found - rejected', ['id' => $id]);
- return false;