1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-24 00:35:59 +00:00

Update StoryController, fixes #2018

This commit is contained in:
Daniel Supernault 2020-02-17 00:00:33 -07:00
parent 5bcb43a673
commit 5ffa71dacd
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -108,16 +108,25 @@ class StoryController extends Controller
$profile = $request->user()->profile;
$following = $profile->following->pluck('id')->toArray();
$groupBy = config('database.default') == 'pgsql' ? 'id' : 'profile_id';
$stories = Story::with('profile')
->groupBy($groupBy)
->whereIn('profile_id', $following)
->where('expires_at', '>', now())
->orderByDesc('expires_at')
->take(9)
->get()
->map(function($s, $k) {
if(config('database.default') == 'pgsql') {
$db = Story::with('profile')
->whereIn('profile_id', $following)
->where('expires_at', '>', now())
->distinct('profile_id')
->take(9)
->get();
} else {
$db = Story::with('profile')
->whereIn('profile_id', $following)
->where('expires_at', '>', now())
->orderByDesc('expires_at')
->groupBy('profile_id')
->take(9)
->get();
}
$stories = $db->map(function($s, $k) {
return [
'id' => (string) $s->id,
'photo' => $s->profile->avatarUrl(),