tkserver 1.6.19 → 1.6.20
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 +6 -4
- package/mongo.js +6 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -23,6 +23,8 @@ const {
|
|
|
23
23
|
getUrlsQuery,
|
|
24
24
|
parseComment,
|
|
25
25
|
parseCommentForAdmin,
|
|
26
|
+
normalizeMail,
|
|
27
|
+
equalsMail,
|
|
26
28
|
getMailMd5,
|
|
27
29
|
getAvatar,
|
|
28
30
|
isQQ,
|
|
@@ -143,7 +145,7 @@ module.exports = async (request, response) => {
|
|
|
143
145
|
res.message = '请更新 Twikoo 云函数至最新版本'
|
|
144
146
|
} else {
|
|
145
147
|
res.code = RES_CODE.NO_PARAM
|
|
146
|
-
res.message = 'Twikoo 云函数运行正常,请参考 https://twikoo.js.org/
|
|
148
|
+
res.message = 'Twikoo 云函数运行正常,请参考 https://twikoo.js.org/frontend.html 完成前端的配置'
|
|
147
149
|
res.version = VERSION
|
|
148
150
|
}
|
|
149
151
|
}
|
|
@@ -647,14 +649,14 @@ async function postSubmit (comment) {
|
|
|
647
649
|
async function parse (comment, request) {
|
|
648
650
|
const timestamp = Date.now()
|
|
649
651
|
const isAdminUser = isAdmin(request.body.accessToken)
|
|
650
|
-
const isBloggerMail = comment.mail
|
|
652
|
+
const isBloggerMail = equalsMail(comment.mail, config.BLOGGER_EMAIL)
|
|
651
653
|
if (isBloggerMail && !isAdminUser) throw new Error('请先登录管理面板,再使用博主身份发送评论')
|
|
652
654
|
const commentDo = {
|
|
653
655
|
_id: uuidv4().replace(/-/g, ''),
|
|
654
656
|
uid: request.body.accessToken,
|
|
655
657
|
nick: comment.nick ? comment.nick : '匿名',
|
|
656
658
|
mail: comment.mail ? comment.mail : '',
|
|
657
|
-
mailMd5: comment.mail ? md5(comment.mail) : '',
|
|
659
|
+
mailMd5: comment.mail ? md5(normalizeMail(comment.mail)) : '',
|
|
658
660
|
link: comment.link ? comment.link : '',
|
|
659
661
|
ua: comment.ua,
|
|
660
662
|
ip: getIp(request),
|
|
@@ -670,7 +672,7 @@ async function parse (comment, request) {
|
|
|
670
672
|
}
|
|
671
673
|
if (isQQ(comment.mail)) {
|
|
672
674
|
commentDo.mail = addQQMailSuffix(comment.mail)
|
|
673
|
-
commentDo.mailMd5 = md5(commentDo.mail)
|
|
675
|
+
commentDo.mailMd5 = md5(normalizeMail(commentDo.mail))
|
|
674
676
|
commentDo.avatar = await getQQAvatar(comment.mail)
|
|
675
677
|
}
|
|
676
678
|
return commentDo
|
package/mongo.js
CHANGED
|
@@ -21,6 +21,8 @@ const {
|
|
|
21
21
|
getUrlsQuery,
|
|
22
22
|
parseComment,
|
|
23
23
|
parseCommentForAdmin,
|
|
24
|
+
normalizeMail,
|
|
25
|
+
equalsMail,
|
|
24
26
|
getMailMd5,
|
|
25
27
|
getAvatar,
|
|
26
28
|
isQQ,
|
|
@@ -140,7 +142,7 @@ module.exports = async (request, response) => {
|
|
|
140
142
|
res.message = '请更新 Twikoo 云函数至最新版本'
|
|
141
143
|
} else {
|
|
142
144
|
res.code = RES_CODE.NO_PARAM
|
|
143
|
-
res.message = 'Twikoo 云函数运行正常,请参考 https://twikoo.js.org/
|
|
145
|
+
res.message = 'Twikoo 云函数运行正常,请参考 https://twikoo.js.org/frontend.html 完成前端的配置'
|
|
144
146
|
res.version = VERSION
|
|
145
147
|
}
|
|
146
148
|
}
|
|
@@ -629,14 +631,14 @@ async function postSubmit (comment) {
|
|
|
629
631
|
async function parse (comment, request) {
|
|
630
632
|
const timestamp = Date.now()
|
|
631
633
|
const isAdminUser = isAdmin(request.body.accessToken)
|
|
632
|
-
const isBloggerMail = comment.mail
|
|
634
|
+
const isBloggerMail = equalsMail(comment.mail, config.BLOGGER_EMAIL)
|
|
633
635
|
if (isBloggerMail && !isAdminUser) throw new Error('请先登录管理面板,再使用博主身份发送评论')
|
|
634
636
|
const commentDo = {
|
|
635
637
|
_id: uuidv4().replace(/-/g, ''),
|
|
636
638
|
uid: request.body.accessToken,
|
|
637
639
|
nick: comment.nick ? comment.nick : '匿名',
|
|
638
640
|
mail: comment.mail ? comment.mail : '',
|
|
639
|
-
mailMd5: comment.mail ? md5(comment.mail) : '',
|
|
641
|
+
mailMd5: comment.mail ? md5(normalizeMail(comment.mail)) : '',
|
|
640
642
|
link: comment.link ? comment.link : '',
|
|
641
643
|
ua: comment.ua,
|
|
642
644
|
ip: getIp(request),
|
|
@@ -652,7 +654,7 @@ async function parse (comment, request) {
|
|
|
652
654
|
}
|
|
653
655
|
if (isQQ(comment.mail)) {
|
|
654
656
|
commentDo.mail = addQQMailSuffix(comment.mail)
|
|
655
|
-
commentDo.mailMd5 = md5(commentDo.mail)
|
|
657
|
+
commentDo.mailMd5 = md5(normalizeMail(commentDo.mail))
|
|
656
658
|
commentDo.avatar = await getQQAvatar(comment.mail)
|
|
657
659
|
}
|
|
658
660
|
return commentDo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tkserver",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.20",
|
|
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": "^3.6.3",
|
|
34
|
-
"twikoo-func": "1.6.
|
|
34
|
+
"twikoo-func": "1.6.20",
|
|
35
35
|
"uuid": "^8.3.2"
|
|
36
36
|
}
|
|
37
37
|
}
|