Unverified Commit 92536ddb authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(activity-pub): get database records using new model instances

update types and some remap logic
parent 4a28127b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class PermissionModel extends MythAuthPermissionModel
            $groupPermissions = $this->db
                ->table('auth_groups_permissions')
                ->select('id, auth_permissions.name')
                ->join('auth_permissions', 'auth_permissions.id = permission_id', 'inner',)
                ->join('auth_permissions', 'auth_permissions.id = permission_id', 'inner')
                ->where('group_id', $groupId)
                ->get()
                ->getResultObject();
+6 −6
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ Events::on('on_undo_follow', function ($actor, $targetActor): void {
 * @param Note $note
 */
Events::on('on_note_add', function ($note): void {
    if ($note->is_reply) {
    if ($note->in_reply_to_id !== null) {
        $note = $note->reply_to_note;
    }

@@ -147,7 +147,7 @@ Events::on('on_note_add', function ($note): void {
 * @param Note $note
 */
Events::on('on_note_remove', function ($note): void {
    if ($note->is_reply) {
    if ($note->in_reply_to_id !== null) {
        Events::trigger('on_note_remove', $note->reply_to_note);
    }

@@ -207,7 +207,7 @@ Events::on('on_note_reblog', function ($actor, $note): void {
    cache()
        ->deleteMatching("page_note#{$note->id}*");

    if ($note->is_reply) {
    if ($note->in_reply_to_id !== null) {
        cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
    }
});
@@ -239,7 +239,7 @@ Events::on('on_note_undo_reblog', function ($reblogNote): void {
    cache()
        ->deleteMatching("page_note#{$reblogNote->id}*");

    if ($note->is_reply) {
    if ($note->in_reply_to_id !== null) {
        cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
    }

@@ -308,7 +308,7 @@ Events::on('on_note_favourite', function ($actor, $note): void {
    cache()
        ->deleteMatching("page_note#{$note->id}*");

    if ($note->is_reply) {
    if ($note->in_reply_to_id !== null) {
        cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
    }

@@ -340,7 +340,7 @@ Events::on('on_note_undo_favourite', function ($actor, $note): void {
    cache()
        ->deleteMatching("page_note#{$note->id}*");

    if ($note->is_reply) {
    if ($note->in_reply_to_id !== null) {
        cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
    }

+13 −8
Original line number Diff line number Diff line
@@ -27,19 +27,24 @@ class ContributorController extends BaseController

    public function _remap(string $method, string ...$params): mixed
    {
        $this->podcast = (new PodcastModel())->getPodcastById((int) $params[0]);
        if (count($params) === 0) {
            throw PageNotFoundException::forPageNotFound();
        }

        if (count($params) <= 1) {
            return $this->{$method}();
        if (($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) === null) {
            throw PageNotFoundException::forPageNotFound();
        }

        $this->podcast = $podcast;

        if (
            ($this->user = (new UserModel())->getPodcastContributor((int) $params[1], (int) $params[0],)) !== null
            count($params) > 1 &&
            ($this->user = (new UserModel())->getPodcastContributor((int) $params[1], (int) $params[0])) === null
        ) {
            return $this->{$method}();
            throw PageNotFoundException::forPageNotFound();
        }

        throw PageNotFoundException::forPageNotFound();
        return $this->{$method}();
    }

    public function list(): string
@@ -57,7 +62,7 @@ class ContributorController extends BaseController
    public function view(): string
    {
        $data = [
            'contributor' => (new UserModel())->getPodcastContributor($this->user->id, $this->podcast->id,),
            'contributor' => (new UserModel())->getPodcastContributor($this->user->id, $this->podcast->id),
        ];

        replace_breadcrumb_params([
@@ -173,7 +178,7 @@ class ContributorController extends BaseController

        $podcastModel = new PodcastModel();
        if (
            ! $podcastModel->removePodcastContributor($this->user->id, $this->podcast->id,)
            ! $podcastModel->removePodcastContributor($this->user->id, $this->podcast->id)
        ) {
            return redirect()
                ->back()
+6 −4
Original line number Diff line number Diff line
@@ -33,11 +33,13 @@ class EpisodeController extends BaseController
    public function _remap(string $method, string ...$params): mixed
    {
        if (
            ($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) === null
            ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) === null
        ) {
            throw PageNotFoundException::forPageNotFound();
        }

        $this->podcast = $podcast;

        if (count($params) > 1) {
            if (
                ! ($this->episode = (new EpisodeModel())
@@ -135,7 +137,7 @@ class EpisodeController extends BaseController
            'audio_file' => $this->request->getFile('audio_file'),
            'description_markdown' => $this->request->getPost('description'),
            'image' => $image,
            'location' => new Location($this->request->getPost('location_name'),),
            'location' => new Location($this->request->getPost('location_name')),
            'transcript' => $this->request->getFile('transcript'),
            'chapters' => $this->request->getFile('chapters'),
            'parental_advisory' =>
@@ -276,7 +278,7 @@ class EpisodeController extends BaseController
            }
        } elseif ($transcriptChoice === 'remote-url') {
            if (
                ($transcriptFileRemoteUrl = $this->request->getPost('transcript_file_remote_url',)) &&
                ($transcriptFileRemoteUrl = $this->request->getPost('transcript_file_remote_url')) &&
                (($transcriptFile = $this->episode->transcript_file) &&
                    $transcriptFile !== null)
            ) {
@@ -295,7 +297,7 @@ class EpisodeController extends BaseController
            }
        } elseif ($chaptersChoice === 'remote-url') {
            if (
                ($chaptersFileRemoteUrl = $this->request->getPost('chapters_file_remote_url',)) &&
                ($chaptersFileRemoteUrl = $this->request->getPost('chapters_file_remote_url')) &&
                (($chaptersFile = $this->episode->chapters_file) &&
                    $chaptersFile !== null)
            ) {
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ class EpisodePersonController extends BaseController
        }

        if (
            ($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) &&
            ($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0])) &&
            ($this->episode = (new EpisodeModel())
                ->where([
                    'id' => $params[1],
Loading