tkserver 1.6.35 → 1.6.37

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.
Files changed (3) hide show
  1. package/index.js +4 -1
  2. package/mongo.js +4 -1
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -15,6 +15,7 @@ const {
15
15
  getCheerio,
16
16
  getDomPurify,
17
17
  getMd5,
18
+ getSha256,
18
19
  getXml2js
19
20
  } = require('twikoo-func/utils/lib')
20
21
  const {
@@ -53,6 +54,7 @@ const logger = require('twikoo-func/utils/logger')
53
54
  const $ = getCheerio()
54
55
  const DOMPurify = getDomPurify()
55
56
  const md5 = getMd5()
57
+ const sha256 = getSha256()
56
58
  const xml2js = getXml2js()
57
59
 
58
60
  // 常量 / constants
@@ -657,12 +659,13 @@ async function parse (comment, request) {
657
659
  const isAdminUser = isAdmin(request.body.accessToken)
658
660
  const isBloggerMail = equalsMail(comment.mail, config.BLOGGER_EMAIL)
659
661
  if (isBloggerMail && !isAdminUser) throw new Error('请先登录管理面板,再使用博主身份发送评论')
662
+ const hashMethod = this.gravatarCdn === 'cravatar.cn' ? md5 : sha256
660
663
  const commentDo = {
661
664
  _id: uuidv4().replace(/-/g, ''),
662
665
  uid: request.body.accessToken,
663
666
  nick: comment.nick ? comment.nick : '匿名',
664
667
  mail: comment.mail ? comment.mail : '',
665
- mailMd5: comment.mail ? md5(normalizeMail(comment.mail)) : '',
668
+ mailMd5: comment.mail ? hashMethod(normalizeMail(comment.mail)) : '',
666
669
  link: comment.link ? comment.link : '',
667
670
  ua: comment.ua,
668
671
  ip: getIp(request),
package/mongo.js CHANGED
@@ -13,6 +13,7 @@ const {
13
13
  getCheerio,
14
14
  getDomPurify,
15
15
  getMd5,
16
+ getSha256,
16
17
  getXml2js
17
18
  } = require('twikoo-func/utils/lib')
18
19
  const {
@@ -51,6 +52,7 @@ const logger = require('twikoo-func/utils/logger')
51
52
  const $ = getCheerio()
52
53
  const DOMPurify = getDomPurify()
53
54
  const md5 = getMd5()
55
+ const sha256 = getSha256()
54
56
  const xml2js = getXml2js()
55
57
 
56
58
  // 常量 / constants
@@ -636,12 +638,13 @@ async function parse (comment, request) {
636
638
  const isAdminUser = isAdmin(request.body.accessToken)
637
639
  const isBloggerMail = equalsMail(comment.mail, config.BLOGGER_EMAIL)
638
640
  if (isBloggerMail && !isAdminUser) throw new Error('请先登录管理面板,再使用博主身份发送评论')
641
+ const hashMethod = this.gravatarCdn === 'cravatar.cn' ? md5 : sha256
639
642
  const commentDo = {
640
643
  _id: uuidv4().replace(/-/g, ''),
641
644
  uid: request.body.accessToken,
642
645
  nick: comment.nick ? comment.nick : '匿名',
643
646
  mail: comment.mail ? comment.mail : '',
644
- mailMd5: comment.mail ? md5(normalizeMail(comment.mail)) : '',
647
+ mailMd5: comment.mail ? hashMethod(normalizeMail(comment.mail)) : '',
645
648
  link: comment.link ? comment.link : '',
646
649
  ua: comment.ua,
647
650
  ip: getIp(request),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tkserver",
3
- "version": "1.6.35",
3
+ "version": "1.6.37",
4
4
  "description": "A simple comment system.",
5
5
  "keywords": [
6
6
  "twikoo",
@@ -31,7 +31,7 @@
31
31
  "get-user-ip": "^1.0.1",
32
32
  "lokijs": "^1.5.12",
33
33
  "mongodb": "^6.3.0",
34
- "twikoo-func": "1.6.35",
34
+ "twikoo-func": "1.6.37",
35
35
  "uuid": "^8.3.2"
36
36
  }
37
37
  }