fix: broadcast S3DownloadFinished to correct user
The event was broadcasting to the first user in the team instead of the actual user who triggered the download. This caused the download message to never hide for other team members. - Pass userId in S3DownloadFinished event data - Use the specific userId from event data for broadcasting - Remove unused User model import - Ensures broadcast reaches the correct user's private channel 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
23fdad1d9f
commit
8e273dd799
2 changed files with 4 additions and 8 deletions
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue