tkserver 1.7.22 → 1.7.23

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.
Files changed (3) hide show
  1. package/index.js +5 -5
  2. package/mongo.js +5 -5
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -334,7 +334,7 @@ async function commentGet (event) {
334
334
  url: { $in: getUrlQuery(event.url) },
335
335
  rid: { $exists: false }
336
336
  }
337
- // 查询非垃圾评论 + 自己的评论
337
+ // 按当前用户和配置查询可见评论
338
338
  query = getCommentQuery({ condition, uid, isAdminUser })
339
339
  // 读取总条数
340
340
  const count = db
@@ -374,10 +374,7 @@ async function commentGet (event) {
374
374
  let top = []
375
375
  if (!config.TOP_DISABLED && !event.before) {
376
376
  // 查询置顶评论
377
- query = {
378
- ...condition,
379
- top: true
380
- }
377
+ query = getCommentQuery({ condition: { ...condition, top: true }, uid, isAdminUser })
381
378
  top = db
382
379
  .getCollection('comment')
383
380
  .chain()
@@ -467,6 +464,9 @@ async function commentSearch (event) {
467
464
  }
468
465
 
469
466
  function getCommentQuery ({ condition, uid, isAdminUser }) {
467
+ if (config.HIDE_SPAM === 'true') {
468
+ return { ...condition, isSpam: { $ne: true } }
469
+ }
470
470
  return {
471
471
  $or: [
472
472
  { ...condition, isSpam: { $ne: isAdminUser ? 'imaegoo' : true } },
package/mongo.js CHANGED
@@ -324,7 +324,7 @@ async function commentGet (event) {
324
324
  url: { $in: getUrlQuery(event.url) },
325
325
  rid: { $in: ['', null] }
326
326
  }
327
- // 查询非垃圾评论 + 自己的评论
327
+ // 按当前用户和配置查询可见评论
328
328
  query = getCommentQuery({ condition, uid, isAdminUser })
329
329
  // 读取总条数
330
330
  const count = await db
@@ -364,10 +364,7 @@ async function commentGet (event) {
364
364
  let top = []
365
365
  if (!config.TOP_DISABLED && !event.before) {
366
366
  // 查询置顶评论
367
- query = {
368
- ...condition,
369
- top: true
370
- }
367
+ query = getCommentQuery({ condition: { ...condition, top: true }, uid, isAdminUser })
371
368
  top = await db
372
369
  .collection('comment')
373
370
  .find(query)
@@ -455,6 +452,9 @@ async function commentSearch (event) {
455
452
  }
456
453
 
457
454
  function getCommentQuery ({ condition, uid, isAdminUser }) {
455
+ if (config.HIDE_SPAM === 'true') {
456
+ return { ...condition, isSpam: { $ne: true } }
457
+ }
458
458
  return {
459
459
  $or: [
460
460
  { ...condition, isSpam: { $ne: isAdminUser ? 'imaegoo' : true } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tkserver",
3
- "version": "1.7.22",
3
+ "version": "1.7.23",
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": "^6.3.0",
34
- "twikoo-func": "1.7.22",
34
+ "twikoo-func": "1.7.23",
35
35
  "uuid": "^8.3.2"
36
36
  }
37
37
  }