feat: support podcast:txt tag with verify use case

closes #468
This commit is contained in:
Guy Martin (Dwev) 2024-04-24 10:03:20 +00:00 committed by Yassine Doghri
parent a67f4acb3d
commit 57e459e187
7 changed files with 86 additions and 18 deletions

View File

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

View File

@ -121,6 +121,12 @@ if (! function_exists('get_rss_feed')) {
->addAttribute('owner', $podcast->owner_email);
}
if ($podcast->verify_txt !== null) {
$channel
->addChild('txt', $podcast->verify_txt, $podcastNamespace)
->addAttribute('purpose', 'verify');
}
if ($podcast->imported_feed_url !== null) {
$channel->addChild('previousUrl', $podcast->imported_feed_url, $podcastNamespace);
}

View File

@ -61,6 +61,7 @@ class PodcastModel extends Model
'location_name',
'location_geo',
'location_osm',
'verify_txt',
'payment_pointer',
'custom_rss',
'is_published_on_hubs',

View File

@ -224,6 +224,7 @@ class PodcastController extends BaseController
'location' => $this->request->getPost('location_name') === '' ? null : new Location(
$this->request->getPost('location_name')
),
'verify_txt' => $this->request->getPost('verify_txt'),
'custom_rss_string' => $this->request->getPost('custom_rss'),
'is_blocked' => $this->request->getPost('block') === 'yes',
'is_completed' => $this->request->getPost('complete') === 'yes',
@ -320,6 +321,9 @@ class PodcastController extends BaseController
$this->podcast->location = $this->request->getPost('location_name') === '' ? null : new Location(
$this->request->getPost('location_name')
);
$this->podcast->verify_txt = $this->request->getPost('verify_txt') === '' ? null : $this->request->getPost(
'verify_txt'
);
$this->podcast->custom_rss_string = $this->request->getPost('custom_rss');
$this->podcast->new_feed_url = $this->request->getPost('new_feed_url') === '' ? null : $this->request->getPost(
'new_feed_url'

View File

@ -138,6 +138,9 @@ return [
'If you need RSS tags that Castopod does not handle, set them here.',
'custom_rss' => 'Custom RSS tags for the podcast',
'custom_rss_hint' => 'This will be injected within the ❬channel❭ tag.',
'verify_txt' => 'Ownership verification TXT',
'verify_txt_hint' => 'Rather than relying on email, certain third-party services may confirm your podcast ownership by requesting you to embed a verification text within your feed.',
'verify_txt_helper' => 'This text is injected into a <podcast:txt purpose="verify"> tag.',
'new_feed_url' => 'New feed URL',
'new_feed_url_hint' => 'Use this field when you move to another domain or podcast hosting platform. By default, the value is set to the current RSS URL if the podcast is imported.',
'old_feed_url' => 'Old feed URL',

View File

@ -205,7 +205,16 @@
as="XMLEditor"
name="custom_rss"
label="<?= esc(lang('Podcast.form.custom_rss')) ?>"
hint="<?= esc(lang('Podcast.form.custom_rss_hint')) ?>" />
hint="<?= esc(lang('Podcast.form.custom_rss_hint')) ?>"
rows="8" />
<Forms.Field
as="Textarea"
name="verify_txt"
label="<?= esc(lang('Podcast.form.verify_txt')) ?>"
hint="<?= esc(lang('Podcast.form.verify_txt_hint')) ?>"
helper="<?= esc(lang('Podcast.form.verify_txt_helper')) ?>"
rows="5" />
<Forms.Toggler class="mb-2" name="lock" value="yes" checked="true" hint="<?= esc(lang('Podcast.form.lock_hint')) ?>">
<?= lang('Podcast.form.lock') ?>

View File

@ -239,25 +239,36 @@
name="custom_rss"
label="<?= esc(lang('Podcast.form.custom_rss')) ?>"
hint="<?= esc(lang('Podcast.form.custom_rss_hint')) ?>"
content="<?= esc($podcast->custom_rss_string) ?>" />
content="<?= esc($podcast->custom_rss_string) ?>"
rows="8" />
<Forms.Field
name="new_feed_url"
type="url"
label="<?= esc(lang('Podcast.form.new_feed_url')) ?>"
hint="<?= esc(lang('Podcast.form.new_feed_url_hint')) ?>"
value="<?= esc($podcast->new_feed_url) ?>"
/>
<Forms.Field
as="Textarea"
name="verify_txt"
label="<?= esc(lang('Podcast.form.verify_txt')) ?>"
hint="<?= esc(lang('Podcast.form.verify_txt_hint')) ?>"
helper="<?= esc(lang('Podcast.form.verify_txt_helper')) ?>"
value="<?= esc($podcast->verify_txt) ?>"
rows="5" />
<Forms.Field
name="new_feed_url"
type="url"
label="<?= esc(lang('Podcast.form.new_feed_url')) ?>"
hint="<?= esc(lang('Podcast.form.new_feed_url_hint')) ?>"
value="<?= esc($podcast->new_feed_url) ?>"
/>
<Forms.Toggler class="mb-2" name="lock" value="yes" checked="<?= $podcast->is_locked ? 'true' : 'false' ?>" hint="<?= esc(lang('Podcast.form.lock_hint')) ?>">
<?= lang('Podcast.form.lock') ?>
</Forms.Toggler>
<Forms.Toggler class="mb-2" name="block" value="yes" checked="<?= $podcast->is_blocked ? 'true' : 'false' ?>" hint="<?= esc(lang('Podcast.form.block_hint')) ?>">
<?= lang('Podcast.form.block') ?>
</Forms.Toggler>
<Forms.Toggler name="complete" value="yes" checked="<?= $podcast->is_completed ? 'true' : 'false' ?>">
<?= lang('Podcast.form.complete') ?>
</Forms.Toggler>
<Forms.Toggler class="mb-2" name="lock" value="yes" checked="<?= $podcast->is_locked ? 'true' : 'false' ?>" hint="<?= esc(lang('Podcast.form.lock_hint')) ?>">
<?= lang('Podcast.form.lock') ?>
</Forms.Toggler>
<Forms.Toggler class="mb-2" name="block" value="yes" checked="<?= $podcast->is_blocked ? 'true' : 'false' ?>" hint="<?= esc(lang('Podcast.form.block_hint')) ?>">
<?= lang('Podcast.form.block') ?>
</Forms.Toggler>
<Forms.Toggler name="complete" value="yes" checked="<?= $podcast->is_completed ? 'true' : 'false' ?>">
<?= lang('Podcast.form.complete') ?>
</Forms.Toggler>
</Forms.Section>
</div>