Skip to content

Commit a8c593a

Browse files
committed
feat(AI审查): 优化违规图片处理逻辑
- 添加对 AI 审查结果为 block 或 review 的处理逻辑 - 在捕获异常时刷新 CDN 缓存- 调整违规处罚积分,block 类型从 500 积分调整为 50 积分,review 类型从 200 积分调整为 20 积分 - 优化日志记录和聊天室通知消息
1 parent 2c88f96 commit a8c593a

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/main/java/org/b3log/symphony/processor/ApiProcessor.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,20 @@ public void callbackFromQiNiu(final RequestContext context) {
191191
try {
192192
JSONObject uploadJSON = uploadRepository.getFirst(query);
193193
userName = uploadJSON.optString("userName");
194-
} catch (RepositoryException e) {
195-
LOGGER.log(Level.ERROR, "Cannot find upload by path [" + fileURL + "]", e);
194+
} catch (Exception e) {
195+
String suggestion = jsonObject.optJSONArray("items").optJSONObject(0).optJSONObject("result").optJSONObject("result").optString("suggestion");
196+
if (suggestion.equals("block") || suggestion.equals("review")) {
197+
try {
198+
Auth auth = Auth.create(Symphonys.UPLOAD_QINIU_AK, Symphonys.UPLOAD_QINIU_SK);
199+
String[] urls = new String[]{fileURL};
200+
CdnManager c = new CdnManager(auth);
201+
CdnResult.RefreshResult result = c.refreshUrls(urls);
202+
LOGGER.log(Level.INFO, "CDN Refresh result: " + result.code);
203+
LOGGER.log(Level.WARN, "Avatar file " + fileURL);
204+
} catch (Exception f) {
205+
LOGGER.error(f);
206+
}
207+
}
196208
}
197209

198210
if (!userName.isEmpty()) {
@@ -207,8 +219,8 @@ public void callbackFromQiNiu(final RequestContext context) {
207219
CdnResult.RefreshResult result = c.refreshUrls(urls);
208220
LOGGER.log(Level.INFO, "CDN Refresh result: " + result.code);
209221
LOGGER.log(Level.WARN, "Block file " + fileURL);
210-
ChatRoomBot.sendBotMsg("[AI审查] 犯罪嫌疑人 @" + userName + " 由于上传违法文件/图片,被处以 500 积分的处罚,请引以为戒。如误报请联系管理员找回积分!\n@adlered 留档");
211-
ChatRoomBot.abusePoint(userId, 500, "[AI审查] [如有误报请联系管理员追回积分] 机器人罚单-上传违法文件");
222+
ChatRoomBot.sendBotMsg("[AI审查] 犯罪嫌疑人 @" + userName + " 由于上传违法文件/图片,被处以 50 积分的处罚,请引以为戒。如误报请联系管理员找回积分!\n@adlered 留档");
223+
ChatRoomBot.abusePoint(userId, 50, "[AI审查] [如有误报请联系管理员追回积分] 机器人罚单-上传违法文件");
212224
LogsService.censorLog(context, userName, "用户:" + userName + " 上传违规图片:" + fileURL);
213225
} catch (Exception e) {
214226
LOGGER.error(e);
@@ -222,8 +234,8 @@ public void callbackFromQiNiu(final RequestContext context) {
222234
CdnResult.RefreshResult result = c.refreshUrls(urls);
223235
LOGGER.log(Level.INFO, "CDN Refresh result: " + result.code);
224236
LOGGER.log(Level.WARN, "Review file " + fileURL);
225-
ChatRoomBot.sendBotMsg("[AI审查] 用户 @" + userName + " 由于上传疑似违规文件/图片,被处以 200 积分的处罚,请引以为戒。如误报请联系管理员找回积分!\n@adlered 留档");
226-
ChatRoomBot.abusePoint(userId, 200, "[AI审查] [如有误报请联系管理员追回积分] 机器人罚单-上传疑似违规文件");
237+
ChatRoomBot.sendBotMsg("[AI审查] 用户 @" + userName + " 由于上传疑似违规文件/图片,被处以 20 积分的处罚,请引以为戒。如误报请联系管理员找回积分!\n@adlered 留档");
238+
ChatRoomBot.abusePoint(userId, 20, "[AI审查] [如有误报请联系管理员追回积分] 机器人罚单-上传疑似违规文件");
227239
LogsService.censorLog(context, userName, "用户:" + userName + " 上传疑似违规图片:" + fileURL);
228240
} catch (Exception e) {
229241
LOGGER.error(e);

0 commit comments

Comments
 (0)