feat: add SMS Bower verification settings
This commit is contained in:
+69
-2
@@ -719,8 +719,6 @@ const DEFAULT_FIVE_SIM_COUNTRY_ORDER = Object.freeze(['thailand']);
|
||||
const DEFAULT_NEX_SMS_BASE_URL = 'https://api.nexsms.net';
|
||||
const DEFAULT_NEX_SMS_SERVICE_CODE = 'ot';
|
||||
const DEFAULT_NEX_SMS_COUNTRY_ORDER = Object.freeze([1]);
|
||||
const DEFAULT_SMS_BOWER_SERVICE_CODE = 'ot';
|
||||
const DEFAULT_SMS_BOWER_COUNTRY_ORDER = Object.freeze([52]);
|
||||
const DEFAULT_MADAO_BASE_URL = 'http://127.0.0.1:7822';
|
||||
const DEFAULT_MADAO_MODE = 'routing_plan';
|
||||
const DEFAULT_HERO_SMS_REUSE_ENABLED = true;
|
||||
@@ -1453,6 +1451,11 @@ const PERSISTED_SETTING_DEFAULTS = {
|
||||
nexSmsCountryOrder: [...DEFAULT_NEX_SMS_COUNTRY_ORDER],
|
||||
nexSmsServiceCode: DEFAULT_NEX_SMS_SERVICE_CODE,
|
||||
smsBowerApiKey: '',
|
||||
smsBowerCountryId: 6,
|
||||
smsBowerCountryLabel: 'Indonesia',
|
||||
smsBowerCountryOrder: [6],
|
||||
smsBowerMinPrice: '',
|
||||
smsBowerMaxPrice: '',
|
||||
madaoBaseUrl: DEFAULT_MADAO_BASE_URL,
|
||||
madaoHttpSecret: '',
|
||||
madaoMode: DEFAULT_MADAO_MODE,
|
||||
@@ -2205,6 +2208,59 @@ function normalizeNexSmsServiceCode(value = '', fallback = DEFAULT_NEX_SMS_SERVI
|
||||
return fallbackNormalized || DEFAULT_NEX_SMS_SERVICE_CODE;
|
||||
}
|
||||
|
||||
function normalizeSmsBowerCountryId(value, fallback = 6) {
|
||||
const parsed = Math.floor(Number(value));
|
||||
if (Number.isFinite(parsed) && parsed >= 0) {
|
||||
return parsed;
|
||||
}
|
||||
const fallbackParsed = Math.floor(Number(fallback));
|
||||
if (Number.isFinite(fallbackParsed) && fallbackParsed >= 0) {
|
||||
return fallbackParsed;
|
||||
}
|
||||
return 6;
|
||||
}
|
||||
|
||||
function normalizeSmsBowerCountryLabel(value = '', fallback = 'Indonesia') {
|
||||
return String(value || '').trim() || fallback;
|
||||
}
|
||||
|
||||
function normalizeSmsBowerCountryOrder(value = []) {
|
||||
const source = Array.isArray(value)
|
||||
? value
|
||||
: String(value || '')
|
||||
.split(/[\r\n,,;;]+/)
|
||||
.map((entry) => String(entry || '').trim())
|
||||
.filter(Boolean);
|
||||
const normalized = [];
|
||||
const seen = new Set();
|
||||
source.forEach((entry) => {
|
||||
const id = normalizeSmsBowerCountryId(
|
||||
entry && typeof entry === 'object' && !Array.isArray(entry)
|
||||
? (entry.id ?? entry.countryId ?? entry.country ?? '')
|
||||
: entry,
|
||||
-1
|
||||
);
|
||||
if (id < 0 || seen.has(id)) {
|
||||
return;
|
||||
}
|
||||
seen.add(id);
|
||||
normalized.push(id);
|
||||
});
|
||||
return normalized.length ? normalized.slice(0, 10) : [6];
|
||||
}
|
||||
|
||||
function normalizeSmsBowerMaxPrice(value = '') {
|
||||
const normalized = String(value || '').trim();
|
||||
if (!normalized) {
|
||||
return '';
|
||||
}
|
||||
const numeric = Number(normalized.replace(',', '.'));
|
||||
if (!Number.isFinite(numeric) || numeric < 0) {
|
||||
return '';
|
||||
}
|
||||
return String(Number(numeric.toFixed(4))).replace(/\.0+$/, '');
|
||||
}
|
||||
|
||||
function normalizeMaDaoBaseUrl(value = '') {
|
||||
const normalized = normalizeLocalHttpBaseUrl(value, DEFAULT_MADAO_BASE_URL);
|
||||
try {
|
||||
@@ -3600,6 +3656,17 @@ function normalizePersistentSettingValue(key, value) {
|
||||
return normalizeNexSmsCountryOrder(value);
|
||||
case 'nexSmsServiceCode':
|
||||
return normalizeNexSmsServiceCode(value);
|
||||
case 'smsBowerApiKey':
|
||||
return String(value || '');
|
||||
case 'smsBowerCountryId':
|
||||
return normalizeSmsBowerCountryId(value);
|
||||
case 'smsBowerCountryLabel':
|
||||
return normalizeSmsBowerCountryLabel(value);
|
||||
case 'smsBowerCountryOrder':
|
||||
return normalizeSmsBowerCountryOrder(value);
|
||||
case 'smsBowerMinPrice':
|
||||
case 'smsBowerMaxPrice':
|
||||
return normalizeSmsBowerMaxPrice(value);
|
||||
case 'madaoBaseUrl':
|
||||
return normalizeMaDaoBaseUrl(value);
|
||||
case 'madaoHttpSecret':
|
||||
|
||||
Reference in New Issue
Block a user