mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 17:53:16 +00:00
Update BaseApiController, cache verify_credentials endpoint
This commit is contained in:
parent
080516a7eb
commit
066f1a9282
5 changed files with 13 additions and 4 deletions
|
@ -309,9 +309,13 @@ class BaseApiController extends Controller
|
||||||
|
|
||||||
public function verifyCredentials(Request $request)
|
public function verifyCredentials(Request $request)
|
||||||
{
|
{
|
||||||
$profile = Auth::user()->profile;
|
$id = Auth::id();
|
||||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = Cache::remember('user:account:id:'.$id, now()->addHours(6), function() use($id) {
|
||||||
|
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
|
||||||
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||||
|
return $this->fractal->createData($resource)->toArray();
|
||||||
|
});
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ class AvatarController extends Controller
|
||||||
$avatar->save();
|
$avatar->save();
|
||||||
|
|
||||||
Cache::forget("avatar:{$profile->id}");
|
Cache::forget("avatar:{$profile->id}");
|
||||||
|
Cache::forget('user:account:id:'.$user->id);
|
||||||
AvatarOptimize::dispatch($user->profile, $currentAvatar);
|
AvatarOptimize::dispatch($user->profile, $currentAvatar);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,5 +76,7 @@ class FollowerController extends Controller
|
||||||
Cache::forget('profile:following:'.$user->id);
|
Cache::forget('profile:following:'.$user->id);
|
||||||
Cache::forget('profile:followers:'.$user->id);
|
Cache::forget('profile:followers:'.$user->id);
|
||||||
Cache::forget('api:local:exp:rec:'.$user->id);
|
Cache::forget('api:local:exp:rec:'.$user->id);
|
||||||
|
Cache::forget('user:account:id:'.$target->user_id);
|
||||||
|
Cache::forget('user:account:id:'.$user->user_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,7 +400,7 @@ class InternalApiController extends Controller
|
||||||
$status->save();
|
$status->save();
|
||||||
|
|
||||||
NewStatusPipeline::dispatch($status);
|
NewStatusPipeline::dispatch($status);
|
||||||
|
Cache::forget('user:account:id:'.$profile->user_id);
|
||||||
return $status->url();
|
return $status->url();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ use App\User;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
use App\Util\Lexer\PrettyNumber;
|
use App\Util\Lexer\PrettyNumber;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Cache;
|
||||||
use DB;
|
use DB;
|
||||||
use Purify;
|
use Purify;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -101,6 +102,7 @@ trait HomeSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($changes === true) {
|
if ($changes === true) {
|
||||||
|
Cache::forget('user:account:id:'.$user->id);
|
||||||
$user->save();
|
$user->save();
|
||||||
$profile->save();
|
$profile->save();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue