feat: add SMS Bower phone SMS provider
This commit is contained in:
@@ -454,6 +454,7 @@ const rowNexSmsApiKey = document.getElementById('row-nex-sms-api-key');
|
||||
const rowNexSmsCountry = document.getElementById('row-nex-sms-country');
|
||||
const rowNexSmsCountryFallback = document.getElementById('row-nex-sms-country-fallback');
|
||||
const rowNexSmsServiceCode = document.getElementById('row-nex-sms-service-code');
|
||||
const rowSmsBowerApiKey = document.getElementById('row-sms-bower-api-key');
|
||||
const rowMaDaoBaseUrl = document.getElementById('row-madao-base-url');
|
||||
const rowMaDaoHttpSecret = document.getElementById('row-madao-http-secret');
|
||||
const rowMaDaoMode = document.getElementById('row-madao-mode');
|
||||
@@ -491,6 +492,8 @@ const inputFiveSimProduct = document.getElementById('input-five-sim-product');
|
||||
const inputNexSmsApiKey = document.getElementById('input-nex-sms-api-key');
|
||||
const btnToggleNexSmsApiKey = document.getElementById('btn-toggle-nex-sms-api-key');
|
||||
const inputNexSmsServiceCode = document.getElementById('input-nex-sms-service-code');
|
||||
const inputSmsBowerApiKey = document.getElementById('input-sms-bower-api-key');
|
||||
const btnToggleSmsBowerApiKey = document.getElementById('btn-toggle-sms-bower-api-key');
|
||||
const inputMaDaoBaseUrl = document.getElementById('input-madao-base-url');
|
||||
const inputMaDaoHttpSecret = document.getElementById('input-madao-http-secret');
|
||||
const btnToggleMaDaoHttpSecret = document.getElementById('btn-toggle-madao-http-secret');
|
||||
@@ -679,18 +682,22 @@ const PHONE_SMS_PROVIDER_FIVE_SIM = '5sim';
|
||||
const PHONE_SMS_PROVIDER_HERO_SMS = PHONE_SMS_PROVIDER_HERO;
|
||||
const PHONE_SMS_PROVIDER_NEXSMS = 'nexsms';
|
||||
const PHONE_SMS_PROVIDER_MADAO = 'madao';
|
||||
const PHONE_SMS_PROVIDER_SMS_BOWER = 'sms-bower';
|
||||
const DEFAULT_PHONE_SMS_PROVIDER = PHONE_SMS_PROVIDER_HERO;
|
||||
const DEFAULT_PHONE_SMS_PROVIDER_ORDER = Object.freeze([
|
||||
PHONE_SMS_PROVIDER_HERO,
|
||||
PHONE_SMS_PROVIDER_FIVE_SIM,
|
||||
PHONE_SMS_PROVIDER_NEXSMS,
|
||||
PHONE_SMS_PROVIDER_MADAO,
|
||||
PHONE_SMS_PROVIDER_SMS_BOWER,
|
||||
]);
|
||||
const DEFAULT_FIVE_SIM_COUNTRY_ORDER = Object.freeze(['thailand']);
|
||||
const DEFAULT_FIVE_SIM_OPERATOR = 'any';
|
||||
const DEFAULT_FIVE_SIM_PRODUCT = 'openai';
|
||||
const DEFAULT_NEX_SMS_COUNTRY_ORDER = Object.freeze([1]);
|
||||
const DEFAULT_NEX_SMS_SERVICE_CODE = 'ot';
|
||||
const DEFAULT_SMS_BOWER_COUNTRY_ORDER = Object.freeze([52]);
|
||||
const DEFAULT_SMS_BOWER_SERVICE_CODE = 'ot';
|
||||
const DEFAULT_MADAO_BASE_URL = 'http://127.0.0.1:7822';
|
||||
const MADAO_MODE_ROUTING_PLAN = 'routing_plan';
|
||||
const MADAO_MODE_DIRECT = 'direct';
|
||||
@@ -732,6 +739,11 @@ const PHONE_SMS_PROVIDER_UI_DESCRIPTORS = Object.freeze({
|
||||
'rowNexSmsServiceCode',
|
||||
]),
|
||||
}),
|
||||
[PHONE_SMS_PROVIDER_SMS_BOWER]: Object.freeze({
|
||||
rowKeys: Object.freeze([
|
||||
'rowSmsBowerApiKey',
|
||||
]),
|
||||
}),
|
||||
[PHONE_SMS_PROVIDER_MADAO]: Object.freeze({
|
||||
rowKeys: Object.freeze([
|
||||
'rowMaDaoBaseUrl',
|
||||
@@ -768,6 +780,7 @@ function getPhoneSmsProviderUiRowMap() {
|
||||
rowNexSmsCountry,
|
||||
rowNexSmsCountryFallback,
|
||||
rowNexSmsServiceCode,
|
||||
rowSmsBowerApiKey,
|
||||
rowMaDaoBaseUrl,
|
||||
rowMaDaoHttpSecret,
|
||||
rowMaDaoMode,
|
||||
@@ -4642,6 +4655,9 @@ function collectSettingsPayload() {
|
||||
const nexSmsApiKeyValue = typeof inputNexSmsApiKey !== 'undefined' && inputNexSmsApiKey
|
||||
? String(inputNexSmsApiKey.value || '')
|
||||
: String(latestState?.nexSmsApiKey || '');
|
||||
const smsBowerApiKeyValue = typeof inputSmsBowerApiKey !== 'undefined' && inputSmsBowerApiKey
|
||||
? String(inputSmsBowerApiKey.value || '')
|
||||
: String(latestState?.smsBowerApiKey || '');
|
||||
const maDaoBaseUrlValue = typeof inputMaDaoBaseUrl !== 'undefined' && inputMaDaoBaseUrl
|
||||
? normalizeMaDaoBaseUrlSafe(inputMaDaoBaseUrl.value || latestState?.madaoBaseUrl)
|
||||
: normalizeMaDaoBaseUrlSafe(latestState?.madaoBaseUrl);
|
||||
@@ -5287,6 +5303,7 @@ function collectSettingsPayload() {
|
||||
nexSmsApiKey: nexSmsApiKeyValue,
|
||||
nexSmsCountryOrder: nexSmsCountryOrderValue,
|
||||
nexSmsServiceCode: nexSmsServiceCodeValue,
|
||||
smsBowerApiKey: smsBowerApiKeyValue,
|
||||
madaoBaseUrl: maDaoBaseUrlValue,
|
||||
madaoHttpSecret: maDaoHttpSecretValue,
|
||||
madaoMode: maDaoModeValue,
|
||||
@@ -5426,6 +5443,9 @@ function normalizePhoneSmsProvider(value = '') {
|
||||
const maDaoProvider = typeof PHONE_SMS_PROVIDER_MADAO !== 'undefined'
|
||||
? PHONE_SMS_PROVIDER_MADAO
|
||||
: 'madao';
|
||||
const smsBowerProvider = typeof PHONE_SMS_PROVIDER_SMS_BOWER !== 'undefined'
|
||||
? PHONE_SMS_PROVIDER_SMS_BOWER
|
||||
: 'sms-bower';
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (normalized === PHONE_SMS_PROVIDER_FIVE_SIM) {
|
||||
return PHONE_SMS_PROVIDER_FIVE_SIM;
|
||||
@@ -5436,6 +5456,9 @@ function normalizePhoneSmsProvider(value = '') {
|
||||
if (normalized === maDaoProvider) {
|
||||
return maDaoProvider;
|
||||
}
|
||||
if (normalized === smsBowerProvider) {
|
||||
return smsBowerProvider;
|
||||
}
|
||||
return PHONE_SMS_PROVIDER_HERO_SMS;
|
||||
}
|
||||
function setPhoneSmsProviderSelectValue(provider) {
|
||||
@@ -5475,6 +5498,9 @@ function getPhoneSmsProviderLabel(provider = getSelectedPhoneSmsProvider()) {
|
||||
if (normalizedProvider === PHONE_SMS_PROVIDER_MADAO) {
|
||||
return 'MaDao';
|
||||
}
|
||||
if (normalizedProvider === PHONE_SMS_PROVIDER_SMS_BOWER) {
|
||||
return 'SMS Bower';
|
||||
}
|
||||
return 'HeroSMS';
|
||||
}
|
||||
|
||||
@@ -17772,6 +17798,9 @@ function applyPhoneSmsProviderFieldsToInputs(provider = getSelectedPhoneSmsProvi
|
||||
if (typeof inputNexSmsApiKey !== 'undefined' && inputNexSmsApiKey) {
|
||||
inputNexSmsApiKey.value = String(state?.nexSmsApiKey || '');
|
||||
}
|
||||
if (typeof inputSmsBowerApiKey !== 'undefined' && inputSmsBowerApiKey) {
|
||||
inputSmsBowerApiKey.value = String(state?.smsBowerApiKey || '');
|
||||
}
|
||||
if (typeof inputMaDaoBaseUrl !== 'undefined' && inputMaDaoBaseUrl) {
|
||||
inputMaDaoBaseUrl.value = normalizeMaDaoBaseUrlValue(state?.madaoBaseUrl);
|
||||
}
|
||||
@@ -19202,6 +19231,9 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
if (message.payload.nexSmsApiKey !== undefined && inputNexSmsApiKey) {
|
||||
inputNexSmsApiKey.value = String(message.payload.nexSmsApiKey || '').trim();
|
||||
}
|
||||
if (message.payload.smsBowerApiKey !== undefined && inputSmsBowerApiKey) {
|
||||
inputSmsBowerApiKey.value = String(message.payload.smsBowerApiKey || '').trim();
|
||||
}
|
||||
if (message.payload.fiveSimCountryOrder !== undefined && typeof applyFiveSimCountrySelection === 'function') {
|
||||
applyFiveSimCountrySelection(
|
||||
Array.isArray(message.payload.fiveSimCountryOrder) ? message.payload.fiveSimCountryOrder : []
|
||||
|
||||
Reference in New Issue
Block a user