twikoo-func 1.6.2 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/image.js +3 -0
- package/utils/index.js +1 -1
- package/utils/notify.js +32 -11
package/package.json
CHANGED
package/utils/image.js
CHANGED
|
@@ -46,6 +46,9 @@ const fn = {
|
|
|
46
46
|
// 自定义兰空图床(v2)URL
|
|
47
47
|
const formData = new FormData()
|
|
48
48
|
formData.append('file', fn.base64UrlToReadStream(photo, fileName))
|
|
49
|
+
if (process.env.TWIKOO_LSKY_STRATEGY_ID) {
|
|
50
|
+
formData.append('strategy_id', parseInt(process.env.TWIKOO_LSKY_STRATEGY_ID))
|
|
51
|
+
}
|
|
49
52
|
const url = `${imageCdn}/api/v1/upload`
|
|
50
53
|
let token = config.IMAGE_CDN_TOKEN
|
|
51
54
|
if (!token.startsWith('Bearer')) {
|
package/utils/index.js
CHANGED
package/utils/notify.js
CHANGED
|
@@ -57,12 +57,20 @@ const fn = {
|
|
|
57
57
|
},
|
|
58
58
|
// 博主通知
|
|
59
59
|
async noticeMaster (comment, config) {
|
|
60
|
-
if (!transporter
|
|
61
|
-
|
|
60
|
+
if (!transporter && !await fn.initMailer({ config })) {
|
|
61
|
+
console.log('未配置邮箱或邮箱配置有误,不通知')
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
if (config.BLOGGER_EMAIL && config.BLOGGER_EMAIL === comment.mail) {
|
|
65
|
+
console.log('博主本人评论,不发送通知给博主')
|
|
66
|
+
return
|
|
67
|
+
}
|
|
62
68
|
// 判断是否存在即时消息推送配置
|
|
63
69
|
const hasIMPushConfig = config.PUSHOO_CHANNEL && config.PUSHOO_TOKEN
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
if (hasIMPushConfig && config.SC_MAIL_NOTIFY !== 'true') {
|
|
71
|
+
console.log('存在即时消息推送配置,默认不发送邮件给博主,您可以在管理面板修改此行为')
|
|
72
|
+
return
|
|
73
|
+
}
|
|
66
74
|
const SITE_NAME = config.SITE_NAME
|
|
67
75
|
const NICK = comment.nick
|
|
68
76
|
const IMG = getAvatar(comment, config)
|
|
@@ -114,7 +122,10 @@ const fn = {
|
|
|
114
122
|
console.log('没有配置 pushoo,放弃即时消息通知')
|
|
115
123
|
return
|
|
116
124
|
}
|
|
117
|
-
if (config.BLOGGER_EMAIL === comment.mail)
|
|
125
|
+
if (config.BLOGGER_EMAIL && config.BLOGGER_EMAIL === comment.mail) {
|
|
126
|
+
console.log('博主本人评论,不发送通知给博主')
|
|
127
|
+
return
|
|
128
|
+
}
|
|
118
129
|
const pushContent = fn.getIMPushContent(comment, config)
|
|
119
130
|
const sendResult = await pushoo(config.PUSHOO_CHANNEL, {
|
|
120
131
|
token: config.PUSHOO_TOKEN,
|
|
@@ -153,13 +164,23 @@ const fn = {
|
|
|
153
164
|
},
|
|
154
165
|
// 回复通知
|
|
155
166
|
async noticeReply (currentComment, config, getParentComment) {
|
|
156
|
-
if (!currentComment.pid)
|
|
157
|
-
|
|
167
|
+
if (!currentComment.pid) {
|
|
168
|
+
console.log('无父级评论,不通知')
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
if (!transporter && !await fn.initMailer({ config })) {
|
|
172
|
+
console.log('未配置邮箱或邮箱配置有误,不通知')
|
|
173
|
+
return
|
|
174
|
+
}
|
|
158
175
|
const parentComment = await getParentComment(currentComment)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
176
|
+
if (config.BLOGGER_EMAIL === parentComment.mail) {
|
|
177
|
+
console.log('回复给博主,因为会发博主通知邮件,所以不再重复通知')
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
if (currentComment.mail === parentComment.mail) {
|
|
181
|
+
console.log('回复自己的评论,不邮件通知')
|
|
182
|
+
return
|
|
183
|
+
}
|
|
163
184
|
const PARENT_NICK = parentComment.nick
|
|
164
185
|
const IMG = getAvatar(currentComment, config)
|
|
165
186
|
const PARENT_IMG = getAvatar(parentComment, config)
|