From 3d3f5ff6484416aa28b74e41327967382d81435a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 12 Nov 2018 23:25:31 -0700 Subject: [PATCH] Add AP CreateNote Transformer --- .../ActivityPub/Verb/CreateNote.php | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 app/Transformer/ActivityPub/Verb/CreateNote.php diff --git a/app/Transformer/ActivityPub/Verb/CreateNote.php b/app/Transformer/ActivityPub/Verb/CreateNote.php new file mode 100644 index 000000000..2a27057a4 --- /dev/null +++ b/app/Transformer/ActivityPub/Verb/CreateNote.php @@ -0,0 +1,65 @@ + [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', + [ + 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', + 'featured' => [ + 'https://pixelfed.org/ns#featured' => ['@type' => '@id'], + ], + ], + ], + 'id' => $status->permalink(), + 'type' => 'Create', + 'actor' => $status->profile->permalink(), + 'published' => $status->created_at->toAtomString(), + 'to' => $status->scopeToAudience('to'), + 'cc' => $status->scopeToAudience('cc'), + 'object' => [ + 'id' => $status->url(), + + // TODO: handle other types + 'type' => 'Note', + + // XXX: CW Title + 'summary' => null, + 'content' => $status->rendered ?? $status->caption, + 'inReplyTo' => $status->in_reply_to_id ? $status->parent()->url() : 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, + 'attachment' => $status->media->map(function ($media) { + return [ + 'type' => 'Document', + 'mediaType' => $media->mime, + 'url' => $media->url(), + 'name' => null, + ]; + })->toArray(), + 'tag' => [], + ] + ]; + } +}