From 745c35807cf83e7aadcb18037f5e85a4fbb27049 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 28 Dec 2021 23:49:56 -0700 Subject: [PATCH] Update FederationController, increase webfinger cache ttl from 12 hours to 14 days --- app/Http/Controllers/FederationController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index bc90737d8..19063c105 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -58,17 +58,17 @@ class FederationController extends Controller if($cached = Cache::get($key)) { return response()->json($cached, 200, [], JSON_UNESCAPED_SLASHES); } + $domain = config('pixelfed.domain.app'); + abort_if(strpos($resource, $domain) == false, 404); $parsed = Nickname::normalizeProfileUrl($resource); - if(empty($parsed) || $parsed['domain'] !== config('pixelfed.domain.app')) { + if(empty($parsed) || $parsed['domain'] !== $domain) { abort(404); } $username = $parsed['username']; $profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail(); - if($profile->status != null) { - return ProfileController::accountCheck($profile); - } + abort_if($profile->status != null, 404); $webfinger = (new Webfinger($profile))->generate(); - Cache::put($key, $webfinger, 43200); + Cache::put($key, $webfinger, 1209600); return response()->json($webfinger, 200, [], JSON_UNESCAPED_SLASHES) ->header('Access-Control-Allow-Origin','*');