Track file uploads on Wings, not the panel

This commit is contained in:
DaneEveritt 2022-07-24 17:13:07 -04:00
parent 6a11c32bb2
commit f8c48214a5
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 11 additions and 3 deletions

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Controllers\Api\Client;
use Pterodactyl\Models\ActivityLog;
use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter;
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
@ -18,6 +19,7 @@ class ActivityLogController extends ClientApiController
->with('actor')
->allowedFilters([AllowedFilter::partial('event')])
->allowedSorts(['timestamp'])
->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS)
->paginate(min($request->query('per_page', 25), 100))
->appends($request->query());

View file

@ -5,6 +5,7 @@ namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Permission;
use Pterodactyl\Models\ActivityLog;
use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter;
use Illuminate\Database\Eloquent\Builder;
@ -26,6 +27,7 @@ class ActivityLogController extends ClientApiController
->with('actor')
->allowedSorts(['timestamp'])
->allowedFilters([AllowedFilter::partial('event')])
->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS)
->when(config('activity.hide_admin_activity'), function (Builder $builder) use ($server) {
// We could do this with a query and a lot of joins, but that gets pretty
// painful so for now we'll execute a simpler query.

View file

@ -6,7 +6,6 @@ use Carbon\CarbonImmutable;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Illuminate\Http\JsonResponse;
use Pterodactyl\Facades\Activity;
use Pterodactyl\Services\Nodes\NodeJWTService;
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\UploadFileRequest;
@ -36,8 +35,6 @@ class FileUploadController extends ClientApiController
*/
public function __invoke(UploadFileRequest $request, Server $server)
{
Activity::event('server:file.upload')->log();
return new JsonResponse([
'object' => 'signed_url',
'attributes' => [

View file

@ -53,6 +53,12 @@ class ActivityLog extends Model
public const RESOURCE_NAME = 'activity_log';
/**
* Tracks all of the events we no longer wish to display to users. These are either legacy
* events or just events where we never ended up using the associated data.
*/
public const DISABLED_EVENTS = ['server:file.upload'];
public $timestamps = false;
protected $guarded = [

View file

@ -81,6 +81,7 @@ return [
'rename_other' => 'Renamed :count files in :directory',
'write' => 'Wrote new content to :file',
'upload' => 'Began a file upload',
'uploaded' => 'Uploaded :file in :directory',
],
'sftp' => [
'denied' => 'Blocked SFTP access due to permissions',