|
|
|
@ -2,10 +2,11 @@
|
|
|
|
|
|
|
|
|
|
namespace App\Transformer\ActivityPub\Verb;
|
|
|
|
|
|
|
|
|
|
use App\Status;
|
|
|
|
|
use League\Fractal;
|
|
|
|
|
use App\Models\CustomEmoji;
|
|
|
|
|
use App\Status;
|
|
|
|
|
use App\Util\Lexer\Autolink;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
use League\Fractal;
|
|
|
|
|
|
|
|
|
|
class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
{
|
|
|
|
@ -16,10 +17,11 @@ class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
$name = Str::startsWith($webfinger, '@') ?
|
|
|
|
|
$webfinger :
|
|
|
|
|
'@'.$webfinger;
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'type' => 'Mention',
|
|
|
|
|
'href' => $mention->permalink(),
|
|
|
|
|
'name' => $name
|
|
|
|
|
'name' => $name,
|
|
|
|
|
];
|
|
|
|
|
})->toArray();
|
|
|
|
|
|
|
|
|
@ -33,7 +35,7 @@ class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
$reply = [
|
|
|
|
|
'type' => 'Mention',
|
|
|
|
|
'href' => $parent->permalink(),
|
|
|
|
|
'name' => $name
|
|
|
|
|
'name' => $name,
|
|
|
|
|
];
|
|
|
|
|
$mentions = array_merge($reply, $mentions);
|
|
|
|
|
}
|
|
|
|
@ -50,6 +52,7 @@ class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
$emojis = CustomEmoji::scan($status->caption, true) ?? [];
|
|
|
|
|
$emoji = array_merge($emojis, $mentions);
|
|
|
|
|
$tags = array_merge($emoji, $hashtags);
|
|
|
|
|
$content = $status->caption ? Autolink::create()->autolink($status->caption) : null;
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'@context' => [
|
|
|
|
@ -62,28 +65,28 @@ class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
'pixelfed' => 'http://pixelfed.org/ns#',
|
|
|
|
|
'commentsEnabled' => [
|
|
|
|
|
'@id' => 'pixelfed:commentsEnabled',
|
|
|
|
|
'@type' => 'schema:Boolean'
|
|
|
|
|
'@type' => 'schema:Boolean',
|
|
|
|
|
],
|
|
|
|
|
'capabilities' => [
|
|
|
|
|
'@id' => 'pixelfed:capabilities',
|
|
|
|
|
'@container' => '@set'
|
|
|
|
|
'@container' => '@set',
|
|
|
|
|
],
|
|
|
|
|
'announce' => [
|
|
|
|
|
'@id' => 'pixelfed:canAnnounce',
|
|
|
|
|
'@type' => '@id'
|
|
|
|
|
'@type' => '@id',
|
|
|
|
|
],
|
|
|
|
|
'like' => [
|
|
|
|
|
'@id' => 'pixelfed:canLike',
|
|
|
|
|
'@type' => '@id'
|
|
|
|
|
'@type' => '@id',
|
|
|
|
|
],
|
|
|
|
|
'reply' => [
|
|
|
|
|
'@id' => 'pixelfed:canReply',
|
|
|
|
|
'@type' => '@id'
|
|
|
|
|
'@type' => '@id',
|
|
|
|
|
],
|
|
|
|
|
'toot' => 'http://joinmastodon.org/ns#',
|
|
|
|
|
'Emoji' => 'toot:Emoji',
|
|
|
|
|
'blurhash' => 'toot:blurhash',
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'id' => $status->permalink(),
|
|
|
|
|
'type' => 'Create',
|
|
|
|
@ -95,7 +98,7 @@ class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
'id' => $status->url(),
|
|
|
|
|
'type' => 'Note',
|
|
|
|
|
'summary' => $status->is_nsfw ? $status->cw_summary : null,
|
|
|
|
|
'content' => $status->rendered ?? $status->caption,
|
|
|
|
|
'content' => $content,
|
|
|
|
|
'inReplyTo' => $status->in_reply_to_id ? $status->parent()->url() : null,
|
|
|
|
|
'published' => $status->created_at->toAtomString(),
|
|
|
|
|
'url' => $status->url(),
|
|
|
|
@ -119,6 +122,7 @@ class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
if ($media->height) {
|
|
|
|
|
$res['height'] = $media->height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
|
})->toArray(),
|
|
|
|
|
'tag' => $tags,
|
|
|
|
@ -126,16 +130,16 @@ class CreateNote extends Fractal\TransformerAbstract
|
|
|
|
|
'capabilities' => [
|
|
|
|
|
'announce' => 'https://www.w3.org/ns/activitystreams#Public',
|
|
|
|
|
'like' => 'https://www.w3.org/ns/activitystreams#Public',
|
|
|
|
|
'reply' => $status->comments_disabled == true ? '[]' : 'https://www.w3.org/ns/activitystreams#Public'
|
|
|
|
|
'reply' => $status->comments_disabled == true ? '[]' : 'https://www.w3.org/ns/activitystreams#Public',
|
|
|
|
|
],
|
|
|
|
|
'location' => $status->place_id ? [
|
|
|
|
|
'type' => 'Place',
|
|
|
|
|
'name' => $status->place->name,
|
|
|
|
|
'longitude' => $status->place->long,
|
|
|
|
|
'latitude' => $status->place->lat,
|
|
|
|
|
'country' => $status->place->country
|
|
|
|
|
'country' => $status->place->country,
|
|
|
|
|
] : null,
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|