Update AccountController
This commit is contained in:
parent
506208f545
commit
213fba725e
2 changed files with 433 additions and 512 deletions
|
@ -50,38 +50,7 @@ class InternalApiController extends Controller
|
|||
// deprecated
|
||||
public function discover(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);
|
||||
|
||||
$posts = Status::select('id', 'caption', 'profile_id')
|
||||
->whereHas('media')
|
||||
->whereIsNsfw(false)
|
||||
->whereVisibility('public')
|
||||
->whereNotIn('profile_id', $following)
|
||||
->with('media')
|
||||
->orderBy('created_at', 'desc')
|
||||
->take(21)
|
||||
->get();
|
||||
|
||||
$res = [
|
||||
'posts' => $posts->map(function($post) {
|
||||
return [
|
||||
'url' => $post->url(),
|
||||
'thumb' => $post->thumb(),
|
||||
];
|
||||
})
|
||||
];
|
||||
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
||||
return;
|
||||
}
|
||||
|
||||
public function discoverPosts(Request $request)
|
||||
|
@ -155,22 +124,9 @@ class InternalApiController extends Controller
|
|||
return response()->json(compact('msg', 'profile', 'thread'), 200, [], JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
public function notificationMarkAllRead(Request $request)
|
||||
{
|
||||
$profile = Auth::user()->profile;
|
||||
|
||||
$notifications = Notification::whereProfileId($profile->id)->get();
|
||||
foreach($notifications as $n) {
|
||||
$n->read_at = Carbon::now();
|
||||
$n->save();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function statusReplies(Request $request, int $id)
|
||||
{
|
||||
$parent = Status::findOrFail($id);
|
||||
$parent = Status::whereScope('public')->findOrFail($id);
|
||||
|
||||
$children = Status::whereInReplyToId($parent->id)
|
||||
->orderBy('created_at', 'desc')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue