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')
|
2020-12-28 01:00:43 +00:00
|
|
|
->whereScope('public')
|
2018-12-12 21:26:00 +00:00
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
->paginate(10);
|
|
|
|
|
|
|
|
return $this->collection($statuses, new CreateNote);
|
|
|
|
}
|
2018-08-28 03:07:36 +00:00
|
|
|
}
|