2022-05-30 00:34:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Client;
|
|
|
|
|
2022-07-24 21:13:07 +00:00
|
|
|
use Pterodactyl\Models\ActivityLog;
|
2022-05-30 00:34:48 +00:00
|
|
|
use Spatie\QueryBuilder\QueryBuilder;
|
|
|
|
use Spatie\QueryBuilder\AllowedFilter;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|
|
|
use Pterodactyl\Transformers\Api\Client\ActivityLogTransformer;
|
|
|
|
|
|
|
|
class ActivityLogController extends ClientApiController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns a paginated set of the user's activity logs.
|
|
|
|
*/
|
|
|
|
public function __invoke(ClientApiRequest $request): array
|
|
|
|
{
|
|
|
|
$activity = QueryBuilder::for($request->user()->activity())
|
|
|
|
->with('actor')
|
2022-06-28 00:52:27 +00:00
|
|
|
->allowedFilters([AllowedFilter::partial('event')])
|
2022-06-05 22:28:08 +00:00
|
|
|
->allowedSorts(['timestamp'])
|
2022-07-24 21:13:07 +00:00
|
|
|
->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS)
|
2022-06-12 19:08:26 +00:00
|
|
|
->paginate(min($request->query('per_page', 25), 100))
|
2022-05-30 00:34:48 +00:00
|
|
|
->appends($request->query());
|
|
|
|
|
|
|
|
return $this->fractal->collection($activity)
|
|
|
|
->transformWith($this->getTransformer(ActivityLogTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
}
|