1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 08:14:10 +00:00

Update WebfingerService

This commit is contained in:
Daniel Supernault 2022-12-28 19:42:42 -07:00
parent 492b92140a
commit 26b5b42b86
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -28,6 +28,7 @@ class WebfingerService
return []; return [];
} }
try {
$res = Http::retry(3, 100) $res = Http::retry(3, 100)
->acceptJson() ->acceptJson()
->withHeaders([ ->withHeaders([
@ -35,6 +36,9 @@ class WebfingerService
]) ])
->timeout(20) ->timeout(20)
->get($url); ->get($url);
} catch (\Illuminate\Http\Client\ConnectionException $e) {
return [];
}
if(!$res->successful()) { if(!$res->successful()) {
return []; return [];
@ -48,11 +52,9 @@ class WebfingerService
$link = collect($webfinger['links']) $link = collect($webfinger['links'])
->filter(function($link) { ->filter(function($link) {
return $link && return $link &&
isset($link['rel']) && isset($link['rel'], $link['type'], $link['href']) &&
isset($link['type']) && $link['rel'] === 'self' &&
isset($link['href']) && in_array($link['type'], ['application/activity+json','application/ld+json; profile="https://www.w3.org/ns/activitystreams"']);
$link['rel'] == 'self' &&
$link['type'] == 'application/activity+json' || $link['type'] == 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
}) })
->pluck('href') ->pluck('href')
->first(); ->first();