diff --git a/README.md b/README.md index bd38f3a134..900f965942 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-06-05 09:43:27 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-03-06 11:29:44 + * @LastEditTime: 2025-03-06 17:10:23 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -184,7 +184,3 @@ demo password: admin - -## License - -- [Apache License 2.0](./LICENSE.txt) diff --git a/README.zh.md b/README.zh.md index d296c490fd..a7078694bf 100644 --- a/README.zh.md +++ b/README.zh.md @@ -190,5 +190,4 @@ http://127.0.0.1:9003/ ## 版权 -- [Apache License 2.0](./LICENSE.txt) - 此为开源社区版,支持免费商用 diff --git a/modules/core/src/main/java/com/bytedesk/core/message/MessageEventListener.java b/modules/core/src/main/java/com/bytedesk/core/message/MessageEventListener.java index e9b967ea01..fffd8d4038 100644 --- a/modules/core/src/main/java/com/bytedesk/core/message/MessageEventListener.java +++ b/modules/core/src/main/java/com/bytedesk/core/message/MessageEventListener.java @@ -21,6 +21,7 @@ import java.util.Optional; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; @@ -134,4 +135,13 @@ public class MessageEventListener { }); } + @Async + @EventListener + public void onMessageCreateEvent(MessageCreateEvent event) { + List messageJsonList = event.getMessageJsonList(); + Assert.notEmpty(messageJsonList, "Message JSON list must not be empty"); + + // ... rest of the method + } + } diff --git a/modules/core/src/main/java/com/bytedesk/core/utils/Utils.java b/modules/core/src/main/java/com/bytedesk/core/utils/Utils.java index 22f1cfb5fc..7721c251b7 100644 --- a/modules/core/src/main/java/com/bytedesk/core/utils/Utils.java +++ b/modules/core/src/main/java/com/bytedesk/core/utils/Utils.java @@ -15,6 +15,7 @@ package com.bytedesk.core.utils; import java.util.Random; import java.util.UUID; +import org.springframework.util.Assert; public class Utils { @@ -47,7 +48,7 @@ public class Utils { /** * 带有时间戳的uuid - * UUID.randomUUID().toString()长度为36,我们去掉‘-’之后,截取前半段 + * UUID.randomUUID().toString()长度为36,我们去掉'-'之后,截取前半段 * * @return uuid */ @@ -60,20 +61,9 @@ public class Utils { } public static String formatUid(String orgUid, String uid) { - // 如果都为空,则调用getUid - if ((orgUid == null || orgUid.isEmpty()) && (uid == null || uid.isEmpty())) { - return getUid(); - } - // 如果orgUid为空,则返回uid - if (orgUid == null || orgUid.isEmpty()) { - return uid; - } - // 如果uid为空,则返回orgUid - if (uid == null || uid.isEmpty()) { - return orgUid; - } - // 如果orgUid和uid都不为空,则返回orgUid_uid - return orgUid + "_" + uid.toLowerCase(); + Assert.hasText(orgUid, "Organization UID must not be empty"); + Assert.hasText(uid, "UID must not be empty"); + return orgUid + "_" + uid; } diff --git a/modules/voc/src/main/java/com/bytedesk/voc/filter/SensitiveWordFilter.java b/modules/voc/src/main/java/com/bytedesk/voc/filter/SensitiveWordFilter.java index cc3bd357ac..e8d2077b21 100644 --- a/modules/voc/src/main/java/com/bytedesk/voc/filter/SensitiveWordFilter.java +++ b/modules/voc/src/main/java/com/bytedesk/voc/filter/SensitiveWordFilter.java @@ -10,6 +10,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; @@ -38,6 +39,7 @@ public class SensitiveWordFilter { } public boolean containsSensitiveWords(String text) { + Assert.hasText(text, "Text must not be empty"); if (text == null || text.isEmpty()) { return false; } @@ -48,6 +50,7 @@ public class SensitiveWordFilter { } public Set findSensitiveWords(String text) { + Assert.hasText(text, "Text must not be empty"); Set found = new HashSet<>(); if (text == null || text.isEmpty()) { return found; @@ -62,6 +65,7 @@ public class SensitiveWordFilter { } public String filter(String text) { + Assert.hasText(text, "Text must not be empty"); if (text == null || text.isEmpty()) { return text; }