Add AS2.0 data for a note

This commit is contained in:
Jonny Barnes 2017-09-13 15:49:37 +01:00
parent d33793df14
commit f3cfa9324c
2 changed files with 52 additions and 0 deletions

View file

@ -48,6 +48,34 @@ class NotesController extends Controller
{
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
if (request()->wantsActivityStream()) {
$data = json_encode([
'@context' => 'https://www.w3.org/ns/activitystreams',
'summary' => 'Jonny added a note to his microblog',
'type' => 'Add',
'published' => $note->updated_at->toW3cString(),
'actor' => [
'type' => 'Person',
'id' => config('app.url'),
'name' => config('app.display_name'),
'url' => config('app.url'),
'image' => [
'type' => 'Link',
'href' => config('app.url') . '/assets/img/jmb-bw.jpg',
'mediaType' => '/image/jpeg',
],
],
'object' => [
'id' => $note->longurl,
'type' => 'Note',
'url' => $note->longurl,
'name' => strip_tags($note->note)
],
]);
return response($data)->header('Content-Type', 'application/activity+json');
}
return view('notes.show', compact('note'));
}