|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
namespace App\Transformer\ActivityPub;
|
|
|
|
|
|
|
|
|
|
use App\Services\MediaService;
|
|
|
|
|
use App\Services\StatusService;
|
|
|
|
|
use App\Status;
|
|
|
|
|
use App\Util\Lexer\Autolink;
|
|
|
|
|
use League\Fractal;
|
|
|
|
@ -11,7 +12,16 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
|
|
|
|
{
|
|
|
|
|
public function transform(Status $status)
|
|
|
|
|
{
|
|
|
|
|
$content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : "";
|
|
|
|
|
$content = $status->caption ? nl2br(Autolink::create()->autolink($status->caption)) : '';
|
|
|
|
|
|
|
|
|
|
$inReplyTo = null;
|
|
|
|
|
|
|
|
|
|
if ($status->in_reply_to_id) {
|
|
|
|
|
$reply = StatusService::get($status->in_reply_to_id, true);
|
|
|
|
|
if ($reply && isset($reply['url'])) {
|
|
|
|
|
$inReplyTo = $reply['url'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'@context' => [
|
|
|
|
@ -25,30 +35,20 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'id' => $status->url(),
|
|
|
|
|
|
|
|
|
|
// TODO: handle other types
|
|
|
|
|
'type' => 'Note',
|
|
|
|
|
|
|
|
|
|
// XXX: CW Title
|
|
|
|
|
'summary' => null,
|
|
|
|
|
'content' => $content,
|
|
|
|
|
'inReplyTo' => null,
|
|
|
|
|
|
|
|
|
|
// TODO: fix date format
|
|
|
|
|
'inReplyTo' => $inReplyTo,
|
|
|
|
|
'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,
|
|
|
|
|
'attachment' => MediaService::activitypub($status->id),
|
|
|
|
|
'tag' => [],
|
|
|
|
|
'location' => $status->place_id ? [
|
|
|
|
|