Loading app/Controllers/Admin/PodcastController.php +1 −0 Original line number Diff line number Diff line Loading @@ -192,6 +192,7 @@ class PodcastController extends BaseController } $podcast = new Podcast([ 'guid' => podcast_uuid(url_to('podcast_feed', $this->request->getPost('name'))), 'title' => $this->request->getPost('title'), 'name' => $this->request->getPost('name'), 'description_markdown' => $this->request->getPost('description'), Loading app/Controllers/Admin/PodcastImportController.php +7 −1 Original line number Diff line number Diff line Loading @@ -128,11 +128,17 @@ class PodcastImportController extends BaseController (string) $nsPodcast->location->attributes()['osm'], ); } if (property_exists($nsPodcast, 'guid') && $nsPodcast->guid !== null) { $guid = (string) $nsPodcast->guid; } else { $guid = podcast_uuid(url_to('podcast_feed', $this->request->getPost('name'))); } $podcast = new Podcast([ 'guid' => $guid, 'name' => $this->request->getPost('name'), 'imported_feed_url' => $this->request->getPost('imported_feed_url'), 'new_feed_url' => base_url(route_to('podcast_feed', $this->request->getPost('name'))), 'new_feed_url' => url_to('podcast_feed', $this->request->getPost('name')), 'title' => (string) $feed->channel[0]->title, 'description_markdown' => $converter->convert($channelDescriptionHtml), 'description_html' => $channelDescriptionHtml, Loading app/Database/Migrations/2020-05-30-101500_add_podcasts.php +5 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ class AddPodcasts extends Migration 'unsigned' => true, 'auto_increment' => true, ], 'guid' => [ 'type' => 'CHAR', 'constraint' => 36, ], 'actor_id' => [ 'type' => 'INT', 'unsigned' => true, Loading Loading @@ -190,6 +194,7 @@ class AddPodcasts extends Migration $this->forge->addPrimaryKey('id'); // TODO: remove name in favor of username from actor $this->forge->addUniqueKey('name'); $this->forge->addUniqueKey('guid'); $this->forge->addUniqueKey('actor_id'); $this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE'); $this->forge->addForeignKey('category_id', 'categories', 'id'); Loading app/Entities/Podcast.php +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ use RuntimeException; /** * @property int $id * @property string $guid * @property int $actor_id * @property Actor|null $actor * @property string $name Loading Loading @@ -137,6 +138,7 @@ class Podcast extends Entity */ protected $casts = [ 'id' => 'integer', 'guid' => 'string', 'actor_id' => 'integer', 'name' => 'string', 'title' => 'string', Loading app/Helpers/misc_helper.php +14 −0 Original line number Diff line number Diff line Loading @@ -148,4 +148,18 @@ if (! function_exists('format_duration')) { } } if (! function_exists('podcast_uuid')) { /** * Generate UUIDv5 for podcast. For more information, see * https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#guid */ function podcast_uuid(string $feedUrl): string { $uuid = service('uuid'); // 'ead4c236-bf58-58c6-a2c6-a6b28d128cb6' is the uuid of the podcast namespace return $uuid->uuid5('ead4c236-bf58-58c6-a2c6-a6b28d128cb6', $feedUrl) ->toString(); } } //-------------------------------------------------------------------- Loading
app/Controllers/Admin/PodcastController.php +1 −0 Original line number Diff line number Diff line Loading @@ -192,6 +192,7 @@ class PodcastController extends BaseController } $podcast = new Podcast([ 'guid' => podcast_uuid(url_to('podcast_feed', $this->request->getPost('name'))), 'title' => $this->request->getPost('title'), 'name' => $this->request->getPost('name'), 'description_markdown' => $this->request->getPost('description'), Loading
app/Controllers/Admin/PodcastImportController.php +7 −1 Original line number Diff line number Diff line Loading @@ -128,11 +128,17 @@ class PodcastImportController extends BaseController (string) $nsPodcast->location->attributes()['osm'], ); } if (property_exists($nsPodcast, 'guid') && $nsPodcast->guid !== null) { $guid = (string) $nsPodcast->guid; } else { $guid = podcast_uuid(url_to('podcast_feed', $this->request->getPost('name'))); } $podcast = new Podcast([ 'guid' => $guid, 'name' => $this->request->getPost('name'), 'imported_feed_url' => $this->request->getPost('imported_feed_url'), 'new_feed_url' => base_url(route_to('podcast_feed', $this->request->getPost('name'))), 'new_feed_url' => url_to('podcast_feed', $this->request->getPost('name')), 'title' => (string) $feed->channel[0]->title, 'description_markdown' => $converter->convert($channelDescriptionHtml), 'description_html' => $channelDescriptionHtml, Loading
app/Database/Migrations/2020-05-30-101500_add_podcasts.php +5 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ class AddPodcasts extends Migration 'unsigned' => true, 'auto_increment' => true, ], 'guid' => [ 'type' => 'CHAR', 'constraint' => 36, ], 'actor_id' => [ 'type' => 'INT', 'unsigned' => true, Loading Loading @@ -190,6 +194,7 @@ class AddPodcasts extends Migration $this->forge->addPrimaryKey('id'); // TODO: remove name in favor of username from actor $this->forge->addUniqueKey('name'); $this->forge->addUniqueKey('guid'); $this->forge->addUniqueKey('actor_id'); $this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE'); $this->forge->addForeignKey('category_id', 'categories', 'id'); Loading
app/Entities/Podcast.php +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ use RuntimeException; /** * @property int $id * @property string $guid * @property int $actor_id * @property Actor|null $actor * @property string $name Loading Loading @@ -137,6 +138,7 @@ class Podcast extends Entity */ protected $casts = [ 'id' => 'integer', 'guid' => 'string', 'actor_id' => 'integer', 'name' => 'string', 'title' => 'string', Loading
app/Helpers/misc_helper.php +14 −0 Original line number Diff line number Diff line Loading @@ -148,4 +148,18 @@ if (! function_exists('format_duration')) { } } if (! function_exists('podcast_uuid')) { /** * Generate UUIDv5 for podcast. For more information, see * https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#guid */ function podcast_uuid(string $feedUrl): string { $uuid = service('uuid'); // 'ead4c236-bf58-58c6-a2c6-a6b28d128cb6' is the uuid of the podcast namespace return $uuid->uuid5('ead4c236-bf58-58c6-a2c6-a6b28d128cb6', $feedUrl) ->toString(); } } //--------------------------------------------------------------------