1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-24 16:53:17 +00:00
pixelfed/app/Transformer/ActivityPub/StatusTransformer.php

60 lines
1.8 KiB
PHP
Raw Normal View History

2018-08-14 04:18:53 +00:00
<?php
namespace App\Transformer\ActivityPub;
2018-08-28 03:07:36 +00:00
use App\Status;
2018-08-14 04:18:53 +00:00
use League\Fractal;
class StatusTransformer extends Fractal\TransformerAbstract
{
2018-08-28 03:07:36 +00:00
public function transform(Status $status)
{
return [
2018-08-14 04:18:53 +00:00
'@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
2018-08-28 03:07:36 +00:00
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'featured' => [
'https://pixelfed.org/ns#featured' => ['@type' => '@id'],
],
],
2018-08-14 04:18:53 +00:00
],
'id' => $status->url(),
// TODO: handle other types
'type' => 'Note',
// XXX: CW Title
2018-08-28 03:07:36 +00:00
'summary' => null,
'content' => $status->rendered ?? $status->caption,
2018-08-14 04:18:53 +00:00
'inReplyTo' => null,
// TODO: fix date format
2018-08-28 03:07:36 +00:00
'published' => $status->created_at->toAtomString(),
'url' => $status->url(),
2018-08-14 04:18:53 +00:00
'attributedTo' => $status->profile->permalink(),
2018-08-28 03:07:36 +00:00
'to' => [
2018-08-14 04:18:53 +00:00
// TODO: handle proper scope
2018-08-28 03:07:36 +00:00
'https://www.w3.org/ns/activitystreams#Public',
2018-08-14 04:18:53 +00:00
],
'cc' => [
// TODO: add cc's
$status->profile->permalink('/followers'),
],
2018-08-28 03:07:36 +00:00
'sensitive' => (bool) $status->is_nsfw,
'atomUri' => $status->url(),
2018-08-14 04:18:53 +00:00
'inReplyToAtomUri' => null,
2018-08-28 03:07:36 +00:00
'attachment' => $status->media->map(function ($media) {
return [
'type' => 'Document',
2018-08-14 04:18:53 +00:00
'mediaType' => $media->mime,
2018-08-28 03:07:36 +00:00
'url' => $media->url(),
'name' => $media->caption
2018-08-14 04:18:53 +00:00
];
}),
2018-08-28 03:07:36 +00:00
'tag' => [],
2018-08-14 04:18:53 +00:00
];
2018-08-28 03:07:36 +00:00
}
}