|
|
|
|
@ -1037,7 +1037,7 @@ export class CommandService {
|
|
|
|
|
VALUES (?, ?, ?, NULL)
|
|
|
|
|
`).run(ensured, tokenHash, expiresIso);
|
|
|
|
|
|
|
|
|
|
try { Metrics.inc('web_tokens_issued_total'); } catch {}
|
|
|
|
|
try { Metrics.inc('web_tokens_issued_total'); } catch { }
|
|
|
|
|
|
|
|
|
|
const url = new URL(`/login?token=${encodeURIComponent(token)}`, base).toString();
|
|
|
|
|
return [{
|
|
|
|
|
@ -1050,7 +1050,7 @@ export class CommandService {
|
|
|
|
|
const feature = String(process.env.FEATURE_HELP_V2 ?? 'true').toLowerCase();
|
|
|
|
|
const helpV2Enabled = !['false', '0', 'no'].includes(feature);
|
|
|
|
|
|
|
|
|
|
try { Metrics.inc('commands_unknown_total'); } catch {}
|
|
|
|
|
try { Metrics.inc('commands_unknown_total'); } catch { }
|
|
|
|
|
if (!helpV2Enabled) {
|
|
|
|
|
return [{
|
|
|
|
|
recipient: context.sender,
|
|
|
|
|
@ -1093,7 +1093,7 @@ export class CommandService {
|
|
|
|
|
try {
|
|
|
|
|
const gid = isGroupId(context.groupId) ? context.groupId : 'dm';
|
|
|
|
|
Metrics.inc('onboarding_assign_failures_total', 1, { group_id: String(gid), source, reason });
|
|
|
|
|
} catch {}
|
|
|
|
|
} catch { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 1) Menciones aportadas por el backend (JIDs crudos)
|
|
|
|
|
@ -1229,7 +1229,7 @@ export class CommandService {
|
|
|
|
|
`).run(taskId, groupIdToUse, context.messageId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch {}
|
|
|
|
|
} catch { }
|
|
|
|
|
|
|
|
|
|
// Recuperar la tarea creada para obtener display_code asignado
|
|
|
|
|
const createdTask = TaskService.getTaskById(taskId);
|
|
|
|
|
@ -1292,15 +1292,15 @@ export class CommandService {
|
|
|
|
|
? String(process.env.ONBOARDING_ENABLE_IN_TEST || '').toLowerCase() === 'true'
|
|
|
|
|
: (() => {
|
|
|
|
|
const v = process.env.ONBOARDING_PROMPTS_ENABLED;
|
|
|
|
|
return v == null ? true : ['true','1','yes'].includes(String(v).toLowerCase());
|
|
|
|
|
return v == null ? true : ['true', '1', 'yes'].includes(String(v).toLowerCase());
|
|
|
|
|
})();
|
|
|
|
|
const groupLabel = isGroupId(context.groupId) ? String(context.groupId) : 'dm';
|
|
|
|
|
if (!enabled) {
|
|
|
|
|
try { Metrics.inc('onboarding_prompts_skipped_total', 1, { group_id: groupLabel, source: 'jit_assignee_failure', reason: 'disabled' }); } catch {}
|
|
|
|
|
try { Metrics.inc('onboarding_prompts_skipped_total', 1, { group_id: groupLabel, source: 'jit_assignee_failure', reason: 'disabled' }); } catch { }
|
|
|
|
|
} else {
|
|
|
|
|
const bot = String(process.env.CHATBOT_PHONE_NUMBER || '').trim();
|
|
|
|
|
if (!bot || !/^\d+$/.test(bot)) {
|
|
|
|
|
try { Metrics.inc('onboarding_prompts_skipped_total', 1, { group_id: groupLabel, source: 'jit_assignee_failure', reason: 'missing_bot_number' }); } catch {}
|
|
|
|
|
try { Metrics.inc('onboarding_prompts_skipped_total', 1, { group_id: groupLabel, source: 'jit_assignee_failure', reason: 'missing_bot_number' }); } catch { }
|
|
|
|
|
} else {
|
|
|
|
|
const list = unresolvedList.join(', ');
|
|
|
|
|
let groupCtx = '';
|
|
|
|
|
@ -1310,7 +1310,7 @@ export class CommandService {
|
|
|
|
|
}
|
|
|
|
|
const msg = `No puedo asignar a ${list} aún${groupCtx}. Pídele que toque este enlace y diga 'activar': https://wa.me/${bot}`;
|
|
|
|
|
responses.push({ recipient: createdBy, message: msg });
|
|
|
|
|
try { Metrics.inc('onboarding_prompts_sent_total', 1, { group_id: groupLabel, source: 'jit_assignee_failure' }); } catch {}
|
|
|
|
|
try { Metrics.inc('onboarding_prompts_sent_total', 1, { group_id: groupLabel, source: 'jit_assignee_failure' }); } catch { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1332,12 +1332,12 @@ export class CommandService {
|
|
|
|
|
|
|
|
|
|
// Gating de grupos en modo 'enforce' (cuando CommandService se invoca directamente)
|
|
|
|
|
if (isGroupId(context.groupId)) {
|
|
|
|
|
try { (AllowedGroups as any).dbInstance = this.dbInstance; } catch {}
|
|
|
|
|
try { (AllowedGroups as any).dbInstance = this.dbInstance; } catch { }
|
|
|
|
|
const mode = String(process.env.GROUP_GATING_MODE || 'off').toLowerCase();
|
|
|
|
|
if (mode === 'enforce') {
|
|
|
|
|
try {
|
|
|
|
|
if (!AllowedGroups.isAllowed(context.groupId)) {
|
|
|
|
|
try { Metrics.inc('commands_blocked_total'); } catch {}
|
|
|
|
|
try { Metrics.inc('commands_blocked_total'); } catch { }
|
|
|
|
|
return { responses: [], ok: true };
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
|