mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update PublicApiController
This commit is contained in:
parent
73226360fc
commit
0db82ff2dd
1 changed files with 33 additions and 10 deletions
|
@ -486,7 +486,7 @@ class PublicApiController extends Controller
|
||||||
if($min || $max) {
|
if($min || $max) {
|
||||||
$dir = $min ? '>' : '<';
|
$dir = $min ? '>' : '<';
|
||||||
$id = $min ?? $max;
|
$id = $min ?? $max;
|
||||||
$timeline = Status::select(
|
return Status::select(
|
||||||
'id',
|
'id',
|
||||||
'uri',
|
'uri',
|
||||||
'caption',
|
'caption',
|
||||||
|
@ -513,13 +513,26 @@ class PublicApiController extends Controller
|
||||||
->with('profile', 'hashtags', 'mentions')
|
->with('profile', 'hashtags', 'mentions')
|
||||||
->where('id', $dir, $id)
|
->where('id', $dir, $id)
|
||||||
->whereIn('profile_id', $following)
|
->whereIn('profile_id', $following)
|
||||||
->whereNotIn('profile_id', $filtered)
|
|
||||||
->whereIn('visibility',['public', 'unlisted', 'private'])
|
->whereIn('visibility',['public', 'unlisted', 'private'])
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
->get();
|
->get()
|
||||||
|
->map(function($s) use ($user) {
|
||||||
|
$status = StatusService::get($s->id);
|
||||||
|
if(!$status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id);
|
||||||
|
$status['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $s->id);
|
||||||
|
return $status;
|
||||||
|
})
|
||||||
|
->filter(function($s) use($filtered) {
|
||||||
|
return $s && in_array($s['account']['id'], $filtered) == false;
|
||||||
|
})
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
} else {
|
} else {
|
||||||
$timeline = Status::select(
|
return Status::select(
|
||||||
'id',
|
'id',
|
||||||
'uri',
|
'uri',
|
||||||
'caption',
|
'caption',
|
||||||
|
@ -545,15 +558,25 @@ class PublicApiController extends Controller
|
||||||
})
|
})
|
||||||
->with('profile', 'hashtags', 'mentions')
|
->with('profile', 'hashtags', 'mentions')
|
||||||
->whereIn('profile_id', $following)
|
->whereIn('profile_id', $following)
|
||||||
->whereNotIn('profile_id', $filtered)
|
|
||||||
->whereIn('visibility',['public', 'unlisted', 'private'])
|
->whereIn('visibility',['public', 'unlisted', 'private'])
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->simplePaginate($limit);
|
->limit($limit)
|
||||||
|
->get()
|
||||||
|
->map(function($s) use ($user) {
|
||||||
|
$status = StatusService::get($s->id);
|
||||||
|
if(!$status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id);
|
||||||
|
$status['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $s->id);
|
||||||
|
return $status;
|
||||||
|
})
|
||||||
|
->filter(function($s) use($filtered) {
|
||||||
|
return $s && in_array($s['account']['id'], $filtered) == false;
|
||||||
|
})
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
$fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer());
|
|
||||||
$res = $this->fractal->createData($fractal)->toArray();
|
|
||||||
return response()->json($res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function networkTimelineApi(Request $request)
|
public function networkTimelineApi(Request $request)
|
||||||
|
|
Loading…
Reference in a new issue