twikoo-vercel 1.7.6 → 1.7.8
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 +26 -0
- package/package.json +2 -2
package/api/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const {
|
|
|
30
30
|
isQQ,
|
|
31
31
|
addQQMailSuffix,
|
|
32
32
|
getQQAvatar,
|
|
33
|
+
getQQNick,
|
|
33
34
|
getPasswordStatus,
|
|
34
35
|
preCheckSpam,
|
|
35
36
|
checkTurnstileCaptcha,
|
|
@@ -145,6 +146,9 @@ module.exports = async (request, response) => {
|
|
|
145
146
|
case 'UPLOAD_IMAGE': // >= 1.5.0
|
|
146
147
|
res = await uploadImage(event, config)
|
|
147
148
|
break
|
|
149
|
+
case 'GET_QQ_NICK': // >= 1.7.0
|
|
150
|
+
res = await qqNickGet(event)
|
|
151
|
+
break
|
|
148
152
|
case 'COMMENT_EXPORT_FOR_ADMIN': // >= 1.6.13
|
|
149
153
|
res = await commentExportForAdmin(event)
|
|
150
154
|
break
|
|
@@ -769,11 +773,18 @@ async function checkCaptcha (comment, request) {
|
|
|
769
773
|
geeTestGenTime: comment.geeTestGenTime
|
|
770
774
|
})
|
|
771
775
|
} else if (provider === 'Cap' && config.CAP_API_ENDPOINT && config.CAP_SECRET_KEY) {
|
|
776
|
+
if (!comment.capToken) {
|
|
777
|
+
throw new Error('验证码 token 缺失,请刷新页面重试')
|
|
778
|
+
}
|
|
772
779
|
await checkCapCaptcha({
|
|
773
780
|
capToken: comment.capToken,
|
|
774
781
|
capSecretKey: config.CAP_SECRET_KEY,
|
|
775
782
|
capApiEndpoint: config.CAP_API_ENDPOINT
|
|
776
783
|
})
|
|
784
|
+
} else if (provider === 'Cap') {
|
|
785
|
+
throw new Error('Cap 验证码配置不完整,请联系管理员')
|
|
786
|
+
} else if (provider) {
|
|
787
|
+
throw new Error(`不支持的验证码类型: ${provider}`)
|
|
777
788
|
}
|
|
778
789
|
}
|
|
779
790
|
|
|
@@ -924,6 +935,21 @@ async function getRecentComments (event) {
|
|
|
924
935
|
return res
|
|
925
936
|
}
|
|
926
937
|
|
|
938
|
+
// 获取 QQ 昵称
|
|
939
|
+
async function qqNickGet (event) {
|
|
940
|
+
const res = {}
|
|
941
|
+
try {
|
|
942
|
+
validate(event, ['qq'])
|
|
943
|
+
const nick = await getQQNick(event.qq, config.QQ_API_KEY)
|
|
944
|
+
res.code = RES_CODE.SUCCESS
|
|
945
|
+
res.nick = nick
|
|
946
|
+
} catch (e) {
|
|
947
|
+
res.code = RES_CODE.FAIL
|
|
948
|
+
res.message = e.message
|
|
949
|
+
}
|
|
950
|
+
return res
|
|
951
|
+
}
|
|
952
|
+
|
|
927
953
|
// 修改配置
|
|
928
954
|
async function setConfig (event) {
|
|
929
955
|
const isAdminUser = isAdmin()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twikoo-vercel",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
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": "^6.3.0",
|
|
16
|
-
"twikoo-func": "1.7.
|
|
16
|
+
"twikoo-func": "1.7.8",
|
|
17
17
|
"uuid": "^8.3.2"
|
|
18
18
|
}
|
|
19
19
|
}
|