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 $owner_name
* @property string $owner_email
* @property bool $is_owner_email_removed_from_feed
* @property string $type
* @property string|null $copyright
* @property string|null $episode_description_footer_markdown
@ -191,6 +192,7 @@ class Podcast extends Entity
'publisher' => '?string',
'owner_name' => 'string',
'owner_email' => 'string',
'is_owner_email_removed_from_feed' => 'boolean',
'type' => 'string',
'copyright' => '?string',
'episode_description_footer_markdown' => '?string',

View File

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

View File

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

View File

@ -214,12 +214,13 @@ class PodcastController extends BaseController
'parental_advisory' => $this->request->getPost('parental_advisory') !== 'undefined'
? $this->request->getPost('parental_advisory')
: null,
'owner_name' => $this->request->getPost('owner_name'),
'owner_email' => $this->request->getPost('owner_email'),
'publisher' => $this->request->getPost('publisher'),
'type' => $this->request->getPost('type'),
'copyright' => $this->request->getPost('copyright'),
'location' => $this->request->getPost('location_name') === '' ? null : new Location(
'owner_name' => $this->request->getPost('owner_name'),
'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'),
'type' => $this->request->getPost('type'),
'copyright' => $this->request->getPost('copyright'),
'location' => $this->request->getPost('location_name') === '' ? null : new Location(
$this->request->getPost('location_name')
),
'custom_rss_string' => $this->request->getPost('custom_rss'),

View File

@ -99,6 +99,8 @@ return [
'owner_email' => 'Owner email',
'owner_email_hint' =>
'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_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.',

View File

@ -121,6 +121,9 @@
hint="<?= lang('Podcast.form.owner_email_hint') ?>"
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
name="publisher"
label="<?= lang('Podcast.form.publisher') ?>"

View File

@ -147,6 +147,9 @@
hint="<?= lang('Podcast.form.owner_email_hint') ?>"
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
name="publisher"
label="<?= lang('Podcast.form.publisher') ?>"