diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 7beb251aa..0bdf12213 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -1867,17 +1867,17 @@ class ApiV1Controller extends Controller if(config('database.default') == 'pgsql') { $dms = DirectMessage::when($scope === 'inbox', function($q, $scope) use($pid) { - return $q->whereIsHidden(false)->whereToId($pid)->orWhere('from_id', $pid); + return $q->whereIsHidden(false)->where('to_id', $pid)->orWhere('from_id', $pid); }) ->when($scope === 'sent', function($q, $scope) use($pid) { - return $q->whereFromId($pid); + return $q->whereFromId($pid)->groupBy(['to_id', 'id']); }) ->when($scope === 'requests', function($q, $scope) use($pid) { return $q->whereToId($pid)->whereIsHidden(true); }); } else { $dms = DirectMessage::when($scope === 'inbox', function($q, $scope) use($pid) { - return $q->whereIsHidden(false)->whereToId($pid)->orWhere('from_id', $pid)->groupBy('to_id'); + return $q->whereIsHidden(false)->where('to_id', $pid)->orWhere('from_id', $pid); }) ->when($scope === 'sent', function($q, $scope) use($pid) { return $q->whereFromId($pid)->groupBy('to_id'); @@ -1887,7 +1887,7 @@ class ApiV1Controller extends Controller }); } - $dms = $dms->latest() + $dms = $dms->orderByDesc('created_at') ->simplePaginate($limit) ->map(function($dm) use($pid) { $from = $pid == $dm->to_id ? $dm->from_id : $dm->to_id; diff --git a/app/Services/StatusLabelService.php b/app/Services/StatusLabelService.php index 2c1a3a7f4..30c3533cd 100644 --- a/app/Services/StatusLabelService.php +++ b/app/Services/StatusLabelService.php @@ -19,6 +19,11 @@ class StatusLabelService } return Cache::remember(self::CACHE_KEY . $status->id, now()->addDays(7), function() use($status) { + if(!$status->caption) { + return [ + 'covid' => false + ]; + } return [ 'covid' => Str::of(strtolower($status->caption))->contains(['covid','corona', 'coronavirus', 'vaccine', 'vaxx', 'vaccination', 'plandemic']) ]; diff --git a/app/Services/StatusService.php b/app/Services/StatusService.php index f3b4b3538..9f8188ce6 100644 --- a/app/Services/StatusService.php +++ b/app/Services/StatusService.php @@ -131,7 +131,7 @@ class StatusService $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); - $resource = new Fractal\Resource\Item($status, new StatusTransformer()); + $resource = new Fractal\Resource\Item($status, new StatusStatelessTransformer()); return $fractal->createData($resource)->toArray(); } diff --git a/app/Transformer/Api/AccountTransformer.php b/app/Transformer/Api/AccountTransformer.php index e8ac84196..1e8ab0958 100644 --- a/app/Transformer/Api/AccountTransformer.php +++ b/app/Transformer/Api/AccountTransformer.php @@ -30,7 +30,7 @@ class AccountTransformer extends Fractal\TransformerAbstract 'following_count' => (int) $profile->followingCount(), 'statuses_count' => (int) $profile->statusCount(), 'note' => $profile->bio ?? '', - 'note_text' => strip_tags($profile->bio), + 'note_text' => $profile->bio ? strip_tags($profile->bio) : null, 'url' => $profile->url(), 'avatar' => $profile->avatarUrl(), 'website' => $profile->website,