twikoo-vercel 1.6.26 → 1.6.28
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/api/index.js +17 -1
- package/package.json +2 -2
package/api/index.js
CHANGED
|
@@ -31,6 +31,7 @@ const {
|
|
|
31
31
|
getQQAvatar,
|
|
32
32
|
getPasswordStatus,
|
|
33
33
|
preCheckSpam,
|
|
34
|
+
checkTurnstileCaptcha,
|
|
34
35
|
getConfig,
|
|
35
36
|
getConfigForAdmin,
|
|
36
37
|
validate
|
|
@@ -596,6 +597,8 @@ async function commentSubmit (event, request) {
|
|
|
596
597
|
validate(event, ['url', 'ua', 'comment'])
|
|
597
598
|
// 限流
|
|
598
599
|
await limitFilter(request)
|
|
600
|
+
// 验证码
|
|
601
|
+
await checkCaptcha(event, request)
|
|
599
602
|
// 预检测、转换
|
|
600
603
|
const data = await parse(event, request)
|
|
601
604
|
// 保存
|
|
@@ -615,7 +618,7 @@ async function commentSubmit (event, request) {
|
|
|
615
618
|
])
|
|
616
619
|
logger.log('POST_SUBMIT')
|
|
617
620
|
} catch (e) {
|
|
618
|
-
logger.error('POST_SUBMIT 失败', e)
|
|
621
|
+
logger.error('POST_SUBMIT 失败', e.message)
|
|
619
622
|
}
|
|
620
623
|
return res
|
|
621
624
|
}
|
|
@@ -711,6 +714,16 @@ async function limitFilter (request) {
|
|
|
711
714
|
}
|
|
712
715
|
}
|
|
713
716
|
|
|
717
|
+
async function checkCaptcha (comment, request) {
|
|
718
|
+
if (config.TURNSTILE_SITE_KEY && config.TURNSTILE_SECRET_KEY) {
|
|
719
|
+
await checkTurnstileCaptcha({
|
|
720
|
+
ip: getIp(request),
|
|
721
|
+
turnstileToken: comment.turnstileToken,
|
|
722
|
+
turnstileTokenSecretKey: config.TURNSTILE_SECRET_KEY
|
|
723
|
+
})
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
714
727
|
async function saveSpamCheckResult (comment, isSpam) {
|
|
715
728
|
comment.isSpam = isSpam
|
|
716
729
|
if (isSpam) {
|
|
@@ -827,6 +840,9 @@ async function getRecentComments (event) {
|
|
|
827
840
|
try {
|
|
828
841
|
const query = {}
|
|
829
842
|
query.isSpam = { $ne: true }
|
|
843
|
+
if (event.urls && event.urls.length) {
|
|
844
|
+
query.url = { $in: getUrlsQuery(event.urls) }
|
|
845
|
+
}
|
|
830
846
|
if (!event.includeReply) query.rid = { $in: ['', null] }
|
|
831
847
|
if (event.pageSize > 100) event.pageSize = 100
|
|
832
848
|
const result = await db
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twikoo-vercel",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.28",
|
|
4
4
|
"description": "A simple comment system.",
|
|
5
5
|
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"get-user-ip": "^1.0.1",
|
|
15
15
|
"mongodb": "^3.6.3",
|
|
16
|
-
"twikoo-func": "1.6.
|
|
16
|
+
"twikoo-func": "1.6.28",
|
|
17
17
|
"uuid": "^8.3.2"
|
|
18
18
|
}
|
|
19
19
|
}
|