genieacs: fix password send
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
c4e35028f6
commit
ad2c6fd485
2 files changed
+26
-11
No files matched your search
+12
-3
@@ -7688,7 +7688,10 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
if (band === 'ch24') session.device.channel24 = String(canal);
|
||||
else session.device.channel5 = String(canal);
|
||||
this.userSessions.set(userId, session);
|
||||
await this.bot.sendMessage(chatId, `✅ *${meta.label}* definido para o canal *${canal}*.`, { parse_mode: 'Markdown' });
|
||||
const okMsg = res.queued
|
||||
? `⏳ *${meta.label}* → canal *${canal}* enfileirado. O roteador aplicará na próxima conexão.`
|
||||
: `✅ *${meta.label}* definido para o canal *${canal}*.`;
|
||||
await this.bot.sendMessage(chatId, okMsg, { parse_mode: 'Markdown' });
|
||||
}
|
||||
await this._enviarMenuConfigurarRoteador(chatId, session.device, session.instance);
|
||||
return;
|
||||
@@ -7720,7 +7723,10 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
else session.device.autoChannel5 = novoValor ? 'Sim' : 'Não';
|
||||
this.userSessions.set(userId, session);
|
||||
|
||||
await this.bot.sendMessage(chatId, `✅ ${meta.label} ${novoValor ? 'ativado' : 'desativado'} com sucesso.`);
|
||||
const autoMsg = res.queued
|
||||
? `⏳ ${meta.label} ${novoValor ? 'ativação' : 'desativação'} enfileirada. O roteador aplicará na próxima conexão.`
|
||||
: `✅ ${meta.label} ${novoValor ? 'ativado' : 'desativado'} com sucesso.`;
|
||||
await this.bot.sendMessage(chatId, autoMsg);
|
||||
await this._enviarMenuConfigurarRoteador(chatId, session.device, session.instance);
|
||||
return;
|
||||
}
|
||||
@@ -7847,7 +7853,10 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
return;
|
||||
}
|
||||
|
||||
await this.bot.sendMessage(chatId, `✅ *${meta.label}* atualizado para: \`${valorFinal}\``, { parse_mode: 'Markdown' });
|
||||
const statusMsg = res.queued
|
||||
? `⏳ *${meta.label}* → \`${valorFinal}\`\n_Task enfileirada. O roteador aplicará na próxima conexão com o servidor._`
|
||||
: `✅ *${meta.label}* atualizado para: \`${valorFinal}\``;
|
||||
await this.bot.sendMessage(chatId, statusMsg, { parse_mode: 'Markdown' });
|
||||
|
||||
// Atualiza o device local com o novo valor para o menu refletir
|
||||
const fieldToDeviceKey = {
|
||||
|
||||
+14
-8
@@ -59,7 +59,7 @@ class GenieACSApi {
|
||||
_buildClient(instance) {
|
||||
return axios.create({
|
||||
baseURL: this.config.getNBIUrl(instance),
|
||||
timeout: 15000,
|
||||
timeout: 30000,
|
||||
auth: {
|
||||
username: instance.user,
|
||||
password: instance.password
|
||||
@@ -184,25 +184,31 @@ class GenieACSApi {
|
||||
|
||||
/**
|
||||
* Cria uma task setParameterValues no dispositivo via NBI.
|
||||
* Aguarda até 3 s pela conexão do CPE com o servidor (timeout=3000).
|
||||
*
|
||||
* O parâmetro `connection_request` na URL instrui o GenieACS a enviar um
|
||||
* TR-069 Connection Request ao CPE imediatamente, triggering um inform.
|
||||
* Sem ele, o CPE só executaria a task no próximo inform agendado.
|
||||
* O `timeout` (ms) define por quanto tempo o GenieACS aguarda o CPE conectar
|
||||
* antes de retornar 202 (task enfileirada mas ainda não executada).
|
||||
*
|
||||
* @param {string} deviceId - _id do dispositivo
|
||||
* @param {Array} parameterValues - Array de [paramName, value, xsdType]
|
||||
* @param {Object} instance - Instância de GenieACSConfig
|
||||
* @returns {Promise<Object>} - { success, error }
|
||||
* @returns {Promise<Object>} - { success, queued, error }
|
||||
*/
|
||||
async setParameterValues(deviceId, parameterValues, instance) {
|
||||
const client = this._buildClient(instance);
|
||||
const encodedId = encodeURIComponent(deviceId);
|
||||
|
||||
try {
|
||||
await client.post(
|
||||
`/devices/${encodedId}/tasks`,
|
||||
const response = await client.post(
|
||||
`/devices/${encodedId}/tasks?connection_request`,
|
||||
{ name: 'setParameterValues', parameterValues },
|
||||
{ params: { timeout: 3000 } }
|
||||
{ params: { timeout: 15000 } }
|
||||
);
|
||||
logger.info(`[GenieACS] setParameterValues em ${deviceId}: ${JSON.stringify(parameterValues)}`);
|
||||
return { success: true };
|
||||
const queued = response.status === 202;
|
||||
logger.info(`[GenieACS] setParameterValues em ${deviceId} (${queued ? 'enfileirado' : 'aplicado'}): ${JSON.stringify(parameterValues)}`);
|
||||
return { success: true, queued };
|
||||
} catch (error) {
|
||||
const status = error.response?.status;
|
||||
const msg = status
|
||||
|
||||
Reference in new issue
Block a user