This commit is contained in:
陆柯 2024-01-03 12:40:41 +08:00
parent 2f0c78c842
commit e5c4ffc89f

View File

@ -36,11 +36,12 @@ module.exports = {
config = my.envar?.SMS || wo.envar?.SMS || {}, // ['ALIYUN','UNICLOUD','TENCENT'].includes(config.vendor) config = my.envar?.SMS || wo.envar?.SMS || {}, // ['ALIYUN','UNICLOUD','TENCENT'].includes(config.vendor)
msg, // for 'DXTON' msg, // for 'DXTON'
msgParam, msgParam,
// 以下参数可在 config 内部,或者在这里再次覆盖
msgTemplate, msgTemplate,
signName, // for 'ALIYUN', 'TENCENT' signName, // for 'ALIYUN', 'TENCENT'
appid, // for 'UNICLOUD', 'TENCENT' appid, // for 'UNICLOUD', 'TENCENT'
} = {}) { } = {}) {
if (/^\+\d+-\d+$/.test(phone) && config.vendor) { if (/^\+\d+-\d+$/.test(phone)) {
if (config.vendor === 'DXTON' && msg) { if (config.vendor === 'DXTON' && msg) {
return await this.sendSmsDxton(phone, msg, config) return await this.sendSmsDxton(phone, msg, config)
} else if (config.vendor === 'ALIYUN' && msgParam && msgTemplate) { } else if (config.vendor === 'ALIYUN' && msgParam && msgTemplate) {
@ -50,7 +51,7 @@ module.exports = {
} else if (config.vendor === 'TENCENT' && msgParam && msgTemplate) { } else if (config.vendor === 'TENCENT' && msgParam && msgTemplate) {
return await this.sendSmsTencent({ phone, msgParam, msgTemplate, appid, signName, config }) return await this.sendSmsTencent({ phone, msgParam, msgTemplate, appid, signName, config })
} else { } else {
return { _state: 'SMS_UNKNOWN_VENDOR', error: {} } return { _state: 'SMS_UNKNOWN_VENDOR', error: { unknownVendor: config.vendor } }
} }
} else { } else {
return { _state: 'SMS_INVALID_PHONE', error: {} } return { _state: 'SMS_INVALID_PHONE', error: {} }