1
0
Fork 0

Add AccountMigration ActivityPub support

This commit is contained in:
Daniel Supernault 2023-08-07 23:59:10 -06:00
parent eab16e7fd8
commit 9378c65396
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 20 additions and 1 deletions

View File

@ -4,17 +4,26 @@ namespace App\Transformer\ActivityPub;
use App\Profile; use App\Profile;
use League\Fractal; use League\Fractal;
use App\Services\AccountService;
class ProfileTransformer extends Fractal\TransformerAbstract class ProfileTransformer extends Fractal\TransformerAbstract
{ {
public function transform(Profile $profile) public function transform(Profile $profile)
{ {
return [ $res = [
'@context' => [ '@context' => [
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
'https://www.w3.org/ns/activitystreams', 'https://www.w3.org/ns/activitystreams',
[ [
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'alsoKnownAs' => [
'@id' => 'as:alsoKnownAs',
'@type' => '@id'
],
'movedTo' => [
'@id' => 'as:movedTo',
'@type' => '@id'
]
], ],
], ],
'id' => $profile->permalink(), 'id' => $profile->permalink(),
@ -42,5 +51,15 @@ class ProfileTransformer extends Fractal\TransformerAbstract
'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->moved_to_profile_id) {
$res['movedTo'] = AccountService::get($profile->moved_to_profile_id)['url'];
}
return $res;
} }
} }