reinicio: fix phase

Signed-off-by: Rodrigo Martins <rodrigo@martinsevieira.adv.br>
This commit is contained in:
Rodrigo Martins committed 2026-04-07 12:46:33 -03:00
1 parent 3ec5ad73cb
commit ba6e765107
2 files changed
+11 -13

No files matched your search

+10 -12
View File
@@ -8686,10 +8686,6 @@ Digite /help para ver todos os comandos disponíveis!
const serialEscaped = serial.replace(/_/g, '\\_');
// Gerar ID curto para não estourar o limite de 64 bytes do callback_data
const restartId = String(++this._restartIdCounter);
this.pendingRestarts.set(restartId, { serial, base, location });
await this.bot.sendMessage(chatId,
`⚠️ *Confirmar Reinicialização de ONU*\n\n` +
`📦 *Serviço:* ${nome}\n` +
@@ -8702,7 +8698,7 @@ Digite /help para ver todos os comandos disponíveis!
reply_markup: {
inline_keyboard: [
[
{ text: '✅ SIM, Reiniciar', callback_data: `confirm_rst_${restartId}` },
{ text: '✅ SIM, Reiniciar', callback_data: `confirm_restart_onu_${serial}_${base}_${location}` },
{ text: '❌ Cancelar', callback_data: 'cancel_action' }
]
]
@@ -8762,16 +8758,18 @@ Digite /help para ver todos os comandos disponíveis!
const chatId = callbackQuery.message.chat.id;
await this.bot.answerCallbackQuery(callbackQuery.id);
// Formato: confirm_rst_ID
const restartId = data.replace('confirm_rst_', '');
const pending = this.pendingRestarts.get(restartId);
if (!pending) {
await this.bot.sendMessage(chatId, '❌ Dados de reinicialização expirados. Tente novamente.');
// Formato: confirm_restart_onu_SERIAL_BASE_LOCATION
const rest = data.replace('confirm_restart_onu_', '');
// Serial é o primeiro token (12 chars alfanuméricos)
const serialMatch = rest.match(/^([A-Za-z0-9]+)_(.*)$/);
if (!serialMatch) {
await this.bot.sendMessage(chatId, '❌ Erro ao processar dados de reinicialização.');
return;
}
this.pendingRestarts.delete(restartId);
const { serial, base } = pending;
const serial = serialMatch[1];
const remaining = serialMatch[2]; // BASE_LOCATION
const base = remaining; // usa o restante como base (pode conter location junto)
const oltHint = this._resolverOLTporBase(base);