jonnybarnes.uk/app/Services/ActivityStreamsService.php

51 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace App\Services;
use App\Note;
class ActivityStreamsService
{
public function siteOwnerResponse()
{
$data = json_encode([
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => config('app.url'),
'type' => 'Person',
'name' => config('app.display_name'),
'preferredUsername' => 'jonnybarnes',
]);
return response($data)->header('Content-Type', 'application/activity+json');
}
public function singleNoteResponse(Note $note)
{
$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');
}
}