pixelfed/app/Transformer/ActivityPub/ProfileTransformer.php

54 wiersze
1.7 KiB
PHP
Czysty Zwykły widok Historia

2018-05-20 03:18:06 +00:00
<?php
namespace App\Transformer\ActivityPub;
use App\Profile;
use League\Fractal;
class ProfileTransformer extends Fractal\TransformerAbstract
{
public function transform(Profile $profile)
{
return [
2018-08-14 00:18:20 +00:00
'@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
2018-08-14 03:29:40 +00:00
"featured" => [
"https://pixelfed.org/ns#featured" => ["@type" => "@id"],
]
2018-08-14 00:18:20 +00:00
]
],
2018-05-20 03:18:06 +00:00
'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(),
2018-08-14 00:18:20 +00:00
'manuallyApprovesFollowers' => (bool) $profile->is_private,
// 'follower_count' => $profile->followers()->count(),
// 'following_count' => $profile->following()->count(),
2018-05-20 03:18:06 +00:00
'publicKey' => [
'id' => $profile->permalink() . '#main-key',
'owner' => $profile->permalink(),
'publicKeyPem' => $profile->public_key
],
'endpoints' => [
'sharedInbox' => config('routes.api.sharedInbox')
],
2018-08-14 01:31:18 +00:00
'icon' => [
'type' => 'Image',
'mediaType' => 'image/jpeg',
'url' => $profile->avatarUrl()
]
2018-05-20 03:18:06 +00:00
];
}
}