twikoo-func 1.5.4 → 1.5.7
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 +7 -25
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1123,7 +1123,7 @@ async function parse (comment) {
|
|
|
1123
1123
|
comment: DOMPurify.sanitize(comment.comment, { FORBID_TAGS: ['style'], FORBID_ATTR: ['style'] }),
|
|
1124
1124
|
pid: comment.pid ? comment.pid : comment.rid,
|
|
1125
1125
|
rid: comment.rid,
|
|
1126
|
-
isSpam: isAdminUser ? false : preCheckSpam(comment
|
|
1126
|
+
isSpam: isAdminUser ? false : preCheckSpam(comment),
|
|
1127
1127
|
created: timestamp,
|
|
1128
1128
|
updated: timestamp
|
|
1129
1129
|
}
|
|
@@ -1171,7 +1171,7 @@ async function limitFilter () {
|
|
|
1171
1171
|
}
|
|
1172
1172
|
|
|
1173
1173
|
// 预垃圾评论检测
|
|
1174
|
-
function preCheckSpam (comment) {
|
|
1174
|
+
function preCheckSpam ({ comment, nick }) {
|
|
1175
1175
|
// 长度限制
|
|
1176
1176
|
let limitLength = parseInt(config.LIMIT_LENGTH)
|
|
1177
1177
|
if (Number.isNaN(limitLength)) limitLength = 500
|
|
@@ -1185,7 +1185,7 @@ function preCheckSpam (comment) {
|
|
|
1185
1185
|
} else if (config.FORBIDDEN_WORDS) {
|
|
1186
1186
|
// 违禁词检测
|
|
1187
1187
|
for (const forbiddenWord of config.FORBIDDEN_WORDS.split(',')) {
|
|
1188
|
-
if (comment.indexOf(forbiddenWord.trim()) !== -1) {
|
|
1188
|
+
if (comment.indexOf(forbiddenWord.trim()) !== -1 || nick.indexOf(forbiddenWord.trim()) !== -1) {
|
|
1189
1189
|
console.log('包含违禁词,直接标记为垃圾评论~')
|
|
1190
1190
|
return true
|
|
1191
1191
|
}
|
|
@@ -1425,11 +1425,11 @@ async function uploadImage (event) {
|
|
|
1425
1425
|
}
|
|
1426
1426
|
// tip: qcloud 图床走前端上传,其他图床走后端上传
|
|
1427
1427
|
if (config.IMAGE_CDN === '7bu') {
|
|
1428
|
-
await
|
|
1428
|
+
await uploadImageToLskyPro({ photo, fileName, config, res, imageCdn: 'https://7bu.top' })
|
|
1429
1429
|
} else if (config.IMAGE_CDN === 'smms') {
|
|
1430
1430
|
await uploadImageToSmms({ photo, fileName, config, res })
|
|
1431
1431
|
} else if (isUrl(config.IMAGE_CDN)) {
|
|
1432
|
-
await uploadImageToLskyPro({ photo, fileName, config, res })
|
|
1432
|
+
await uploadImageToLskyPro({ photo, fileName, config, res, imageCdn: config.IMAGE_CDN })
|
|
1433
1433
|
}
|
|
1434
1434
|
} catch (e) {
|
|
1435
1435
|
console.error(e)
|
|
@@ -1439,24 +1439,6 @@ async function uploadImage (event) {
|
|
|
1439
1439
|
return res
|
|
1440
1440
|
}
|
|
1441
1441
|
|
|
1442
|
-
async function uploadImageTo7Bu ({ photo, fileName, config, res }) {
|
|
1443
|
-
// 去不图床旧版本 https://7bu.top
|
|
1444
|
-
// TODO: 2022 年 4 月 30 日后去不图床将会升级新版本,此处逻辑要同步更新
|
|
1445
|
-
const formData = new FormData()
|
|
1446
|
-
formData.append('image', base64UrlToReadStream(photo, fileName))
|
|
1447
|
-
const uploadResult = await axios.post('https://7bu.top/api/upload', formData, {
|
|
1448
|
-
headers: {
|
|
1449
|
-
...formData.getHeaders(),
|
|
1450
|
-
token: config.IMAGE_CDN_TOKEN
|
|
1451
|
-
}
|
|
1452
|
-
})
|
|
1453
|
-
if (uploadResult.data.code === 200) {
|
|
1454
|
-
res.data = uploadResult.data.data
|
|
1455
|
-
} else {
|
|
1456
|
-
throw new Error(uploadResult.data.msg)
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
1442
|
async function uploadImageToSmms ({ photo, fileName, config, res }) {
|
|
1461
1443
|
// SM.MS 图床 https://sm.ms
|
|
1462
1444
|
const formData = new FormData()
|
|
@@ -1474,11 +1456,11 @@ async function uploadImageToSmms ({ photo, fileName, config, res }) {
|
|
|
1474
1456
|
}
|
|
1475
1457
|
}
|
|
1476
1458
|
|
|
1477
|
-
async function uploadImageToLskyPro ({ photo, fileName, config, res }) {
|
|
1459
|
+
async function uploadImageToLskyPro ({ photo, fileName, config, res, imageCdn }) {
|
|
1478
1460
|
// 自定义兰空图床(v2)URL
|
|
1479
1461
|
const formData = new FormData()
|
|
1480
1462
|
formData.append('file', base64UrlToReadStream(photo, fileName))
|
|
1481
|
-
const url = `${
|
|
1463
|
+
const url = `${imageCdn}/api/v1/upload`
|
|
1482
1464
|
let token = config.IMAGE_CDN_TOKEN
|
|
1483
1465
|
if (!token.startsWith('Bearer')) {
|
|
1484
1466
|
token = `Bearer ${token}`
|
package/package.json
CHANGED