Update FederationController, increase webfinger cache ttl from 12 hours to 14 days

This commit is contained in:
Daniel Supernault 2021-12-28 23:49:56 -07:00
parent 8db6a79de9
commit 745c35807c
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -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','*');