reinicio: fix phase_2

Signed-off-by: Rodrigo Martins <rodrigo@martinsevieira.adv.br>
This commit is contained in:
Rodrigo Martins committed 2026-04-07 13:14:24 -03:00
1 parent ba6e765107
commit 728437c7c3
1 file changed
+12 -12
+12 -12
View File
@@ -8686,6 +8686,10 @@ Digite /help para ver todos os comandos disponíveis!
const serialEscaped = serial.replace(/_/g, '\\_');
// Gerar ID curto para 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` +
@@ -8698,7 +8702,7 @@ Digite /help para ver todos os comandos disponíveis!
reply_markup: {
inline_keyboard: [
[
{ text: '✅ SIM, Reiniciar', callback_data: `confirm_restart_onu_${serial}_${base}_${location}` },
{ text: '✅ SIM, Reiniciar', callback_data: `confirm_restart_onu_${restartId}` },
{ text: '❌ Cancelar', callback_data: 'cancel_action' }
]
]
@@ -8758,21 +8762,17 @@ Digite /help para ver todos os comandos disponíveis!
const chatId = callbackQuery.message.chat.id;
await this.bot.answerCallbackQuery(callbackQuery.id);
// 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.');
// Formato: confirm_restart_onu_ID
const restartId = data.replace('confirm_restart_onu_', '');
const pending = this.pendingRestarts.get(restartId);
if (!pending) {
await this.bot.sendMessage(chatId, '❌ Dados de reinicialização expirados. Tente novamente.');
return;
}
this.pendingRestarts.delete(restartId);
const serial = serialMatch[1];
const remaining = serialMatch[2]; // BASE_LOCATION
const base = remaining; // usa o restante como base (pode conter location junto)
const { serial, base } = pending;
const oltHint = this._resolverOLTporBase(base);
const serialEscaped = serial.replace(/_/g, '\\_');
await this.bot.editMessageText(