Commit a5aef2a6 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(rss): generate podcast guid if empty

closes #450
parent 13db54cc
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use App\Entities\Category;
use App\Entities\Location;
use App\Entities\Podcast;
use App\Libraries\SimpleRSSElement;
use App\Models\PodcastModel;
use CodeIgniter\I18n\Time;
use Config\Mimes;
use Modules\Media\Entities\Chapters;
@@ -69,6 +70,16 @@ if (! function_exists('get_rss_feed')) {
        $channel->addChild('generator', 'Castopod - https://castopod.org/');
        $channel->addChild('docs', 'https://cyber.harvard.edu/rss/rss.html');

        if ($podcast->guid === '') {
            // FIXME: guid shouldn't be empty here as it should be filled upon Podcast creation
            $uuid = service('uuid');
            // 'ead4c236-bf58-58c6-a2c6-a6b28d128cb6' is the uuid of the podcast namespace
            $podcast->guid = $uuid->uuid5('ead4c236-bf58-58c6-a2c6-a6b28d128cb6', $podcast->feed_url)
                ->toString();

            (new PodcastModel())->save($podcast);
        }

        $channel->addChild('guid', $podcast->guid, $podcastNamespace);
        $channel->addChild('title', $podcast->title, null, false);
        $channel->addChildWithCDATA('description', $podcast->description_html);
+3 −3
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ class PodcastModel extends Model
     */
    public function clearCache(array $data): array
    {
        $podcast = (new self())->getPodcastById(is_array($data['id']) ? $data['id'][0] : $data['id']);
        $podcast = (new self())->getPodcastById((int) (is_array($data['id']) ? $data['id'][0] : $data['id']));

        // delete cache for users' podcasts
        cache()
@@ -443,7 +443,7 @@ class PodcastModel extends Model
     */
    protected function setActorAvatar(array $data): array
    {
        $podcast = (new self())->getPodcastById(is_array($data['id']) ? $data['id'][0] : $data['id']);
        $podcast = (new self())->getPodcastById((int) (is_array($data['id']) ? $data['id'][0] : $data['id']));

        if ($podcast instanceof Podcast) {
            $podcastActor = (new ActorModel())->find($podcast->actor_id);
@@ -468,7 +468,7 @@ class PodcastModel extends Model
     */
    protected function updatePodcastActor(array $data): array
    {
        $podcast = (new self())->getPodcastById(is_array($data['id']) ? $data['id'][0] : $data['id']);
        $podcast = (new self())->getPodcastById((int) (is_array($data['id']) ? $data['id'][0] : $data['id']));

        if ($podcast instanceof Podcast) {
            $actorModel = new ActorModel();