mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-11 14:40:46 +00:00
Add StatusTransformer
This commit is contained in:
parent
bc42a0d1f4
commit
3193ee2017
1 changed files with 62 additions and 0 deletions
62
app/Transformer/ActivityPub/StatusTransformer.php
Normal file
62
app/Transformer/ActivityPub/StatusTransformer.php
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformer\ActivityPub;
|
||||||
|
|
||||||
|
use App\{Profile, Status};
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
|
class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
public function transform(Status $status)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'@context' => [
|
||||||
|
'https://www.w3.org/ns/activitystreams',
|
||||||
|
'https://w3id.org/security/v1',
|
||||||
|
[
|
||||||
|
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
|
||||||
|
"featured" => [
|
||||||
|
"https://pixelfed.org/ns#featured" => ["@type" => "@id"],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'id' => $status->url(),
|
||||||
|
|
||||||
|
// TODO: handle other types
|
||||||
|
'type' => 'Note',
|
||||||
|
|
||||||
|
// XXX: CW Title
|
||||||
|
'summary' => null,
|
||||||
|
'content' => $status->rendered ?? $status->caption,
|
||||||
|
'inReplyTo' => null,
|
||||||
|
|
||||||
|
// TODO: fix date format
|
||||||
|
'published' => $status->created_at->toAtomString(),
|
||||||
|
'url' => $status->url(),
|
||||||
|
'attributedTo' => $status->profile->permalink(),
|
||||||
|
'to' => [
|
||||||
|
// TODO: handle proper scope
|
||||||
|
'https://www.w3.org/ns/activitystreams#Public'
|
||||||
|
],
|
||||||
|
'cc' => [
|
||||||
|
// TODO: add cc's
|
||||||
|
$status->profile->permalink('/followers'),
|
||||||
|
],
|
||||||
|
'sensitive' => (bool) $status->is_nsfw,
|
||||||
|
'atomUri' => $status->url(),
|
||||||
|
'inReplyToAtomUri' => null,
|
||||||
|
'conversation' => $status->url(),
|
||||||
|
'attachment' => $status->media->map(function($media) {
|
||||||
|
return [
|
||||||
|
'type' => 'Document',
|
||||||
|
'mediaType' => $media->mime,
|
||||||
|
'url' => $media->url(),
|
||||||
|
'name' => null
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
'tag' => []
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue