1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-27 02:06:52 +00:00
pixelfed/app/Util/Webfinger/WebfingerUrl.php
2024-03-02 04:21:04 -07:00

30 lines
858 B
PHP

<?php
namespace App\Util\Webfinger;
use App\Util\Lexer\Nickname;
use App\Services\InstanceService;
class WebfingerUrl
{
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'];
}
public static function generateWebfingerUrl($url)
{
$url = Nickname::normalizeProfileUrl($url);
$domain = $url['domain'];
$username = $url['username'];
$path = "https://{$domain}/.well-known/webfinger?resource=acct:{$username}@{$domain}";
return $path;
}
}