mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 10:34:31 +00:00
31 lines
858 B
PHP
31 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;
|
|
}
|
|
}
|