mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update Webfinger util, add avatar entity. Fixes #1629
This commit is contained in:
parent
5f5cb0616d
commit
bca2484994
1 changed files with 54 additions and 37 deletions
|
@ -11,6 +11,18 @@ class Webfinger
|
||||||
|
|
||||||
public function __construct($user)
|
public function __construct($user)
|
||||||
{
|
{
|
||||||
|
$avatar = $user ? $user->avatarUrl() : url('/storage/avatars/default.jpg');
|
||||||
|
$avatarPath = parse_url($avatar, PHP_URL_PATH);
|
||||||
|
$extension = pathinfo($avatarPath, PATHINFO_EXTENSION);
|
||||||
|
$mimeTypes = [
|
||||||
|
'jpg' => 'image/jpeg',
|
||||||
|
'jpeg' => 'image/jpeg',
|
||||||
|
'png' => 'image/png',
|
||||||
|
'gif' => 'image/gif',
|
||||||
|
'svg' => 'image/svg',
|
||||||
|
];
|
||||||
|
$avatarType = $mimeTypes[$extension] ?? 'application/octet-stream';
|
||||||
|
|
||||||
$this->subject = 'acct:'.$user->username.'@'.parse_url(config('app.url'), PHP_URL_HOST);
|
$this->subject = 'acct:'.$user->username.'@'.parse_url(config('app.url'), PHP_URL_HOST);
|
||||||
$this->aliases = [
|
$this->aliases = [
|
||||||
$user->url(),
|
$user->url(),
|
||||||
|
@ -32,6 +44,11 @@ class Webfinger
|
||||||
'type' => 'application/activity+json',
|
'type' => 'application/activity+json',
|
||||||
'href' => $user->permalink(),
|
'href' => $user->permalink(),
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'rel' => 'http://webfinger.net/rel/avatar',
|
||||||
|
'type' => $avatarType,
|
||||||
|
'href' => $avatar,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue