tkserver 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/index.js +16 -0
- package/mongo.js +16 -0
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -32,6 +32,7 @@ const {
|
|
|
32
32
|
getQQAvatar,
|
|
33
33
|
getPasswordStatus,
|
|
34
34
|
preCheckSpam,
|
|
35
|
+
checkTurnstileCaptcha,
|
|
35
36
|
getConfig,
|
|
36
37
|
getConfigForAdmin,
|
|
37
38
|
validate
|
|
@@ -603,6 +604,8 @@ async function commentSubmit (event, request) {
|
|
|
603
604
|
validate(event, ['url', 'ua', 'comment'])
|
|
604
605
|
// 限流
|
|
605
606
|
await limitFilter(request)
|
|
607
|
+
// 验证码
|
|
608
|
+
await checkCaptcha(event, request)
|
|
606
609
|
// 预检测、转换
|
|
607
610
|
const data = await parse(event, request)
|
|
608
611
|
// 保存
|
|
@@ -709,6 +712,16 @@ async function limitFilter (request) {
|
|
|
709
712
|
}
|
|
710
713
|
}
|
|
711
714
|
|
|
715
|
+
async function checkCaptcha (comment, request) {
|
|
716
|
+
if (config.TURNSTILE_SITE_KEY && config.TURNSTILE_SECRET_KEY) {
|
|
717
|
+
await checkTurnstileCaptcha({
|
|
718
|
+
ip: getIp(request),
|
|
719
|
+
turnstileToken: comment.turnstileToken,
|
|
720
|
+
turnstileTokenSecretKey: config.TURNSTILE_SECRET_KEY
|
|
721
|
+
})
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
712
725
|
async function saveSpamCheckResult (comment, isSpam) {
|
|
713
726
|
comment.isSpam = isSpam
|
|
714
727
|
if (isSpam) {
|
|
@@ -813,6 +826,9 @@ async function getRecentComments (event) {
|
|
|
813
826
|
try {
|
|
814
827
|
const query = {}
|
|
815
828
|
query.isSpam = { $ne: true }
|
|
829
|
+
if (event.urls && event.urls.length) {
|
|
830
|
+
query.url = { $in: getUrlsQuery(event.urls) }
|
|
831
|
+
}
|
|
816
832
|
if (!event.includeReply) query.rid = { $exists: false }
|
|
817
833
|
if (event.pageSize > 100) event.pageSize = 100
|
|
818
834
|
const result = db
|
package/mongo.js
CHANGED
|
@@ -30,6 +30,7 @@ const {
|
|
|
30
30
|
getQQAvatar,
|
|
31
31
|
getPasswordStatus,
|
|
32
32
|
preCheckSpam,
|
|
33
|
+
checkTurnstileCaptcha,
|
|
33
34
|
getConfig,
|
|
34
35
|
getConfigForAdmin,
|
|
35
36
|
validate
|
|
@@ -585,6 +586,8 @@ async function commentSubmit (event, request) {
|
|
|
585
586
|
validate(event, ['url', 'ua', 'comment'])
|
|
586
587
|
// 限流
|
|
587
588
|
await limitFilter(request)
|
|
589
|
+
// 验证码
|
|
590
|
+
await checkCaptcha(event, request)
|
|
588
591
|
// 预检测、转换
|
|
589
592
|
const data = await parse(event, request)
|
|
590
593
|
// 保存
|
|
@@ -691,6 +694,16 @@ async function limitFilter (request) {
|
|
|
691
694
|
}
|
|
692
695
|
}
|
|
693
696
|
|
|
697
|
+
async function checkCaptcha (comment, request) {
|
|
698
|
+
if (config.TURNSTILE_SITE_KEY && config.TURNSTILE_SECRET_KEY) {
|
|
699
|
+
await checkTurnstileCaptcha({
|
|
700
|
+
ip: getIp(request),
|
|
701
|
+
turnstileToken: comment.turnstileToken,
|
|
702
|
+
turnstileTokenSecretKey: config.TURNSTILE_SECRET_KEY
|
|
703
|
+
})
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
694
707
|
async function saveSpamCheckResult (comment, isSpam) {
|
|
695
708
|
comment.isSpam = isSpam
|
|
696
709
|
if (isSpam) {
|
|
@@ -807,6 +820,9 @@ async function getRecentComments (event) {
|
|
|
807
820
|
try {
|
|
808
821
|
const query = {}
|
|
809
822
|
query.isSpam = { $ne: true }
|
|
823
|
+
if (event.urls && event.urls.length) {
|
|
824
|
+
query.url = { $in: getUrlsQuery(event.urls) }
|
|
825
|
+
}
|
|
810
826
|
if (!event.includeReply) query.rid = { $in: ['', null] }
|
|
811
827
|
if (event.pageSize > 100) event.pageSize = 100
|
|
812
828
|
const result = await db
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tkserver",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.28",
|
|
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.28",
|
|
35
35
|
"uuid": "^8.3.2"
|
|
36
36
|
}
|
|
37
37
|
}
|