From 222e02a2af9ecb8b8768a63d3054f4c3ef54e991 Mon Sep 17 00:00:00 2001 From: Ewen Korr Date: Mon, 1 Jan 2024 10:11:29 +0000 Subject: [PATCH] feat: allow hiding owner's email in public RSS feed --- ...9-150000_add_podcasts_owner_email_feed.php | 36 +++++++++++++++++++ app/Entities/Podcast.php | 2 ++ app/Helpers/rss_helper.php | 16 ++++++--- app/Models/PodcastModel.php | 1 + .../Admin/Controllers/PodcastController.php | 13 +++---- modules/Admin/Language/en/Podcast.php | 2 ++ themes/cp_admin/podcast/create.php | 3 ++ themes/cp_admin/podcast/edit.php | 3 ++ 8 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 app/Database/Migrations/2023-12-29-150000_add_podcasts_owner_email_feed.php diff --git a/app/Database/Migrations/2023-12-29-150000_add_podcasts_owner_email_feed.php b/app/Database/Migrations/2023-12-29-150000_add_podcasts_owner_email_feed.php new file mode 100644 index 00000000..88765f1e --- /dev/null +++ b/app/Database/Migrations/2023-12-29-150000_add_podcasts_owner_email_feed.php @@ -0,0 +1,36 @@ + [ + '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); + } +} diff --git a/app/Entities/Podcast.php b/app/Entities/Podcast.php index 23fd04e7..649d1f1b 100644 --- a/app/Entities/Podcast.php +++ b/app/Entities/Podcast.php @@ -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', diff --git a/app/Helpers/rss_helper.php b/app/Helpers/rss_helper.php index cde17a2d..ddcdf36c 100644 --- a/app/Helpers/rss_helper.php +++ b/app/Helpers/rss_helper.php @@ -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 && diff --git a/app/Models/PodcastModel.php b/app/Models/PodcastModel.php index 719bff32..aa905ba2 100644 --- a/app/Models/PodcastModel.php +++ b/app/Models/PodcastModel.php @@ -48,6 +48,7 @@ class PodcastModel extends Model 'parental_advisory', 'owner_name', 'owner_email', + 'is_owner_email_removed_from_feed', 'publisher', 'type', 'copyright', diff --git a/modules/Admin/Controllers/PodcastController.php b/modules/Admin/Controllers/PodcastController.php index ea650a5a..4ac1157f 100644 --- a/modules/Admin/Controllers/PodcastController.php +++ b/modules/Admin/Controllers/PodcastController.php @@ -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'), diff --git a/modules/Admin/Language/en/Podcast.php b/modules/Admin/Language/en/Podcast.php index d9359e9b..3f423f5a 100644 --- a/modules/Admin/Language/en/Podcast.php +++ b/modules/Admin/Language/en/Podcast.php @@ -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’.', diff --git a/themes/cp_admin/podcast/create.php b/themes/cp_admin/podcast/create.php index 62c3b642..c2a9ac65 100644 --- a/themes/cp_admin/podcast/create.php +++ b/themes/cp_admin/podcast/create.php @@ -121,6 +121,9 @@ hint="" required="true" /> + + + + + +