mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-18 19:13:17 +00:00
30 lines
858 B
PHP
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;
|
|
}
|
|
}
|