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.
|
# 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/
|
.svn/
|
||||||
.deploy_git/
|
.deploy_git/
|
||||||
.idea/
|
.idea/
|
||||||
.sass-cache/
|
.sass-cache/
|
||||||
|
.wrangler
|
||||||
/test/unit/coverage/
|
/test/unit/coverage/
|
||||||
/test/e2e/reports/
|
/test/e2e/reports/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
*.aab
|
||||||
*.apk
|
*.apk
|
||||||
|
*.ipa
|
||||||
*.min.js
|
*.min.js
|
||||||
*.min.css
|
*.min.css
|
||||||
*.min.html
|
*.min.html
|
||||||
@@ -70,7 +96,6 @@ _desktop.ini
|
|||||||
/db.json
|
/db.json
|
||||||
|
|
||||||
# wo
|
# wo
|
||||||
*.gitignore.*
|
|
||||||
# 服务端
|
# 服务端
|
||||||
/_archive/*
|
/_archive/*
|
||||||
/_datastore/*
|
/_datastore/*
|
||||||
@@ -84,5 +109,5 @@ _desktop.ini
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
pages4loader.json5
|
pages4loader.json5
|
||||||
|
|
||||||
# 保留
|
### .gitignore.local.txt ###
|
||||||
!.gitkeep
|
|
||||||
|
|||||||
123
messenger.js
123
messenger.js
@@ -13,21 +13,38 @@ module.exports = {
|
|||||||
|
|
||||||
// 或者如果smtp参数已经确定,就可以直接定义 sendMail: Bluebird.promisify(Smtp.sendMail).bind(Smtp)
|
// 或者如果smtp参数已经确定,就可以直接定义 sendMail: Bluebird.promisify(Smtp.sendMail).bind(Smtp)
|
||||||
async sendMail (messageObject, smtp = my.envar?.SMTP || wo?.envar?.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 }
|
// messageObject: { from, to, cc, bcc, subject, text, html, sender, replyTo, inReplyTo }
|
||||||
sender.smtpTransporter = sender.smtpTransporter || NodeMailer.createTransport(smtp)
|
sender.smtpTransporter = sender.smtpTransporter || NodeMailer.createTransport(smtp)
|
||||||
return await sender.smtpTransporter
|
return await sender.smtpTransporter
|
||||||
.sendMail(messageObject)
|
.sendMail(messageObject)
|
||||||
.then((result) => {
|
.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) => {
|
.catch((error) => {
|
||||||
console.log(err)
|
globalThis.wo?.ccerror?.({ _state: 'MSG_SEND_ERROR', subject: messageObject.subject, error })
|
||||||
return { _state: 'SMS_SEND_ERROR' }
|
return { _state: 'MSG_SEND_ERROR' }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -41,21 +58,28 @@ module.exports = {
|
|||||||
signName, // for 'ALIYUN', 'TENCENT'
|
signName, // for 'ALIYUN', 'TENCENT'
|
||||||
appid, // for 'UNICLOUD', 'TENCENT'
|
appid, // for 'UNICLOUD', 'TENCENT'
|
||||||
} = {}) {
|
} = {}) {
|
||||||
|
let result
|
||||||
if (/^\+\d+-\d+$/.test(phone)) {
|
if (/^\+\d+-\d+$/.test(phone)) {
|
||||||
if (config.vendor === 'DXTON') {
|
if (!config?.vendor) {
|
||||||
return await this.sendSmsDxton({ phone, config, msg })
|
result = { _state: 'SMS_CONFIG_MALFORMED', phone, config }
|
||||||
|
} else if (config.vendor === 'DXTON') {
|
||||||
|
result = await this.sendSmsDxton({ phone, config, msg })
|
||||||
} else if (config.vendor === 'ALIYUN') {
|
} else if (config.vendor === 'ALIYUN') {
|
||||||
return await this.sendSmsAliyun({ phone, config, msgParam, msgTemplate, signName })
|
result = await this.sendSmsAliyun({ phone, config, msgParam, msgTemplate, signName })
|
||||||
} else if (config.vendor === 'UNICLOUD') {
|
|
||||||
return await this.sendSmsUnicloud({ phone, config, msgParam, msgTemplate, appid })
|
|
||||||
} else if (config.vendor === 'TENCENT') {
|
} 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 {
|
} else {
|
||||||
return { _state: 'SMS_UNKNOWN_VENDOR', error: { unknownVendor: config.vendor } }
|
result = { _state: 'SMS_UNKNOWN_VENDOR', error: { unknownVendor: config.vendor } }
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
/* 使用 dxton.com 的短信接口 http://www.dxton.com/help_detail/38.html
|
||||||
@@ -92,7 +116,7 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.on('error', (error) => {
|
.on('error', (error) => {
|
||||||
reject({ _state: 'SMS_SEND_ERROR', error })
|
reject({ _state: 'MSG_SEND_ERROR', error })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -120,7 +144,34 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
function (error) {
|
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: '注册' }
|
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) {
|
} catch (error) {
|
||||||
// 调用失败 例如 {"code":undefined,"msg":"短信发送失败:账户余额不足"}
|
// 调用失败 例如 {"code":undefined,"msg":"短信发送失败:账户余额不足"}
|
||||||
return {
|
return {
|
||||||
_state: 'MSG_SEND_FAIL',
|
_state: 'MSG_SEND_ERROR',
|
||||||
error, // { errCode, errMsg }
|
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/
|
# https://help.seafile.com/syncing_client/excluding_files/
|
||||||
# 注释。通配符:* 匹配0到若干个字符,包括代表目录的/。? 匹配1个字符,包括/。
|
# 注释。通配符:* 匹配0到若干个字符,包括代表目录的/。? 匹配1个字符,包括/。
|
||||||
# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。
|
# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。
|
||||||
# 在这种情况下,
|
# 在这种情况下,
|
||||||
# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。
|
# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。
|
||||||
# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。
|
# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。
|
||||||
# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。
|
# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。
|
||||||
|
|
||||||
# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步
|
### seafile-ignore.global.txt ###
|
||||||
*.sfignore
|
|
||||||
*.sfignore.*
|
# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步
|
||||||
*.sfignore/
|
*.sfignore
|
||||||
*.sfignore.*/
|
*.sfignore/
|
||||||
|
*.sfignore.*
|
||||||
.DS_Store
|
*.sfignore.*/
|
||||||
*/.DS_Store
|
*.sfomit
|
||||||
|
*.sfomit.*
|
||||||
.thumbnails
|
*.sfomit/
|
||||||
*/.thumbnails
|
*.sfomit.*/
|
||||||
|
*.nosf
|
||||||
Thumbs.db
|
*.nosf.*
|
||||||
*/Thumbs.db
|
*.nosf/
|
||||||
thumbs.db
|
*.nosf.*/
|
||||||
*/thumbs.db
|
|
||||||
|
.DS_Store
|
||||||
_desktop.ini
|
*/.DS_Store
|
||||||
*/_desktop.ini
|
|
||||||
|
.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/
|
node_modules/
|
||||||
|
*/node_modules/
|
||||||
unpackage/
|
package-lock.json
|
||||||
*/unpackage/
|
|
||||||
|
pages4loader.json5
|
||||||
Icon
|
|
||||||
OneDrive/Icon
|
.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