Update internal apis

This commit is contained in:
Daniel Supernault 2020-03-24 23:00:02 -06:00
parent 869b4ff727
commit e6190b896b
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -239,39 +239,6 @@ class PublicApiController extends Controller
$max = $request->input('max_id');
$limit = $request->input('limit') ?? 3;
$private = Cache::remember('profiles:private', now()->addMinutes(1440), function() {
return Profile::whereIsPrivate(true)
->orWhere('unlisted', true)
->orWhere('status', '!=', null)
->pluck('id')
->toArray();
});
// if(Auth::check()) {
// // $pid = Auth::user()->profile->id;
// // $filters = UserFilter::whereUserId($pid)
// // ->whereFilterableType('App\Profile')
// // ->whereIn('filter_type', ['mute', 'block'])
// // ->pluck('filterable_id')->toArray();
// // $filtered = array_merge($private->toArray(), $filters);
// $filtered = UserFilterService::filters(Auth::user()->profile_id);
// } else {
// // $filtered = $private->toArray();
// $filtered = [];
// }
$filtered = Auth::check() ? array_merge($private, UserFilterService::filters(Auth::user()->profile_id)) : [];
// if($max == 0) {
// $res = PublicTimelineService::count();
// if($res == 0) {
// PublicTimelineService::warmCache();
// $res = PublicTimelineService::get(0,4);
// } else {
// $res = PublicTimelineService::get(0,4);
// }
// return response()->json($res);
// }
if($min || $max) {
$dir = $min ? '>' : '<';
$id = $min ?? $max;
@ -295,15 +262,12 @@ class PublicApiController extends Controller
'created_at',
'updated_at'
)->where('id', $dir, $id)
->with('profile', 'hashtags', 'mentions')
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->whereLocal(true)
->whereNotIn('profile_id', $filtered)
->whereVisibility('public')
->orderBy('created_at', 'desc')
->limit($limit)
->get();
//->toSql();
} else {
$timeline = Status::select(
'id',
@ -327,11 +291,9 @@ class PublicApiController extends Controller
)->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->with('profile', 'hashtags', 'mentions')
->whereLocal(true)
->whereNotIn('profile_id', $filtered)
->whereVisibility('public')
->orderBy('created_at', 'desc')
->simplePaginate($limit);
//->toSql();
}
$fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer());
@ -594,8 +556,6 @@ class PublicApiController extends Controller
'updated_at'
)->whereProfileId($profile->id)
->whereIn('type', $scope)
->whereLocal(true)
->whereNull('uri')
->where('id', $dir, $id)
->whereIn('visibility', $visibility)
->latest()