mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Add ActivityPub Actor Transformer
This commit is contained in:
parent
e3914e94e8
commit
0f55fbacc4
1 changed files with 41 additions and 0 deletions
41
app/Transformer/ActivityPub/ProfileTransformer.php
Normal file
41
app/Transformer/ActivityPub/ProfileTransformer.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Transformer\ActivityPub;
|
||||
|
||||
use App\Profile;
|
||||
use League\Fractal;
|
||||
|
||||
class ProfileTransformer extends Fractal\TransformerAbstract
|
||||
{
|
||||
|
||||
public function transform(Profile $profile)
|
||||
{
|
||||
return [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => $profile->permalink(),
|
||||
'type' => 'Person',
|
||||
'following' => $profile->permalink('/following'),
|
||||
'followers' => $profile->permalink('/followers'),
|
||||
'inbox' => $profile->permalink('/inbox'),
|
||||
'outbox' => $profile->permalink('/outbox'),
|
||||
'featured' => $profile->permalink('/collections/featured'),
|
||||
'preferredUsername' => $profile->username,
|
||||
'name' => $profile->name,
|
||||
'summary' => $profile->bio,
|
||||
'url' => $profile->url(),
|
||||
'manuallyApprovesFollowers' => $profile->is_private,
|
||||
'follower_count' => $profile->followers()->count(),
|
||||
'following_count' => $profile->following()->count(),
|
||||
'publicKey' => [
|
||||
'id' => $profile->permalink() . '#main-key',
|
||||
'owner' => $profile->permalink(),
|
||||
'publicKeyPem' => $profile->public_key
|
||||
],
|
||||
'endpoints' => [
|
||||
'sharedInbox' => config('routes.api.sharedInbox')
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue