twikoo-func 1.6.1 → 1.6.4
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/index.js +1 -1
- package/package.json +1 -1
- package/utils/image.js +3 -0
- package/utils/index.js +4 -2
- package/utils/notify.js +1 -1
package/index.js
CHANGED
|
@@ -575,7 +575,7 @@ async function getParentComment (currentComment) {
|
|
|
575
575
|
async function postSubmit (comment, context) {
|
|
576
576
|
if (!isRecursion(context)) return { code: RES_CODE.FORBIDDEN }
|
|
577
577
|
// 垃圾检测
|
|
578
|
-
const isSpam = await postCheckSpam(comment)
|
|
578
|
+
const isSpam = await postCheckSpam(comment, config)
|
|
579
579
|
await saveSpamCheckResult(comment, isSpam)
|
|
580
580
|
// 发送通知
|
|
581
581
|
await sendNotice(comment, config, getParentComment)
|
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
|
@@ -87,6 +87,8 @@ const fn = {
|
|
|
87
87
|
getIpRegion ({ ip, detail = false }) {
|
|
88
88
|
if (!ip) return ''
|
|
89
89
|
try {
|
|
90
|
+
// 将 IPv6 格式的 IPv4 地址转换为 IPv4 格式
|
|
91
|
+
ip = ip.replace(/^::ffff:/, '')
|
|
90
92
|
const { region } = ipRegionSearcher.binarySearchSync(ip)
|
|
91
93
|
const [country,, province, city, isp] = region.split('|')
|
|
92
94
|
// 有省显示省,没有省显示国家
|
|
@@ -94,10 +96,10 @@ const fn = {
|
|
|
94
96
|
if (detail) {
|
|
95
97
|
return area === city ? [city, isp].join(' ') : [area, city, isp].join(' ')
|
|
96
98
|
} else {
|
|
97
|
-
return area
|
|
99
|
+
return area.replace(/(省|市)$/, '')
|
|
98
100
|
}
|
|
99
101
|
} catch (e) {
|
|
100
|
-
console.error('IP 属地查询失败:', e)
|
|
102
|
+
console.error('IP 属地查询失败:', e.message)
|
|
101
103
|
return ''
|
|
102
104
|
}
|
|
103
105
|
},
|
package/utils/notify.js
CHANGED
|
@@ -155,7 +155,7 @@ const fn = {
|
|
|
155
155
|
async noticeReply (currentComment, config, getParentComment) {
|
|
156
156
|
if (!currentComment.pid) return
|
|
157
157
|
if (!transporter) if (!await fn.initMailer({ config })) return
|
|
158
|
-
const parentComment = await getParentComment()
|
|
158
|
+
const parentComment = await getParentComment(currentComment)
|
|
159
159
|
// 回复给博主,因为会发博主通知邮件,所以不再重复通知
|
|
160
160
|
if (config.BLOGGER_EMAIL === parentComment.mail) return
|
|
161
161
|
// 回复自己的评论,不邮件通知
|