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
{
public $user;
public $subject;
public $aliases;
public $links;
protected $user;
protected $subject;
protected $aliases;
protected $links;
public function __construct($user)
{
$this->user = $user;
$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->subject = 'acct:'.$user->username.'@'.parse_url(config('app.url'), PHP_URL_HOST);
$this->aliases = [
$this->user->url(),
$this->user->permalink(),
$user->url(),
$user->permalink(),
];
return $this;
}
public function generateLinks()
{
$user = $this->user;
$this->links = [
[
'rel' => 'http://webfinger.net/rel/profile-page',
@ -58,16 +33,10 @@ class Webfinger
'href' => $user->permalink(),
],
];
return $this;
}
public function generate()
{
$this->setSubject();
$this->generateAliases();
$this->generateLinks();
return [
'subject' => $this->subject,
'aliases' => $this->aliases,