Commit 222e02a2 authored by Ewen Korr's avatar Ewen Korr Committed by Yassine Doghri
Browse files

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

parent 9178c3f3
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
<?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);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -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',
+12 −4
Original line number Diff line number Diff line
@@ -101,9 +101,15 @@ if (! function_exists('get_rss_feed')) {
            $recipientElement->addAttribute('split', '100');
        }

        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);

        if (! $podcast->is_owner_email_removed_from_feed) {
            $owner->addChild('email', $podcast->owner_email, $itunesNamespace);
        }

        $channel->addChild('type', $podcast->type, $itunesNamespace);
        $podcast->copyright &&
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ class PodcastModel extends Model
        'parental_advisory',
        'owner_name',
        'owner_email',
        'is_owner_email_removed_from_feed',
        'publisher',
        'type',
        'copyright',
+7 −6
Original line number Diff line number Diff line
@@ -216,6 +216,7 @@ class PodcastController extends BaseController
                    : null,
            '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'),
Loading