twikoo-func 1.6.0-beta.2 → 1.6.2

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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twikoo-func",
3
- "version": "1.6.0-beta.2",
3
+ "version": "1.6.2",
4
4
  "description": "A simple comment system.",
5
5
  "author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
6
6
  "license": "MIT",
@@ -13,6 +13,7 @@
13
13
  "dependencies": {
14
14
  "@cloudbase/manager-node": "^3.9.0",
15
15
  "@cloudbase/node-sdk": "^2.5.0",
16
+ "@imaegoo/node-ip2region": "^2.1.1",
16
17
  "akismet-api": "^5.1.0",
17
18
  "axios": "^0.21.1",
18
19
  "blueimp-md5": "^2.18.0",
@@ -20,7 +21,6 @@
20
21
  "cheerio": "1.0.0-rc.5",
21
22
  "crypto-js": "^4.0.0",
22
23
  "dompurify": "^2.2.6",
23
- "dy-node-ip2region": "^1.0.1",
24
24
  "form-data": "^4.0.0",
25
25
  "jsdom": "^16.4.0",
26
26
  "marked": "^4.0.12",
package/utils/import.js CHANGED
@@ -196,6 +196,12 @@ const fn = {
196
196
  // 解决 id 历史数据问题
197
197
  parsed._id = comment._id.$oid
198
198
  }
199
+ if (comment.pid === null) {
200
+ delete comment.pid
201
+ }
202
+ if (comment.rid === null) {
203
+ delete comment.rid
204
+ }
199
205
  comments.push(parsed)
200
206
  log(`${comment._id} 解析成功`)
201
207
  } catch (e) {
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
  // 有省显示省,没有省显示国家
@@ -97,7 +99,7 @@ const fn = {
97
99
  return area
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/lib.js CHANGED
@@ -6,7 +6,7 @@ const { JSDOM } = require('jsdom') // document.window 服务器版
6
6
  const axios = require('axios') // 发送 REST 请求
7
7
  const bowser = require('bowser') // UserAgent 格式化
8
8
  const createDOMPurify = require('dompurify') // 反 XSS
9
- const ipToRegion = require('dy-node-ip2region') // IP 属地查询
9
+ const ipToRegion = require('@imaegoo/node-ip2region') // IP 属地查询
10
10
  const marked = require('marked') // Markdown 解析
11
11
  const md5 = require('blueimp-md5') // MD5 加解密
12
12
  const nodemailer = require('nodemailer') // 发送邮件
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
  // 回复自己的评论,不邮件通知