Compare commits
10 Commits
31febc9a1a
...
d27531ea00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d27531ea00 | ||
|
|
292e138732 | ||
| b4408ce9f9 | |||
|
|
dbd0e0b13f | ||
| 7b200e283a | |||
|
|
5fd32c86b3 | ||
|
|
15b87bbd7c | ||
|
|
5104ce87ee | ||
|
|
159f90f44a | ||
|
|
2a4f962e1c |
33
.gitignore
vendored
33
.gitignore
vendored
@@ -1,16 +1,42 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
# how to include another gitignore?
|
||||
# https://stackoverflow.com/questions/7005142/can-i-include-other-gitignore-file-in-a-gitignore-file-like-include-in-c-li
|
||||
# https://github.com/github/gitignore
|
||||
# https://github.com/SlideWave/gitignore-include?tab=readme-ov-file#examples
|
||||
# https://gitignore.io
|
||||
|
||||
### 目录 #################################################################
|
||||
### .gitignore.global.txt ###
|
||||
|
||||
# Self defined pattern to ignore
|
||||
?*.gitignore
|
||||
?*.gitignore/
|
||||
?*.gitignore.*
|
||||
?*.gitignore.*/
|
||||
*.gitomit
|
||||
*.gitomit.*
|
||||
*.gitomit/
|
||||
*.gitomit.*/
|
||||
*.nogit
|
||||
*.nogit.*
|
||||
*.nogit/
|
||||
*.nogit.*/
|
||||
# 保留
|
||||
!.gitignore
|
||||
!.gitignore.*
|
||||
!.gitkeep
|
||||
|
||||
# 通用
|
||||
.svn/
|
||||
.deploy_git/
|
||||
.idea/
|
||||
.sass-cache/
|
||||
.wrangler
|
||||
/test/unit/coverage/
|
||||
/test/e2e/reports/
|
||||
node_modules/
|
||||
*.aab
|
||||
*.apk
|
||||
*.ipa
|
||||
*.min.js
|
||||
*.min.css
|
||||
*.min.html
|
||||
@@ -70,7 +96,6 @@ _desktop.ini
|
||||
/db.json
|
||||
|
||||
# wo
|
||||
*.gitignore.*
|
||||
# 服务端
|
||||
/_archive/*
|
||||
/_datastore/*
|
||||
@@ -84,5 +109,5 @@ _desktop.ini
|
||||
package-lock.json
|
||||
pages4loader.json5
|
||||
|
||||
# 保留
|
||||
!.gitkeep
|
||||
### .gitignore.local.txt ###
|
||||
|
||||
|
||||
123
messenger.js
123
messenger.js
@@ -13,21 +13,38 @@ module.exports = {
|
||||
|
||||
// 或者如果smtp参数已经确定,就可以直接定义 sendMail: Bluebird.promisify(Smtp.sendMail).bind(Smtp)
|
||||
async sendMail (messageObject, smtp = my.envar?.SMTP || wo?.envar?.SMTP) {
|
||||
if (!smtp?.host) {
|
||||
globalThis.wo?.ccerror?.({ _state: 'SMTP_CONFIG_MALFORMED', smtp })
|
||||
return { _state: 'SMTP_CONFIG_MALFORMED', smtp }
|
||||
}
|
||||
// messageObject: { from, to, cc, bcc, subject, text, html, sender, replyTo, inReplyTo }
|
||||
sender.smtpTransporter = sender.smtpTransporter || NodeMailer.createTransport(smtp)
|
||||
return await sender.smtpTransporter
|
||||
.sendMail(messageObject)
|
||||
.then((result) => {
|
||||
if (result.messageId && result.response === '250 Ok') {
|
||||
console.log(result)
|
||||
return { _state: 'MSG_SENT_SUCCESS' }
|
||||
/*
|
||||
{
|
||||
accepted: [ 'anolaxy+1@outlook.com' ],
|
||||
rejected: [],
|
||||
envelopeTime: 159,
|
||||
messageTime: 160,
|
||||
messageSize: 1055,
|
||||
response: '250 Ok',
|
||||
envelope: { from: 'hi@babely.cc', to: [ 'anolaxy+1@outlook.com' ] },
|
||||
messageId: '<f78681c8-f5d7-4149-4abf-4b940497535f@babely.cc>'
|
||||
}
|
||||
*/
|
||||
if (result.messageId && result.response === '250 Ok') {
|
||||
globalThis.wo?.cclog?.({ _state: 'MSG_SENT_SUCCESS', subject: messageObject.subject, ...result.envelope })
|
||||
return { _state: 'MSG_SENT_SUCCESS' }
|
||||
} else {
|
||||
globalThis.wo?.cclog?.({ _state: 'MSG_SEND_FAIL', subject: messageObject.subject, ...result })
|
||||
return { _state: 'MSG_SEND_FAIL' }
|
||||
}
|
||||
console.log(result)
|
||||
return { _state: 'MSG_SEND_FAIL' }
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
return { _state: 'SMS_SEND_ERROR' }
|
||||
.catch((error) => {
|
||||
globalThis.wo?.ccerror?.({ _state: 'MSG_SEND_ERROR', subject: messageObject.subject, error })
|
||||
return { _state: 'MSG_SEND_ERROR' }
|
||||
})
|
||||
},
|
||||
|
||||
@@ -41,21 +58,28 @@ module.exports = {
|
||||
signName, // for 'ALIYUN', 'TENCENT'
|
||||
appid, // for 'UNICLOUD', 'TENCENT'
|
||||
} = {}) {
|
||||
let result
|
||||
if (/^\+\d+-\d+$/.test(phone)) {
|
||||
if (config.vendor === 'DXTON') {
|
||||
return await this.sendSmsDxton({ phone, config, msg })
|
||||
if (!config?.vendor) {
|
||||
result = { _state: 'SMS_CONFIG_MALFORMED', phone, config }
|
||||
} else if (config.vendor === 'DXTON') {
|
||||
result = await this.sendSmsDxton({ phone, config, msg })
|
||||
} else if (config.vendor === 'ALIYUN') {
|
||||
return await this.sendSmsAliyun({ phone, config, msgParam, msgTemplate, signName })
|
||||
} else if (config.vendor === 'UNICLOUD') {
|
||||
return await this.sendSmsUnicloud({ phone, config, msgParam, msgTemplate, appid })
|
||||
result = await this.sendSmsAliyun({ phone, config, msgParam, msgTemplate, signName })
|
||||
} else if (config.vendor === 'TENCENT') {
|
||||
return await this.sendSmsTencent({ phone, config, msgParam, msgTemplate, appid, signName })
|
||||
result = await this.sendSmsTencent({ phone, config, msgParam, msgTemplate, appid, signName })
|
||||
} else if (config.vendor === 'UNICLOUD') {
|
||||
result = await this.sendSmsUnicloud({ phone, config, msgParam, msgTemplate, appid })
|
||||
} else {
|
||||
return { _state: 'SMS_UNKNOWN_VENDOR', error: { unknownVendor: config.vendor } }
|
||||
result = { _state: 'SMS_UNKNOWN_VENDOR', error: { unknownVendor: config.vendor } }
|
||||
}
|
||||
} else {
|
||||
return { _state: 'SMS_INVALID_PHONE', error: {} }
|
||||
result = { _state: 'SMS_INVALID_PHONE', error: {} }
|
||||
}
|
||||
|
||||
globalThis.wo?.cclog?.({ phone, signName, msgParam, msgTemplate, ...result })
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
/* 使用 dxton.com 的短信接口 http://www.dxton.com/help_detail/38.html
|
||||
@@ -92,7 +116,7 @@ module.exports = {
|
||||
})
|
||||
})
|
||||
.on('error', (error) => {
|
||||
reject({ _state: 'SMS_SEND_ERROR', error })
|
||||
reject({ _state: 'MSG_SEND_ERROR', error })
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -120,7 +144,34 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
return { _state: 'SMS_SEND_ERROR', error }
|
||||
return { _state: 'MSG_SEND_ERROR', error }
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
async sendSmsTencent ({ phone, config, msgTemplate, msgParam, appid, signName } = {}) {
|
||||
sender.smsClientTencent = sender.smsClientTencent || new (require('tencentcloud-sdk-nodejs').sms.v20210111.Client)(config) // https://cloud.tencent.com/document/product/382/43197
|
||||
|
||||
return await sender.smsClientTencent
|
||||
.SendSms({
|
||||
// API: https://cloud.tencent.com/document/product/382/55981
|
||||
PhoneNumberSet: [phone.replace('-', '')],
|
||||
SmsSdkAppId: appid || config.appid,
|
||||
SignName: typeof signName !== 'undefined' ? signName : config.signName, // 腾讯云的国际短信可以没有签名,因此允许传入参数 signName:'' 来覆盖默认的 config.signName
|
||||
TemplateId: msgTemplate || config.msgTemplate,
|
||||
TemplateParamSet: Object.values(msgParam),
|
||||
})
|
||||
.then(
|
||||
function ({ SendStatusSet, RequestId } = {}) {
|
||||
let { SerialNo, PhoneNumber, Fee, Code, Message, IsoCode } = SendStatusSet[0]
|
||||
if (Code === 'Ok') {
|
||||
return { _state: 'MSG_SENT_SUCCESS' }
|
||||
} else {
|
||||
return { _state: 'MSG_SEND_FAIL', error: { SendStatusSet, RequestId } }
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
return { _state: 'MSG_SEND_ERROR', error }
|
||||
}
|
||||
)
|
||||
},
|
||||
@@ -136,40 +187,18 @@ module.exports = {
|
||||
data: msgParam, // 模版中的变量的值,例如 { passcode: '234345', purpose: '注册' }
|
||||
})
|
||||
|
||||
return { _state: 'MSG_SENT_SUCCESS', result } // 调用成功,请注意这时不代表发送成功。// { code:0, errCode:0, success:true } 错误码参见 https://uniapp.dcloud.net.cn/uniCloud/send-sms.html
|
||||
if (result?.errorCode === 0) {
|
||||
return { _state: 'MSG_SENT_SUCCESS', result } // { code:0, errCode:0, success:true }
|
||||
} else {
|
||||
// 错误码参见 https://doc.dcloud.net.cn/uniCloud/sms/dev.html
|
||||
return { _state: 'MSG_SEND_FAIL', result }
|
||||
}
|
||||
} catch (error) {
|
||||
// 调用失败 例如 {"code":undefined,"msg":"短信发送失败:账户余额不足"}
|
||||
return {
|
||||
_state: 'MSG_SEND_FAIL',
|
||||
_state: 'MSG_SEND_ERROR',
|
||||
error, // { errCode, errMsg }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async sendSmsTencent ({ phone, config, msgTemplate, msgParam, appid, signName } = {}) {
|
||||
sender.smsClientTencent = sender.smsClientTencent || new (require('tencentcloud-sdk-nodejs').sms.v20210111.Client)(config) // https://cloud.tencent.com/document/product/382/43197
|
||||
|
||||
return await sender.smsClientTencent
|
||||
.SendSms({
|
||||
// API: https://cloud.tencent.com/document/product/382/55981
|
||||
PhoneNumberSet: [phone.replace('-', '')],
|
||||
SmsSdkAppId: appid || config.appid,
|
||||
SignName: signName || config.signName,
|
||||
TemplateId: msgTemplate || config.msgTemplate,
|
||||
TemplateParamSet: Object.values(msgParam),
|
||||
})
|
||||
.then(
|
||||
function ({ SendStatusSet, RequestId } = {}) {
|
||||
let { SerialNo, PhoneNumber, Fee, Code, Message, IsoCode } = SendStatusSet[0]
|
||||
if (Code === 'Ok') {
|
||||
return { _state: 'MSG_SENT_SUCCESS' }
|
||||
} else {
|
||||
return { _state: 'MSG_SEND_FAIL', error: { SendStatusSet, RequestId } }
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
return { _state: 'SMS_SEND_ERROR', error }
|
||||
}
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,54 +1,72 @@
|
||||
# https://help.seafile.com/syncing_client/excluding_files/
|
||||
# 注释。通配符:* 匹配0到若干个字符,包括代表目录的/。? 匹配1个字符,包括/。
|
||||
# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。
|
||||
# 在这种情况下,
|
||||
# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。
|
||||
# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。
|
||||
# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。
|
||||
|
||||
# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步
|
||||
*.sfignore
|
||||
*.sfignore.*
|
||||
*.sfignore/
|
||||
*.sfignore.*/
|
||||
|
||||
.DS_Store
|
||||
*/.DS_Store
|
||||
|
||||
.thumbnails
|
||||
*/.thumbnails
|
||||
|
||||
Thumbs.db
|
||||
*/Thumbs.db
|
||||
thumbs.db
|
||||
*/thumbs.db
|
||||
|
||||
_desktop.ini
|
||||
*/_desktop.ini
|
||||
|
||||
._*
|
||||
*/._*
|
||||
|
||||
.$*
|
||||
*/.$*
|
||||
|
||||
~$*
|
||||
*/~$*
|
||||
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
package-lock.json
|
||||
|
||||
pages4loader.json5
|
||||
|
||||
.svn/
|
||||
*/.svn/
|
||||
|
||||
.deploy_git/
|
||||
*/.deploy_git/
|
||||
|
||||
unpackage/
|
||||
*/unpackage/
|
||||
|
||||
Icon
|
||||
OneDrive/Icon
|
||||
# https://help.seafile.com/syncing_client/excluding_files/
|
||||
# 注释。通配符:* 匹配0到若干个字符,包括代表目录的/。? 匹配1个字符,包括/。
|
||||
# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。
|
||||
# 在这种情况下,
|
||||
# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。
|
||||
# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。
|
||||
# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。
|
||||
|
||||
### seafile-ignore.global.txt ###
|
||||
|
||||
# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步
|
||||
*.sfignore
|
||||
*.sfignore/
|
||||
*.sfignore.*
|
||||
*.sfignore.*/
|
||||
*.sfomit
|
||||
*.sfomit.*
|
||||
*.sfomit/
|
||||
*.sfomit.*/
|
||||
*.nosf
|
||||
*.nosf.*
|
||||
*.nosf/
|
||||
*.nosf.*/
|
||||
|
||||
.DS_Store
|
||||
*/.DS_Store
|
||||
|
||||
.thumbnails
|
||||
*/.thumbnails
|
||||
|
||||
Thumbs.db
|
||||
*/Thumbs.db
|
||||
thumbs.db
|
||||
*/thumbs.db
|
||||
|
||||
_desktop.ini
|
||||
*/_desktop.ini
|
||||
|
||||
._*
|
||||
*/._*
|
||||
|
||||
.$*
|
||||
*/.$*
|
||||
|
||||
~$*
|
||||
*/~$*
|
||||
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
package-lock.json
|
||||
|
||||
pages4loader.json5
|
||||
|
||||
.deploy_git/
|
||||
*/.deploy_git/
|
||||
|
||||
# HBuilder 目录
|
||||
unpackage/
|
||||
*/unpackage/
|
||||
|
||||
Icon
|
||||
OneDrive/Icon
|
||||
|
||||
# wrangler project
|
||||
|
||||
.dev.vars*
|
||||
*/.dev.vars*
|
||||
.wrangler/
|
||||
*/.wrangler/
|
||||
|
||||
### seafile-ignore.local.txt ###
|
||||
|
||||
|
||||
Reference in New Issue
Block a user