New field "publish" for channels

This commit is contained in:
Michael 2024-01-07 18:36:47 +00:00
parent 08738e6551
commit c4b85ef25a
11 changed files with 162 additions and 122 deletions

View file

@ -110,6 +110,7 @@ class Channels extends BaseSettings
'full-text-search' => $request['text_search'][$id],
'media-type' => ($request['image'][$id] ? 1 : 0) | ($request['video'][$id] ? 2 : 0) | ($request['audio'][$id] ? 4 : 0),
'languages' => $request['languages'][$id],
'publish' => $request['publish'][$id],
]);
$saved = $this->channel->save($channel);
$this->logger->debug('Save channel', ['id' => $id, 'saved' => $saved]);
@ -128,7 +129,7 @@ class Channels extends BaseSettings
$user = User::getById($uid, ['account-type']);
$account_type = $user['account-type'];
if ($account_type == User::ACCOUNT_TYPE_RELAY) {
if (in_array($account_type, [User::ACCOUNT_TYPE_COMMUNITY, User::ACCOUNT_TYPE_RELAY])) {
$intro = $this->t('This page can be used to define the channels that will automatically be reshared by your account.');
$circles = [
0 => $this->l10n->t('Global Community')
@ -160,6 +161,12 @@ class Channels extends BaseSettings
$open = false;
}
if (in_array($account_type, [User::ACCOUNT_TYPE_COMMUNITY, User::ACCOUNT_TYPE_RELAY])) {
$publish = ["publish[$channel->code]", $this->t("Publish"), $channel->publish, $this->t("When selected, the channel results are reshared. This only works for public ActivityPub posts from the public timeline or the user defined circles.")];
} else {
$publish = null;
}
$channels[] = [
'id' => $channel->code,
'open' => $open,
@ -174,6 +181,7 @@ class Channels extends BaseSettings
'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2],
'audio' => ["audio[$channel->code]", $this->t("Audio"), $channel->mediaType & 4],
'languages' => ["languages[$channel->code][]", $this->t('Languages'), $channel->languages ?? $channel_languages, $this->t('Select all languages that you want to see in this channel.'), $languages, 'multiple'],
'publish' => $publish,
'delete' => ["delete[$channel->code]", $this->t("Delete channel") . ' (' . $channel->label . ')', false, $this->t("Check to delete this entry from the channel list")]
];
}