twikoo-func 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.
package/index.js CHANGED
@@ -284,7 +284,7 @@ async function commentGet (event) {
284
284
  url: _.in(getUrlQuery(event.url)),
285
285
  rid: _.in(['', null])
286
286
  }
287
- // 查询非垃圾评论 + 自己的评论
287
+ // 按当前用户和配置查询可见评论
288
288
  query = getCommentQuery({ condition, uid, isAdminUser })
289
289
  // 读取总条数
290
290
  const count = await db
@@ -325,10 +325,7 @@ async function commentGet (event) {
325
325
  let top = []
326
326
  if (!config.TOP_DISABLED && !event.before) {
327
327
  // 查询置顶评论
328
- query = {
329
- ...condition,
330
- top: true
331
- }
328
+ query = getCommentQuery({ condition: { ...condition, top: true }, uid, isAdminUser })
332
329
  top = await db
333
330
  .collection('comment')
334
331
  .where(query)
@@ -434,6 +431,9 @@ async function commentSearch (event) {
434
431
  }
435
432
 
436
433
  function getCommentQuery ({ condition, uid, isAdminUser }) {
434
+ if (config.HIDE_SPAM === 'true') {
435
+ return { ...condition, isSpam: _.neq(true) }
436
+ }
437
437
  return _.or(
438
438
  { ...condition, isSpam: _.neq(isAdminUser ? 'imaegoo' : true) },
439
439
  { ...condition, uid }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twikoo-func",
3
- "version": "1.7.22",
3
+ "version": "1.7.23",
4
4
  "description": "A simple comment system.",
5
5
  "author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
6
6
  "license": "MIT",
package/utils/index.js CHANGED
@@ -288,7 +288,7 @@ const fn = {
288
288
  }
289
289
  },
290
290
  // 预垃圾评论检测
291
- preCheckSpam ({ comment, nick }, config) {
291
+ preCheckSpam ({ comment, nick, link, mail }, config) {
292
292
  // 长度限制
293
293
  let limitLength = parseInt(config.LIMIT_LENGTH)
294
294
  if (Number.isNaN(limitLength)) limitLength = 500
@@ -313,9 +313,11 @@ const fn = {
313
313
  // 违禁词检测
314
314
  const commentLowerCase = comment.toLowerCase()
315
315
  const nickLowerCase = nick.toLowerCase()
316
+ const linkLowerCase = (link || '').toLowerCase()
317
+ const mailLowerCase = (mail || '').toLowerCase()
316
318
  for (const forbiddenWord of config.FORBIDDEN_WORDS.replace(/,+$/, '').split(',')) {
317
319
  const forbiddenWordLowerCase = forbiddenWord.trim().toLowerCase()
318
- if (commentLowerCase.indexOf(forbiddenWordLowerCase) !== -1 || nickLowerCase.indexOf(forbiddenWordLowerCase) !== -1) {
320
+ if (commentLowerCase.indexOf(forbiddenWordLowerCase) !== -1 || nickLowerCase.indexOf(forbiddenWordLowerCase) !== -1 || linkLowerCase.indexOf(forbiddenWordLowerCase) !== -1 || mailLowerCase.indexOf(forbiddenWordLowerCase) !== -1) {
319
321
  logger.warn('包含违禁词,直接标记为垃圾评论~')
320
322
  return true
321
323
  }