Update InternalApiController

This commit is contained in:
Daniel Supernault 2019-05-22 22:07:44 -06:00
parent d15e8f12bd
commit 842adcda24
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -63,17 +63,6 @@ class InternalApiController extends Controller
});
$following = array_merge($following, $filters);
$people = Profile::select('id', 'name', 'username')
->with('avatar')
->whereNull('status')
->orderByRaw('rand()')
->whereHas('statuses')
->whereNull('domain')
->whereNotIn('id', $following)
->whereIsPrivate(false)
->take(3)
->get();
$posts = Status::select('id', 'caption', 'profile_id')
->whereHas('media')
->whereIsNsfw(false)
@ -85,15 +74,6 @@ class InternalApiController extends Controller
->get();
$res = [
'people' => $people->map(function($profile) {
return [
'id' => $profile->id,
'avatar' => $profile->avatarUrl(),
'name' => $profile->name,
'username' => $profile->username,
'url' => $profile->url(),
];
}),
'posts' => $posts->map(function($post) {
return [
'url' => $post->url(),
@ -104,45 +84,6 @@ class InternalApiController extends Controller
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
}
public function discoverPeople(Request $request)
{
$profile = Auth::user()->profile;
$pid = $profile->id;
$following = Cache::remember('feature:discover:following:'.$pid, now()->addMinutes(60), function() use ($pid) {
return Follower::whereProfileId($pid)->pluck('following_id')->toArray();
});
$filters = Cache::remember("user:filter:list:$pid", now()->addMinutes(60), function() use($pid) {
return UserFilter::whereUserId($pid)
->whereFilterableType('App\Profile')
->whereIn('filter_type', ['mute', 'block'])
->pluck('filterable_id')->toArray();
});
$following = array_merge($following, $filters);
$people = Profile::select('id', 'name', 'username')
->with('avatar')
->orderByRaw('rand()')
->whereHas('statuses')
->whereNull('domain')
->whereNotIn('id', $following)
->whereIsPrivate(false)
->take(3)
->get();
$res = [
'people' => $people->map(function($profile) {
return [
'id' => $profile->id,
'avatar' => $profile->avatarUrl(),
'name' => $profile->name,
'username' => $profile->username,
'url' => $profile->url(),
];
})
];
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
}
public function discoverPosts(Request $request)
{
$profile = Auth::user()->profile;