diff --git a/app/Events/S3DownloadFinished.php b/app/Events/S3DownloadFinished.php index f7ec1bf0e..ddc2ead30 100644 --- a/app/Events/S3DownloadFinished.php +++ b/app/Events/S3DownloadFinished.php @@ -3,7 +3,6 @@ namespace App\Events; use App\Models\Server; -use App\Models\User; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; @@ -18,17 +17,13 @@ class S3DownloadFinished implements ShouldBroadcast public function __construct($teamId, $data = null) { - // Get the first user from the team to broadcast to - $user = User::whereHas('teams', function ($query) use ($teamId) { - $query->where('teams.id', $teamId); - })->first(); - - $this->userId = $user?->id; - if (is_null($data)) { return; } + // Get userId from event data (the user who triggered the download) + $this->userId = data_get($data, 'userId'); + $containerName = data_get($data, 'containerName'); $serverId = data_get($data, 'serverId'); diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php index 9b502339f..9cf11c26c 100644 --- a/app/Livewire/Project/Database/Import.php +++ b/app/Livewire/Project/Database/Import.php @@ -401,6 +401,7 @@ public function downloadFromS3() // Execute download commands $activity = remote_process($commands, $this->server, ignore_errors: false, callEventOnFinish: 'S3DownloadFinished', callEventData: [ + 'userId' => Auth::id(), 'downloadPath' => $downloadPath, 'containerName' => $containerName, 'serverId' => $this->server->id,