This commit is contained in:
baodev0
2026-07-21 08:34:15 +07:00
parent 3f477a559d
commit c3b5417b19
19 changed files with 652 additions and 20 deletions
@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace App\Jobs\VirtualMachine\Rebuild;
use App\Http\Services\Telegram;
use App\Jobs\Mail\Customer\VmRebuildFailedJob;
use App\Models\ModuleVmware;
use App\Services\VirtualMachine\Rebuild\VmRebuildPasswordService;
use App\Services\VirtualMachine\Rebuild\VmRebuildService;
use Illuminate\Bus\Queueable;
@@ -62,6 +65,15 @@ final class RebuildChangePasswordJob implements ShouldQueue
'module_vmware_id' => $this->moduleVmwareId,
'new_vm_id' => $this->newVmId,
]);
$vmAfter = ModuleVmware::find($this->moduleVmwareId);
(new Telegram)->SendRebuildStepNotification(
$ctx->vmName,
$ctx->ip,
'Đổi mật khẩu' . ($ctx->isWindows ? ' & Port RDP' : ''),
true,
$ctx->isWindows ? "Port RDP mới: {$vmAfter?->port}" : null,
);
}
public function failed(Throwable $e): void
@@ -77,5 +89,22 @@ final class RebuildChangePasswordJob implements ShouldQueue
'error_message' => 'ChangePassword failed: ' . $e->getMessage(),
'updated_at' => now(),
]);
$vm = ModuleVmware::with('customer')->find($this->moduleVmwareId);
(new Telegram)->SendRebuildStepNotification(
$vm->name ?? "VM #{$this->moduleVmwareId}",
$vm->ip ?? '',
'Đổi mật khẩu & Port',
false,
$e->getMessage(),
);
VmRebuildFailedJob::dispatch([
'customer_email' => $vm?->customer?->email,
'customer_name' => $vm?->customer?->fullname,
'vm_name' => $vm->name ?? "VM #{$this->moduleVmwareId}",
'ip' => $vm->ip ?? '',
'module_vmware_id' => $this->moduleVmwareId,
]);
}
}