feat: add messaging toggles, password reset SMS, and payment discounts

Allow SuperAdmin to disable SMS, email, and bot from dashboard settings on top of env flags. Add admin password reset with credentials SMS, plus payment discounts, notes, and payable amount handling.
This commit is contained in:
2026-08-16 06:58:08 +03:30
parent a6c760c3b7
commit 72be01fee3
25 changed files with 601 additions and 43 deletions
+26
View File
@@ -0,0 +1,26 @@
'use strict';
const AppError = require('../../utils/AppError');
const assertCanResetPasswordAndSms = (user) => {
if (!user) throw new AppError('USER_NOT_FOUND');
const phoneNumber = String(user.phoneNumber || user.phone || '').trim();
const username = String(user.username || '').trim();
const name = String(user.name || '').trim();
if (!phoneNumber) throw new AppError('PHONE_NUMBER_REQUIRED');
if (!username) throw new AppError('VALIDATION_FAILED', null, 'Username is missing');
return { username, phoneNumber, name };
};
const isCredentialsSmsDelivered = (sendResult) => {
if (!sendResult) return false;
return sendResult.result?.skipped !== true;
};
module.exports = {
assertCanResetPasswordAndSms,
isCredentialsSmsDelivered
};