mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update Webfinger class
This commit is contained in:
parent
9327d50c28
commit
91062b1f55
1 changed files with 37 additions and 68 deletions
|
@ -4,74 +4,43 @@ 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 __construct($user)
|
||||
{
|
||||
$this->subject = 'acct:'.$user->username.'@'.parse_url(config('app.url'), PHP_URL_HOST);
|
||||
$this->aliases = [
|
||||
$user->url(),
|
||||
$user->permalink(),
|
||||
];
|
||||
$this->links = [
|
||||
[
|
||||
'rel' => 'http://webfinger.net/rel/profile-page',
|
||||
'type' => 'text/html',
|
||||
'href' => $user->url(),
|
||||
],
|
||||
[
|
||||
'rel' => 'http://schemas.google.com/g/2010#updates-from',
|
||||
'type' => 'application/atom+xml',
|
||||
'href' => $user->permalink('.atom'),
|
||||
],
|
||||
[
|
||||
'rel' => 'self',
|
||||
'type' => 'application/activity+json',
|
||||
'href' => $user->permalink(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
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->user->url(),
|
||||
$this->user->permalink(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function generateLinks()
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
$this->links = [
|
||||
[
|
||||
'rel' => 'http://webfinger.net/rel/profile-page',
|
||||
'type' => 'text/html',
|
||||
'href' => $user->url(),
|
||||
],
|
||||
[
|
||||
'rel' => 'http://schemas.google.com/g/2010#updates-from',
|
||||
'type' => 'application/atom+xml',
|
||||
'href' => $user->permalink('.atom'),
|
||||
],
|
||||
[
|
||||
'rel' => 'self',
|
||||
'type' => 'application/activity+json',
|
||||
'href' => $user->permalink(),
|
||||
],
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function generate()
|
||||
{
|
||||
$this->setSubject();
|
||||
$this->generateAliases();
|
||||
$this->generateLinks();
|
||||
|
||||
return [
|
||||
'subject' => $this->subject,
|
||||
'aliases' => $this->aliases,
|
||||
'links' => $this->links,
|
||||
];
|
||||
}
|
||||
public function generate()
|
||||
{
|
||||
return [
|
||||
'subject' => $this->subject,
|
||||
'aliases' => $this->aliases,
|
||||
'links' => $this->links,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue