Unverified Commit 0a66de3e authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix: set cache expiration to next note publish to show note on publication date

fix episode, podcast and persons forms + episode scheduling
parent fbc0967c
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ Events::on('on_note_add', function (Note $note): void {
    // same for other events below
    cache()
        ->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("podcast#{$note->actor->podcast->id}*");
});

Events::on('on_note_remove', function (Note $note): void {
@@ -108,6 +110,8 @@ Events::on('on_note_remove', function (Note $note): void {

    cache()
        ->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("page_note#{$note->id}*");
});
@@ -125,6 +129,8 @@ Events::on('on_note_reblog', function (Actor $actor, Note $note): void {

    cache()
        ->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("page_note#{$note->id}*");

@@ -147,6 +153,8 @@ Events::on('on_note_undo_reblog', function (Note $reblogNote): void {

    cache()
        ->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("page_note#{$note->id}*");

@@ -169,6 +177,8 @@ Events::on('on_reply_remove', function (Note $reply): void {

    cache()
        ->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("podcast#{$note->actor->podcast->id}*");
    cache()
        ->deleteMatching("page_note#{$note->id}*");
});
@@ -182,6 +192,8 @@ Events::on('on_note_favourite', function (Actor $actor, Note $note): void {

    cache()
        ->deleteMatching("page_podcast#{$actor->podcast->id}*");
    cache()
        ->deleteMatching("podcast#{$actor->podcast->id}*");
    cache()
        ->deleteMatching("page_note#{$note->id}*");

@@ -199,6 +211,8 @@ Events::on('on_note_undo_favourite', function (Actor $actor, Note $note): void {

    cache()
        ->deleteMatching("page_podcast#{$actor->podcast->id}*");
    cache()
        ->deleteMatching("podcast#{$actor->podcast->id}*");
    cache()
        ->deleteMatching("page_note#{$note->id}*");

@@ -209,24 +223,32 @@ Events::on('on_note_undo_favourite', function (Actor $actor, Note $note): void {

Events::on('on_block_actor', function (int $actorId): void {
    cache()->deleteMatching('page_podcast*');
    cache()
        ->deleteMatching('podcast*');
    cache()
        ->deleteMatching('page_note*');
});

Events::on('on_unblock_actor', function (int $actorId): void {
    cache()->deleteMatching('page_podcast*');
    cache()
        ->deleteMatching('podcast*');
    cache()
        ->deleteMatching('page_note*');
});

Events::on('on_block_domain', function (string $domainName): void {
    cache()->deleteMatching('page_podcast*');
    cache()
        ->deleteMatching('podcast*');
    cache()
        ->deleteMatching('page_note*');
});

Events::on('on_unblock_domain', function (string $domainName): void {
    cache()->deleteMatching('page_podcast*');
    cache()
        ->deleteMatching('podcast*');
    cache()
        ->deleteMatching('page_note*');
});
+11 −4
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
namespace App\Controllers\Admin;

use App\Entities\Episode;
use App\Entities\Image;
use App\Entities\Location;
use App\Entities\Note;
use App\Entities\Podcast;
@@ -118,6 +119,12 @@ class EpisodeController extends BaseController
                ->with('errors', $this->validator->getErrors());
        }

        $image = null;
        $imageFile = $this->request->getFile('image');
        if ($imageFile !== null && $imageFile->isValid()) {
            $image = new Image($imageFile);
        }

        $newEpisode = new Episode([
            'podcast_id' => $this->podcast->id,
            'title' => $this->request->getPost('title'),
@@ -125,7 +132,7 @@ class EpisodeController extends BaseController
            'guid' => '',
            'audio_file' => $this->request->getFile('audio_file'),
            'description_markdown' => $this->request->getPost('description'),
            'image' => $this->request->getFile('image'),
            'image' => $image,
            'location' => new Location($this->request->getPost('location_name'),),
            'transcript' => $this->request->getFile('transcript'),
            'chapters' => $this->request->getFile('chapters'),
@@ -253,9 +260,9 @@ class EpisodeController extends BaseController
            $this->episode->audio_file = $audioFile;
        }

        $image = $this->request->getFile('image');
        if ($image !== null && $image->isValid()) {
            $this->episode->image = $image;
        $imageFile = $this->request->getFile('image');
        if ($imageFile !== null && $imageFile->isValid()) {
            $this->episode->image = new Image($imageFile);
        }

        $transcriptChoice = $this->request->getPost('transcript-choice');
+3 −3
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class EpisodePersonController extends BaseController
    public function attemptAdd(): RedirectResponse
    {
        $rules = [
            'person' => 'required',
            'persons' => 'required',
        ];

        if (! $this->validate($rules)) {
@@ -79,8 +79,8 @@ class EpisodePersonController extends BaseController
        (new PersonModel())->addEpisodePersons(
            $this->podcast->id,
            $this->episode->id,
            $this->request->getPost('person'),
            $this->request->getPost('person_group_role'),
            $this->request->getPost('persons'),
            $this->request->getPost('roles') ?? [],
        );

        return redirect()->back();
+2 −2
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ class PodcastController extends BaseController
        // set Podcast categories
        (new CategoryModel())->setPodcastCategories(
            (int) $newPodcastId,
            $this->request->getPost('other_categories'),
            $this->request->getPost('other_categories') ?? [],
        );

        // set interact as the newly created podcast actor
@@ -320,7 +320,7 @@ class PodcastController extends BaseController
        // set Podcast categories
        (new CategoryModel())->setPodcastCategories(
            $this->podcast->id,
            $this->request->getPost('other_categories'),
            $this->request->getPost('other_categories') ?? [],
        );

        $db->transComplete();
+8 −1
Original line number Diff line number Diff line
@@ -67,8 +67,15 @@ class PodcastController extends BaseController
                helper('form');
                return view('podcast/activity_authenticated', $data);
            }

            $secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode(
                $this->podcast->id,
            );

            return view('podcast/activity', $data, [
                'cache' => DECADE,
                'cache' => $secondsToNextUnpublishedEpisode
                    ? $secondsToNextUnpublishedEpisode
                    : DECADE,
                'cache_name' => $cacheName,
            ]);
        }
Loading