Update StatusService

This commit is contained in:
Daniel Supernault 2022-04-18 01:59:27 -06:00
parent 2b188acff3
commit cc6b78c436
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
4 changed files with 11 additions and 6 deletions

View File

@ -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;

View File

@ -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'])
];

View File

@ -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();
}

View File

@ -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,