forked from mirror/pixelfed
commit
3326e377a7
|
@ -18,6 +18,7 @@ use App\{
|
||||||
Notification,
|
Notification,
|
||||||
Profile,
|
Profile,
|
||||||
Status,
|
Status,
|
||||||
|
User,
|
||||||
UserFilter,
|
UserFilter,
|
||||||
};
|
};
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
|
@ -112,20 +113,24 @@ class ApiV1Controller extends Controller
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
$id = $request->user()->id;
|
$id = $request->user()->id;
|
||||||
|
$key = 'user:last_active_at:id:'.$id;
|
||||||
//$res = Cache::remember('mastoapi:user:account:id:'.$id, now()->addHours(6), function() use($id) {
|
$ttl = now()->addMinutes(5);
|
||||||
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
|
Cache::remember($key, $ttl, function() use($id) {
|
||||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
$user = User::findOrFail($id);
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$user->last_active_at = now();
|
||||||
$res['source'] = [
|
$user->save();
|
||||||
'privacy' => $profile->is_private ? 'private' : 'public',
|
return;
|
||||||
'sensitive' => $profile->cw ? true : false,
|
});
|
||||||
'language' => null,
|
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
|
||||||
'note' => '',
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||||
'fields' => []
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
];
|
$res['source'] = [
|
||||||
// return $res;
|
'privacy' => $profile->is_private ? 'private' : 'public',
|
||||||
// });
|
'sensitive' => $profile->cw ? true : false,
|
||||||
|
'language' => null,
|
||||||
|
'note' => '',
|
||||||
|
'fields' => []
|
||||||
|
];
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,6 +322,13 @@ class BaseApiController extends Controller
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
return redirect('/login');
|
return redirect('/login');
|
||||||
}
|
}
|
||||||
|
$key = 'user:last_active_at:id:'.$user->id;
|
||||||
|
$ttl = now()->addMinutes(5);
|
||||||
|
Cache::remember($key, $ttl, function() use($user) {
|
||||||
|
$user->last_active_at = now();
|
||||||
|
$user->save();
|
||||||
|
return;
|
||||||
|
});
|
||||||
$resource = new Fractal\Resource\Item($user->profile, new AccountTransformer());
|
$resource = new Fractal\Resource\Item($user->profile, new AccountTransformer());
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
|
|
Loading…
Reference in New Issue