Use channels for non public content

This commit is contained in:
Michael 2023-09-17 19:28:38 +00:00
parent a1f6e6e871
commit b00c2070d7
9 changed files with 67 additions and 58 deletions

View file

@ -86,24 +86,14 @@ class Relay
$body = ActivityPub\Processor::normalizeMentionLinks($body);
$systemTags = [];
$userTags = [];
$denyTags = [];
if ($scope == self::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();
}
$tagList = self::getSubscribedTags();
} else {
$tagList = [];
}
$tagList = array_unique(array_merge($systemTags, $userTags));
$deny_tags = $config->get('system', 'relay_deny_tags');
$tagitems = explode(',', mb_strtolower($deny_tags));
foreach ($tagitems as $tag) {
@ -149,6 +139,29 @@ class Relay
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
*