twikoo-func 1.6.35 → 1.6.36
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 +3 -1
- package/package.json +1 -1
- package/utils/index.js +17 -5
- package/utils/lib.js +7 -1
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
getCheerio,
|
|
11
11
|
getDomPurify,
|
|
12
12
|
getMd5,
|
|
13
|
+
getSha256,
|
|
13
14
|
getXml2js
|
|
14
15
|
} = require('./utils/lib')
|
|
15
16
|
const {
|
|
@@ -53,6 +54,7 @@ const _ = db.command
|
|
|
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
|
|
@@ -624,7 +626,7 @@ async function parse (comment) {
|
|
|
624
626
|
uid: await getUid(),
|
|
625
627
|
nick: comment.nick ? comment.nick : '匿名',
|
|
626
628
|
mail: comment.mail ? comment.mail : '',
|
|
627
|
-
mailMd5: comment.mail ?
|
|
629
|
+
mailMd5: comment.mail ? sha256(normalizeMail(comment.mail)) : '',
|
|
628
630
|
link: comment.link ? comment.link : '',
|
|
629
631
|
ua: comment.ua,
|
|
630
632
|
ip: auth.getClientIP(),
|
package/package.json
CHANGED
package/utils/index.js
CHANGED
|
@@ -4,12 +4,14 @@ const {
|
|
|
4
4
|
getFormData,
|
|
5
5
|
getBowser,
|
|
6
6
|
getIpToRegion,
|
|
7
|
-
getMd5
|
|
7
|
+
getMd5,
|
|
8
|
+
getSha256
|
|
8
9
|
} = require('./lib')
|
|
9
10
|
const axios = getAxios()
|
|
10
11
|
const FormData = getFormData()
|
|
11
12
|
const bowser = getBowser()
|
|
12
13
|
const md5 = getMd5()
|
|
14
|
+
const sha256 = getSha256()
|
|
13
15
|
const { RES_CODE } = require('./constants')
|
|
14
16
|
const logger = require('./logger')
|
|
15
17
|
|
|
@@ -183,14 +185,23 @@ const fn = {
|
|
|
183
185
|
}
|
|
184
186
|
return md5(comment.nick)
|
|
185
187
|
},
|
|
188
|
+
getMailSha256 (comment) {
|
|
189
|
+
if (comment.mail) {
|
|
190
|
+
return sha256(fn.normalizeMail(comment.mail))
|
|
191
|
+
}
|
|
192
|
+
return sha256(comment.nick)
|
|
193
|
+
},
|
|
186
194
|
getAvatar (comment, config) {
|
|
187
195
|
if (comment.avatar) {
|
|
188
196
|
return comment.avatar
|
|
189
197
|
} else {
|
|
190
|
-
const gravatarCdn = config.GRAVATAR_CDN || '
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
198
|
+
const gravatarCdn = config.GRAVATAR_CDN || 'weavatar.com'
|
|
199
|
+
let defaultGravatar = gravatarCdn === 'weavatar.com' ? `letter&letter=${comment.nick.charAt(0)}` : 'identicon'
|
|
200
|
+
if (config.DEFAULT_GRAVATAR) {
|
|
201
|
+
defaultGravatar = config.DEFAULT_GRAVATAR
|
|
202
|
+
}
|
|
203
|
+
const mailHash = gravatarCdn === 'cravatar.cn' ? fn.getMailMd5(comment) : fn.getMailSha256(comment) // Cravatar 不支持 sha256
|
|
204
|
+
return `https://${gravatarCdn}/avatar/${mailHash}?d=${defaultGravatar}`
|
|
194
205
|
}
|
|
195
206
|
},
|
|
196
207
|
isUrl (s) {
|
|
@@ -296,6 +307,7 @@ const fn = {
|
|
|
296
307
|
HIDE_ADMIN_CRYPT: config.HIDE_ADMIN_CRYPT,
|
|
297
308
|
HIGHLIGHT: config.HIGHLIGHT || 'true',
|
|
298
309
|
HIGHLIGHT_THEME: config.HIGHLIGHT_THEME,
|
|
310
|
+
HIGHLIGHT_PLUGIN: config.HIGHLIGHT_PLUGIN,
|
|
299
311
|
LIMIT_LENGTH: config.LIMIT_LENGTH,
|
|
300
312
|
TURNSTILE_SITE_KEY: config.TURNSTILE_SITE_KEY
|
|
301
313
|
}
|
package/utils/lib.js
CHANGED
|
@@ -46,9 +46,15 @@ module.exports = {
|
|
|
46
46
|
return marked
|
|
47
47
|
},
|
|
48
48
|
getMd5 () {
|
|
49
|
-
const md5 = require('blueimp-md5') // MD5
|
|
49
|
+
const md5 = require('blueimp-md5') // MD5 哈希
|
|
50
50
|
return md5
|
|
51
51
|
},
|
|
52
|
+
getSha256 () {
|
|
53
|
+
const { SHA256 } = require('crypto-js') // SHA256 哈希
|
|
54
|
+
return (message) => {
|
|
55
|
+
return SHA256(message).toString()
|
|
56
|
+
}
|
|
57
|
+
},
|
|
52
58
|
getNodemailer () {
|
|
53
59
|
if (customLibs.nodemailer) return customLibs.nodemailer
|
|
54
60
|
const nodemailer = require('nodemailer') // 发送邮件
|