feat: allow hiding owner's email in public RSS feed

This commit is contained in:
Ewen Korr 2024-01-01 10:11:29 +00:00 committed by Yassine Doghri
parent 9178c3f3af
commit 222e02a2af
8 changed files with 66 additions and 10 deletions

View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* Class AddPodcastsOwnerEmailRemovedFromFeed adds is_owner_email_removed_from_feed field to podcast table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
class AddPodcastsOwnerEmailRemovedFromFeed extends BaseMigration
{
public function up(): void
{
$fields = [
'is_owner_email_removed_from_feed' => [
'type' => 'BOOLEAN',
'null' => false,
'default' => 0,
'after' => 'owner_email',
],
];
$this->forge->addColumn('podcasts', $fields);
}
public function down(): void
{
$fields = ['is_owner_email_removed_from_feed'];
$this->forge->dropColumn('podcasts', $fields);
}
}

View File

@ -62,6 +62,7 @@ use RuntimeException;
* @property string|null $publisher * @property string|null $publisher
* @property string $owner_name * @property string $owner_name
* @property string $owner_email * @property string $owner_email
* @property bool $is_owner_email_removed_from_feed
* @property string $type * @property string $type
* @property string|null $copyright * @property string|null $copyright
* @property string|null $episode_description_footer_markdown * @property string|null $episode_description_footer_markdown
@ -191,6 +192,7 @@ class Podcast extends Entity
'publisher' => '?string', 'publisher' => '?string',
'owner_name' => 'string', 'owner_name' => 'string',
'owner_email' => 'string', 'owner_email' => 'string',
'is_owner_email_removed_from_feed' => 'boolean',
'type' => 'string', 'type' => 'string',
'copyright' => '?string', 'copyright' => '?string',
'episode_description_footer_markdown' => '?string', 'episode_description_footer_markdown' => '?string',

View File

@ -101,9 +101,15 @@ if (! function_exists('get_rss_feed')) {
$recipientElement->addAttribute('split', '100'); $recipientElement->addAttribute('split', '100');
} }
if ($podcast->is_owner_email_removed_from_feed) {
$channel
->addChild('locked', $podcast->is_locked ? 'yes' : 'no', $podcastNamespace);
} else {
$channel $channel
->addChild('locked', $podcast->is_locked ? 'yes' : 'no', $podcastNamespace) ->addChild('locked', $podcast->is_locked ? 'yes' : 'no', $podcastNamespace)
->addAttribute('owner', $podcast->owner_email); ->addAttribute('owner', $podcast->owner_email);
}
if ($podcast->imported_feed_url !== null) { if ($podcast->imported_feed_url !== null) {
$channel->addChild('previousUrl', $podcast->imported_feed_url, $podcastNamespace); $channel->addChild('previousUrl', $podcast->imported_feed_url, $podcastNamespace);
} }
@ -249,7 +255,9 @@ if (! function_exists('get_rss_feed')) {
$owner->addChild('name', $podcast->owner_name, $itunesNamespace, false); $owner->addChild('name', $podcast->owner_name, $itunesNamespace, false);
if (! $podcast->is_owner_email_removed_from_feed) {
$owner->addChild('email', $podcast->owner_email, $itunesNamespace); $owner->addChild('email', $podcast->owner_email, $itunesNamespace);
}
$channel->addChild('type', $podcast->type, $itunesNamespace); $channel->addChild('type', $podcast->type, $itunesNamespace);
$podcast->copyright && $podcast->copyright &&

View File

@ -48,6 +48,7 @@ class PodcastModel extends Model
'parental_advisory', 'parental_advisory',
'owner_name', 'owner_name',
'owner_email', 'owner_email',
'is_owner_email_removed_from_feed',
'publisher', 'publisher',
'type', 'type',
'copyright', 'copyright',

View File

@ -216,6 +216,7 @@ class PodcastController extends BaseController
: null, : null,
'owner_name' => $this->request->getPost('owner_name'), 'owner_name' => $this->request->getPost('owner_name'),
'owner_email' => $this->request->getPost('owner_email'), 'owner_email' => $this->request->getPost('owner_email'),
'is_owner_email_removed_from_feed' => $this->request->getPost('is_owner_email_removed_from_feed') === 'yes',
'publisher' => $this->request->getPost('publisher'), 'publisher' => $this->request->getPost('publisher'),
'type' => $this->request->getPost('type'), 'type' => $this->request->getPost('type'),
'copyright' => $this->request->getPost('copyright'), 'copyright' => $this->request->getPost('copyright'),

View File

@ -99,6 +99,8 @@ return [
'owner_email' => 'Owner email', 'owner_email' => 'Owner email',
'owner_email_hint' => 'owner_email_hint' =>
'Will be used by most platforms to verify the podcast ownership. Visible in the public RSS feed.', 'Will be used by most platforms to verify the podcast ownership. Visible in the public RSS feed.',
'is_owner_email_removed_from_feed' => 'Remove the owner email from the public RSS feed',
'is_owner_email_removed_from_feed_hint' => 'You may need to temporarily unhide the email so that a directory can verify your podcast ownership.',
'publisher' => 'Publisher', 'publisher' => 'Publisher',
'publisher_hint' => 'publisher_hint' =>
'The group responsible for creating the show. Often refers to the parent company or network of a podcast. This field is sometimes labeled as Author.', 'The group responsible for creating the show. Often refers to the parent company or network of a podcast. This field is sometimes labeled as Author.',

View File

@ -121,6 +121,9 @@
hint="<?= lang('Podcast.form.owner_email_hint') ?>" hint="<?= lang('Podcast.form.owner_email_hint') ?>"
required="true" /> required="true" />
<Forms.Toggler class="mt-2" name="is_owner_email_removed_from_feed" value="yes" checked="false" hint="<?= lang('Podcast.form.is_owner_email_removed_from_feed_hint') ?>">
<?= lang('Podcast.form.is_owner_email_removed_from_feed') ?></Forms.Toggler>
<Forms.Field <Forms.Field
name="publisher" name="publisher"
label="<?= lang('Podcast.form.publisher') ?>" label="<?= lang('Podcast.form.publisher') ?>"

View File

@ -147,6 +147,9 @@
hint="<?= lang('Podcast.form.owner_email_hint') ?>" hint="<?= lang('Podcast.form.owner_email_hint') ?>"
required="true" /> required="true" />
<Forms.Toggler class="mt-2" name="is_owner_email_removed_from_feed" value="yes" checked="<?= $podcast->is_owner_email_removed_from_feed ? 'true' : 'false' ?>" hint="<?= lang('Podcast.form.is_owner_email_removed_from_feed_hint') ?>">
<?= lang('Podcast.form.is_owner_email_removed_from_feed') ?></Forms.Toggler>
<Forms.Field <Forms.Field
name="publisher" name="publisher"
label="<?= lang('Podcast.form.publisher') ?>" label="<?= lang('Podcast.form.publisher') ?>"