twikoo-vercel 1.7.22 → 1.7.24
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 +8 -5
- package/package.json +2 -2
package/api/index.js
CHANGED
|
@@ -39,6 +39,7 @@ const {
|
|
|
39
39
|
getConfig,
|
|
40
40
|
getConfigForAdmin,
|
|
41
41
|
validate,
|
|
42
|
+
validateClientFields,
|
|
42
43
|
checkCommentOwnership,
|
|
43
44
|
isValidEmail
|
|
44
45
|
} = require('twikoo-func/utils')
|
|
@@ -86,6 +87,8 @@ module.exports = async (request, response) => {
|
|
|
86
87
|
let res = {}
|
|
87
88
|
try {
|
|
88
89
|
protect(request)
|
|
90
|
+
// 统一校验客户端字段类型,防止查询操作符对象注入数据库查询条件
|
|
91
|
+
validateClientFields(event)
|
|
89
92
|
accessToken = anonymousSignIn(request)
|
|
90
93
|
await connectToDatabase(process.env.MONGODB_URI)
|
|
91
94
|
await readConfig()
|
|
@@ -325,7 +328,7 @@ async function commentGet (event, accessToken) {
|
|
|
325
328
|
url: { $in: getUrlQuery(event.url) },
|
|
326
329
|
rid: { $in: ['', null] }
|
|
327
330
|
}
|
|
328
|
-
//
|
|
331
|
+
// 按当前用户和配置查询可见评论
|
|
329
332
|
query = getCommentQuery({ condition, uid, isAdminUser })
|
|
330
333
|
// 读取总条数
|
|
331
334
|
const count = await db
|
|
@@ -365,10 +368,7 @@ async function commentGet (event, accessToken) {
|
|
|
365
368
|
let top = []
|
|
366
369
|
if (!config.TOP_DISABLED && !event.before) {
|
|
367
370
|
// 查询置顶评论
|
|
368
|
-
query = {
|
|
369
|
-
...condition,
|
|
370
|
-
top: true
|
|
371
|
-
}
|
|
371
|
+
query = getCommentQuery({ condition: { ...condition, top: true }, uid, isAdminUser })
|
|
372
372
|
top = await db
|
|
373
373
|
.collection('comment')
|
|
374
374
|
.find(query)
|
|
@@ -456,6 +456,9 @@ async function commentSearch (event, accessToken) {
|
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
function getCommentQuery ({ condition, uid, isAdminUser }) {
|
|
459
|
+
if (config.HIDE_SPAM === 'true') {
|
|
460
|
+
return { ...condition, isSpam: { $ne: true } }
|
|
461
|
+
}
|
|
459
462
|
return {
|
|
460
463
|
$or: [
|
|
461
464
|
{ ...condition, isSpam: { $ne: isAdminUser ? 'imaegoo' : true } },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twikoo-vercel",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.24",
|
|
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.24",
|
|
17
17
|
"uuid": "^8.3.2"
|
|
18
18
|
}
|
|
19
19
|
}
|