fix: clarify why SMS delivery is skipped when a channel gate is off

Surface env vs dashboard disable reasons in SMS logs so password reset and other sends are easier to diagnose when only one layer is enabled.
This commit is contained in:
2026-08-16 13:30:51 +03:30
parent 7d59448991
commit 4ad5630cb7
2 changed files with 44 additions and 11 deletions
+13 -6
View File
@@ -4,7 +4,7 @@
const axios = require('axios');
const config = require('../../config/config');
const logger = require('../logger');
const { isMessagingChannelEnabled } = require('../../components/settings/messagingFlags');
const { getMessagingChannelState } = require('../../components/settings/messagingFlags');
const toBoolean = (value) => {
if (typeof value === 'boolean') return value;
@@ -22,16 +22,23 @@ const redactSmsParams = (params = []) => (
);
const sendSingleSms = async (mobile, templateId, params = []) => {
console.log('[SMS] About to send notification:', {
const channelState = await getMessagingChannelState('sms');
logger.info('[SMS] About to send notification:', {
mobile,
templateId,
params: redactSmsParams(params),
SMS_ENABLED: config.SMS_ENABLED,
SMS_ENABLED: channelState.envEnabled,
dashboardEnabled: channelState.dbEnabled,
});
if (!(await isMessagingChannelEnabled('sms'))) {
logger.info(`[SMS] Skipped (channel disabled) → ${mobile} template=${templateId}`);
return { skipped: true, reason: 'channel_disabled' };
if (!channelState.enabled) {
const reason = channelState.blockReason || 'channel_disabled';
const detail = reason === 'dashboard_disabled'
? 'dashboard smsEnabled=false'
: 'SMS_ENABLED env flag is false';
logger.info(`[SMS] Skipped (${detail}) → ${mobile} template=${templateId}`);
return { skipped: true, reason };
}
if (!templateId) {