1
0
Fork 0
pixelfed/app/Transformer/ActivityPub/StatusTransformer.php

61 lines
1.9 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;
2021-07-25 09:17:49 +00:00
use App\Services\MediaService;
2018-08-14 04:18:53 +00:00
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,
2021-07-25 09:17:49 +00:00
'attachment' => MediaService::activitypub($status->id),
2018-08-28 03:07:36 +00:00
'tag' => [],
'location' => $status->place_id ? [
'type' => 'Place',
'name' => $status->place->name,
'longitude' => $status->place->long,
2019-09-06 01:58:38 +00:00
'latitude' => $status->place->lat,
'country' => $status->place->country
] : null,
2018-08-14 04:18:53 +00:00
];
2018-08-28 03:07:36 +00:00
}
}