mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-17 20:11:27 +00:00
Lint
This commit is contained in:
parent
21da2b642c
commit
1210bf7502
1 changed files with 22 additions and 22 deletions
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Http\Client\RequestException;
|
|
||||||
use Illuminate\Http\Client\ConnectionException;
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Http\Client\RequestException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
class NodeinfoService
|
class NodeinfoService
|
||||||
{
|
{
|
||||||
|
@ -18,8 +17,8 @@ class NodeinfoService
|
||||||
'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})",
|
'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})",
|
||||||
];
|
];
|
||||||
|
|
||||||
$url = 'https://' . $domain;
|
$url = 'https://'.$domain;
|
||||||
$wk = $url . '/.well-known/nodeinfo';
|
$wk = $url.'/.well-known/nodeinfo';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = Http::withOptions([
|
$res = Http::withOptions([
|
||||||
|
@ -36,18 +35,18 @@ class NodeinfoService
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$res) {
|
if (! $res) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = $res->json();
|
$json = $res->json();
|
||||||
|
|
||||||
if( !isset($json['links'])) {
|
if (! isset($json['links'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_array($json['links'])) {
|
if (is_array($json['links'])) {
|
||||||
if(isset($json['links']['href'])) {
|
if (isset($json['links']['href'])) {
|
||||||
$href = $json['links']['href'];
|
$href = $json['links']['href'];
|
||||||
} else {
|
} else {
|
||||||
$href = $json['links'][0]['href'];
|
$href = $json['links'][0]['href'];
|
||||||
|
@ -59,7 +58,7 @@ class NodeinfoService
|
||||||
$domain = parse_url($url, PHP_URL_HOST);
|
$domain = parse_url($url, PHP_URL_HOST);
|
||||||
$hrefDomain = parse_url($href, PHP_URL_HOST);
|
$hrefDomain = parse_url($href, PHP_URL_HOST);
|
||||||
|
|
||||||
if($domain !== $hrefDomain) {
|
if ($domain !== $hrefDomain) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +76,7 @@ class NodeinfoService
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res->json();
|
return $res->json();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue