1
0
Fork 0
pixelfed/app/Transformer/ActivityPub/ProfileOutbox.php

37 lines
931 B
PHP
Raw Normal View History

2018-06-01 03:16:43 +00:00
<?php
namespace App\Transformer\ActivityPub;
use App\Profile;
use League\Fractal;
2018-12-12 21:26:00 +00:00
use App\Transformer\ActivityPub\Verb\CreateNote;
2018-06-01 03:16:43 +00:00
class ProfileOutbox extends Fractal\TransformerAbstract
{
2018-12-12 21:26:00 +00:00
protected $defaultIncludes = ['orderedItems'];
2018-08-28 03:07:36 +00:00
public function transform(Profile $profile)
{
2018-12-12 21:26:00 +00:00
$count = $profile->statuses()->whereHas('media')->count();
2018-06-01 03:16:43 +00:00
2018-08-28 03:07:36 +00:00
return [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $profile->permalink('/outbox'),
'type' => 'OrderedCollection',
'totalItems' => $count,
];
}
2018-12-12 21:26:00 +00:00
public function includeOrderedItems(Profile $profile)
{
$statuses = $profile
->statuses()
->with('media')
->whereVisibility('public')
->orderBy('created_at', 'desc')
->paginate(10);
return $this->collection($statuses, new CreateNote);
}
2018-08-28 03:07:36 +00:00
}