2018-04-20 01:17:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Util\Webfinger;
|
|
|
|
|
|
|
|
use App\Util\Lexer\Nickname;
|
2024-03-02 11:21:04 +00:00
|
|
|
use App\Services\InstanceService;
|
2018-04-20 01:17:15 +00:00
|
|
|
|
2018-08-28 03:07:36 +00:00
|
|
|
class WebfingerUrl
|
|
|
|
{
|
2024-03-02 11:21:04 +00:00
|
|
|
public static function get($url)
|
|
|
|
{
|
|
|
|
$n = Nickname::normalizeProfileUrl($url);
|
|
|
|
if(!$n || !isset($n['domain'], $n['username'])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(in_array($n['domain'], InstanceService::getBannedDomains())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return 'https://' . $n['domain'] . '/.well-known/webfinger?resource=acct:' . $n['username'] . '@' . $n['domain'];
|
|
|
|
}
|
|
|
|
|
2018-08-28 03:07:36 +00:00
|
|
|
public static function generateWebfingerUrl($url)
|
|
|
|
{
|
|
|
|
$url = Nickname::normalizeProfileUrl($url);
|
|
|
|
$domain = $url['domain'];
|
|
|
|
$username = $url['username'];
|
2021-12-26 11:58:19 +00:00
|
|
|
$path = "https://{$domain}/.well-known/webfinger?resource=acct:{$username}@{$domain}";
|
2018-08-28 03:07:36 +00:00
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
}
|