1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Update Webfinger class

This commit is contained in:
Daniel Supernault 2019-06-27 01:01:20 -06:00
parent 9327d50c28
commit 91062b1f55
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -4,43 +4,18 @@ namespace App\Util\Webfinger;
class Webfinger class Webfinger
{ {
public $user; protected $user;
public $subject; protected $subject;
public $aliases; protected $aliases;
public $links; protected $links;
public function __construct($user) public function __construct($user)
{ {
$this->user = $user; $this->subject = 'acct:'.$user->username.'@'.parse_url(config('app.url'), PHP_URL_HOST);
$this->subject = '';
$this->aliases = [];
$this->links = [];
}
public function setSubject()
{
$host = parse_url(config('app.url'), PHP_URL_HOST);
$username = $this->user->username;
$this->subject = 'acct:'.$username.'@'.$host;
return $this;
}
public function generateAliases()
{
$this->aliases = [ $this->aliases = [
$this->user->url(), $user->url(),
$this->user->permalink(), $user->permalink(),
]; ];
return $this;
}
public function generateLinks()
{
$user = $this->user;
$this->links = [ $this->links = [
[ [
'rel' => 'http://webfinger.net/rel/profile-page', 'rel' => 'http://webfinger.net/rel/profile-page',
@ -58,16 +33,10 @@ class Webfinger
'href' => $user->permalink(), 'href' => $user->permalink(),
], ],
]; ];
return $this;
} }
public function generate() public function generate()
{ {
$this->setSubject();
$this->generateAliases();
$this->generateLinks();
return [ return [
'subject' => $this->subject, 'subject' => $this->subject,
'aliases' => $this->aliases, 'aliases' => $this->aliases,