mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Update AP Profile Transformer, add suspended
attribute
This commit is contained in:
parent
15ad69f76e
commit
25f3fa06af
1 changed files with 56 additions and 51 deletions
|
@ -3,8 +3,8 @@
|
|||
namespace App\Transformer\ActivityPub;
|
||||
|
||||
use App\Profile;
|
||||
use League\Fractal;
|
||||
use App\Services\AccountService;
|
||||
use League\Fractal;
|
||||
|
||||
class ProfileTransformer extends Fractal\TransformerAbstract
|
||||
{
|
||||
|
@ -19,13 +19,14 @@ class ProfileTransformer extends Fractal\TransformerAbstract
|
|||
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
||||
'alsoKnownAs' => [
|
||||
'@id' => 'as:alsoKnownAs',
|
||||
'@type' => '@id'
|
||||
'@type' => '@id',
|
||||
],
|
||||
'movedTo' => [
|
||||
'@id' => 'as:movedTo',
|
||||
'@type' => '@id'
|
||||
'@type' => '@id',
|
||||
],
|
||||
'indexable' => 'toot:indexable',
|
||||
'suspended' => 'toot:suspended',
|
||||
],
|
||||
],
|
||||
'id' => $profile->permalink(),
|
||||
|
@ -40,7 +41,7 @@ class ProfileTransformer extends Fractal\TransformerAbstract
|
|||
'url' => $profile->url(),
|
||||
'manuallyApprovesFollowers' => (bool) $profile->is_private,
|
||||
'indexable' => (bool) $profile->indexable,
|
||||
'published' => $profile->created_at->format('Y-m-d') . 'T00:00:00Z',
|
||||
'published' => $profile->created_at->format('Y-m-d').'T00:00:00Z',
|
||||
'publicKey' => [
|
||||
'id' => $profile->permalink().'#main-key',
|
||||
'owner' => $profile->permalink(),
|
||||
|
@ -52,17 +53,21 @@ class ProfileTransformer extends Fractal\TransformerAbstract
|
|||
'url' => $profile->avatarUrl(),
|
||||
],
|
||||
'endpoints' => [
|
||||
'sharedInbox' => config('app.url') . '/f/inbox'
|
||||
]
|
||||
'sharedInbox' => config('app.url').'/f/inbox',
|
||||
],
|
||||
];
|
||||
|
||||
if($profile->aliases->count()) {
|
||||
$res['alsoKnownAs'] = $profile->aliases->map(fn($alias) => $alias->uri);
|
||||
if ($profile->status === 'delete' || $profile->deleted_at != null) {
|
||||
$res['suspended'] = true;
|
||||
} else {
|
||||
if ($profile->aliases->count()) {
|
||||
$res['alsoKnownAs'] = $profile->aliases->map(fn ($alias) => $alias->uri);
|
||||
}
|
||||
|
||||
if($profile->moved_to_profile_id) {
|
||||
if ($profile->moved_to_profile_id) {
|
||||
$res['movedTo'] = AccountService::get($profile->moved_to_profile_id)['url'];
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue