Use centralized functions for tag string handling

This commit is contained in:
Michael 2024-01-28 06:32:55 +00:00
parent 9e738253e7
commit d2702dfe9c
6 changed files with 46 additions and 44 deletions

View file

@ -97,20 +97,13 @@ class Relay
$body = ActivityPub\Processor::normalizeMentionLinks($body);
$denyTags = [];
if ($scope == self::SCOPE_TAGS) {
$tagList = self::getSubscribedTags();
} else {
$tagList = [];
}
$deny_tags = $config->get('system', 'relay_deny_tags');
$tagitems = explode(',', mb_strtolower($deny_tags));
foreach ($tagitems as $tag) {
$tag = trim($tag, '# ');
$denyTags[] = $tag;
}
$denyTags = Strings::getTagArrayByString($config->get('system', 'relay_deny_tags'));
if (!empty($tagList) || !empty($denyTags)) {
$content = mb_strtolower(BBCode::toPlaintext($body, false));
@ -168,10 +161,7 @@ class Relay
*/
public static function getSubscribedTags(): array
{
$tags = [];
foreach (explode(',', mb_strtolower(DI::config()->get('system', 'relay_server_tags'))) as $tag) {
$tags[] = trim($tag, '# ');
}
$tags = Strings::getTagArrayByString(DI::config()->get('system', 'relay_server_tags'));
if (DI::config()->get('system', 'relay_user_tags')) {
$tags = array_merge($tags, Search::getUserTags());