From 0fbde91e872178a303d8bf42c7635cca753dc785 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 27 Dec 2020 17:54:55 -0700 Subject: [PATCH] Update StatusService, cast response to array --- app/Http/Controllers/Api/BaseApiController.php | 1 + app/Http/Controllers/StatusController.php | 2 +- app/Services/StatusService.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index 6a4497587..686c5dbca 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -133,6 +133,7 @@ class BaseApiController extends Controller $statuses = $account->statuses()->getQuery(); if($only_media == true) { $statuses = $statuses + ->whereIn('scope', ['public','unlisted']) ->whereHas('media') ->whereNull('in_reply_to_id') ->whereNull('reblog_of_id'); diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 34aa16c40..c23e9bf4d 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -33,7 +33,7 @@ class StatusController extends Controller $status = Status::whereProfileId($user->id) ->whereNull('reblog_of_id') - ->whereNotIn('visibility',['draft','direct']) + ->whereIn('scope', ['public','unlisted']) ->findOrFail($id); if($status->uri || $status->url) { diff --git a/app/Services/StatusService.php b/app/Services/StatusService.php index 2fc4634a9..10f8d34f6 100644 --- a/app/Services/StatusService.php +++ b/app/Services/StatusService.php @@ -17,12 +17,12 @@ class StatusService { public static function get($id) { - return json_decode(Redis::get(self::CACHE_KEY . $id) ?? self::coldGet($id)); + return json_decode(Redis::get(self::CACHE_KEY . $id) ?? self::coldGet($id), true); } public static function coldGet($id) { - $status = Status::findOrFail($id); + $status = Status::whereScope('public')->findOrFail($id); $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); $resource = new Fractal\Resource\Item($status, new StatusStatelessTransformer());