mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update WebfingerService
This commit is contained in:
parent
492b92140a
commit
26b5b42b86
1 changed files with 14 additions and 12 deletions
|
@ -28,13 +28,17 @@ class WebfingerService
|
|||
return [];
|
||||
}
|
||||
|
||||
$res = Http::retry(3, 100)
|
||||
->acceptJson()
|
||||
->withHeaders([
|
||||
'User-Agent' => '(Pixelfed/' . config('pixelfed.version') . '; +' . config('app.url') . ')'
|
||||
])
|
||||
->timeout(20)
|
||||
->get($url);
|
||||
try {
|
||||
$res = Http::retry(3, 100)
|
||||
->acceptJson()
|
||||
->withHeaders([
|
||||
'User-Agent' => '(Pixelfed/' . config('pixelfed.version') . '; +' . config('app.url') . ')'
|
||||
])
|
||||
->timeout(20)
|
||||
->get($url);
|
||||
} catch (\Illuminate\Http\Client\ConnectionException $e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(!$res->successful()) {
|
||||
return [];
|
||||
|
@ -48,11 +52,9 @@ class WebfingerService
|
|||
$link = collect($webfinger['links'])
|
||||
->filter(function($link) {
|
||||
return $link &&
|
||||
isset($link['rel']) &&
|
||||
isset($link['type']) &&
|
||||
isset($link['href']) &&
|
||||
$link['rel'] == 'self' &&
|
||||
$link['type'] == 'application/activity+json' || $link['type'] == 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
|
||||
isset($link['rel'], $link['type'], $link['href']) &&
|
||||
$link['rel'] === 'self' &&
|
||||
in_array($link['type'], ['application/activity+json','application/ld+json; profile="https://www.w3.org/ns/activitystreams"']);
|
||||
})
|
||||
->pluck('href')
|
||||
->first();
|
||||
|
|
Loading…
Reference in a new issue