mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update ApiV1Controller, use ProfileService for verify_credentials
This commit is contained in:
parent
f67c67bce1
commit
352aa57346
1 changed files with 5 additions and 16 deletions
|
@ -53,6 +53,7 @@ use App\Services\{
|
||||||
NotificationService,
|
NotificationService,
|
||||||
MediaPathService,
|
MediaPathService,
|
||||||
PublicTimelineService,
|
PublicTimelineService,
|
||||||
|
ProfileService,
|
||||||
SearchApiV2Service,
|
SearchApiV2Service,
|
||||||
StatusService,
|
StatusService,
|
||||||
MediaBlocklistService
|
MediaBlocklistService
|
||||||
|
@ -118,25 +119,13 @@ class ApiV1Controller extends Controller
|
||||||
public function verifyCredentials(Request $request)
|
public function verifyCredentials(Request $request)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
$id = $request->user()->id;
|
$id = $request->user()->profile_id;
|
||||||
|
|
||||||
if($request->user()->last_active_at) {
|
$res = ProfileService::get($id);
|
||||||
$key = 'user:last_active_at:id:'.$id;
|
|
||||||
$ttl = now()->addMinutes(5);
|
|
||||||
Cache::remember($key, $ttl, function() use($id) {
|
|
||||||
$user = User::findOrFail($id);
|
|
||||||
$user->last_active_at = now();
|
|
||||||
$user->save();
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
|
|
||||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
|
||||||
$res['source'] = [
|
$res['source'] = [
|
||||||
'privacy' => $profile->is_private ? 'private' : 'public',
|
'privacy' => $res['locked'] ? 'private' : 'public',
|
||||||
'sensitive' => $profile->cw ? true : false,
|
'sensitive' => false,
|
||||||
'language' => null,
|
'language' => null,
|
||||||
'note' => '',
|
'note' => '',
|
||||||
'fields' => []
|
'fields' => []
|
||||||
|
|
Loading…
Reference in a new issue