|
@@ -296,25 +296,60 @@ class PublicApiController extends Controller
|
|
->whereIn('filter_type', ['mute', 'block'])
|
|
->whereIn('filter_type', ['mute', 'block'])
|
|
->pluck('filterable_id')->toArray();
|
|
->pluck('filterable_id')->toArray();
|
|
|
|
|
|
- if(PublicTimelineService::count() == 0) {
|
|
|
|
- PublicTimelineService::warmCache(true, 400);
|
|
|
|
- }
|
|
|
|
|
|
+ if($min || $max) {
|
|
|
|
+ $dir = $min ? '>' : '<';
|
|
|
|
+ $id = $min ?? $max;
|
|
|
|
+ $timeline = Status::select(
|
|
|
|
+ 'id',
|
|
|
|
+ 'profile_id',
|
|
|
|
+ 'type',
|
|
|
|
+ 'scope',
|
|
|
|
+ 'local'
|
|
|
|
+ )->where('id', $dir, $id)
|
|
|
|
+ ->whereIn('type', ['text', 'photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
|
|
|
+ ->whereNotIn('profile_id', $filtered)
|
|
|
|
+ ->whereLocal(true)
|
|
|
|
+ ->whereScope('public')
|
|
|
|
+ ->orderBy('id', 'desc')
|
|
|
|
+ ->limit($limit)
|
|
|
|
+ ->get()
|
|
|
|
+ ->map(function($s) use ($user) {
|
|
|
|
+ $status = StatusService::get($s->id);
|
|
|
|
+ $status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id);
|
|
|
|
+ return $status;
|
|
|
|
+ });
|
|
|
|
+ $res = $timeline->toArray();
|
|
|
|
+ } else {
|
|
|
|
+ $timeline = Status::select(
|
|
|
|
+ 'id',
|
|
|
|
+ 'uri',
|
|
|
|
+ 'caption',
|
|
|
|
+ 'rendered',
|
|
|
|
+ 'profile_id',
|
|
|
|
+ 'type',
|
|
|
|
+ 'in_reply_to_id',
|
|
|
|
+ 'reblog_of_id',
|
|
|
|
+ 'is_nsfw',
|
|
|
|
+ 'scope',
|
|
|
|
+ 'local',
|
|
|
|
+ 'reply_count',
|
|
|
|
+ 'comments_disabled',
|
|
|
|
+ 'created_at',
|
|
|
|
+ 'place_id',
|
|
|
|
+ 'likes_count',
|
|
|
|
+ 'reblogs_count',
|
|
|
|
+ 'updated_at'
|
|
|
|
+ )->whereIn('type', ['text', 'photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
|
|
|
|
+ ->whereNotIn('profile_id', $filtered)
|
|
|
|
+ ->with('profile', 'hashtags', 'mentions')
|
|
|
|
+ ->whereLocal(true)
|
|
|
|
+ ->whereScope('public')
|
|
|
|
+ ->orderBy('id', 'desc')
|
|
|
|
+ ->simplePaginate($limit);
|
|
|
|
|
|
- if ($max) {
|
|
|
|
- $feed = PublicTimelineService::getRankedMaxId($max, $limit);
|
|
|
|
- } else if ($min) {
|
|
|
|
- $feed = PublicTimelineService::getRankedMinId($min, $limit);
|
|
|
|
- } else {
|
|
|
|
- $feed = PublicTimelineService::get(0, $limit);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $res = collect($feed)
|
|
|
|
- ->map(function($k) use($user) {
|
|
|
|
- $status = StatusService::get($k);
|
|
|
|
- $status['favourited'] = (bool) LikeService::liked($user->profile_id, $k);
|
|
|
|
- return $status;
|
|
|
|
- })
|
|
|
|
- ->toArray();
|
|
|
|
|
|
+ $fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer());
|
|
|
|
+ $res = $this->fractal->createData($fractal)->toArray();
|
|
|
|
+ }
|
|
|
|
|
|
return response()->json($res);
|
|
return response()->json($res);
|
|
}
|
|
}
|