diff --git a/modules/ai/src/main/java/com/bytedesk/ai/robot/RobotConsts.java b/modules/ai/src/main/java/com/bytedesk/ai/robot/RobotConsts.java index e2c2eebec0..b133a06342 100644 --- a/modules/ai/src/main/java/com/bytedesk/ai/robot/RobotConsts.java +++ b/modules/ai/src/main/java/com/bytedesk/ai/robot/RobotConsts.java @@ -14,7 +14,7 @@ package com.bytedesk.ai.robot; import com.bytedesk.core.constant.I18Consts; -import com.bytedesk.core.redis.RedisConsts; +import com.bytedesk.core.constant.RedisConsts; public class RobotConsts { private RobotConsts() { diff --git a/modules/ai/src/main/java/com/bytedesk/ai/robot_message/RobotMessageCache.java b/modules/ai/src/main/java/com/bytedesk/ai/robot_message/RobotMessageCache.java index f5de404ebb..894ccc91d8 100644 --- a/modules/ai/src/main/java/com/bytedesk/ai/robot_message/RobotMessageCache.java +++ b/modules/ai/src/main/java/com/bytedesk/ai/robot_message/RobotMessageCache.java @@ -21,7 +21,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; import com.alibaba.fastjson2.JSON; -import com.bytedesk.core.redis.RedisConsts; +import com.bytedesk.core.constant.RedisConsts; import jakarta.annotation.PostConstruct; import lombok.AllArgsConstructor; diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/RedisConsts.java b/modules/core/src/main/java/com/bytedesk/core/constant/RedisConsts.java similarity index 78% rename from modules/core/src/main/java/com/bytedesk/core/redis/RedisConsts.java rename to modules/core/src/main/java/com/bytedesk/core/constant/RedisConsts.java index 35aeb6f595..4b70ff760d 100644 --- a/modules/core/src/main/java/com/bytedesk/core/redis/RedisConsts.java +++ b/modules/core/src/main/java/com/bytedesk/core/constant/RedisConsts.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-10-23 15:20:38 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-08-15 22:10:29 + * @LastEditTime: 2025-08-16 06:53:35 * @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. @@ -11,7 +11,7 @@ * 联系:270580156@qq.com * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. */ -package com.bytedesk.core.redis; +package com.bytedesk.core.constant; public class RedisConsts { private RedisConsts() {} @@ -34,4 +34,11 @@ public class RedisConsts { public static final String LOGIN_LOCKED_PREFIX = BYTEDESK_REDIS_PREFIX + "login_locked:"; public static final String LOGIN_LOCKED_VALUE = "1"; + // 转接超时相关常量 + public static final String TRANSFER_TIMEOUT_PREFIX = BYTEDESK_REDIS_PREFIX + "transfer:timeout:"; + + // Redis监听频道相关常量 + public static final String REDIS_KEYEVENT_EXPIRED_CHANNEL = "__keyevent@0__:expired"; + public static final String REDIS_KEYEVENT_EXPIRED_PATTERN = "__keyevent@*__:expired"; + } diff --git a/modules/core/src/main/java/com/bytedesk/core/kaptcha/KaptchaRedisService.java b/modules/core/src/main/java/com/bytedesk/core/kaptcha/KaptchaRedisService.java index 16c6ff9251..9e9a1fc771 100644 --- a/modules/core/src/main/java/com/bytedesk/core/kaptcha/KaptchaRedisService.java +++ b/modules/core/src/main/java/com/bytedesk/core/kaptcha/KaptchaRedisService.java @@ -20,8 +20,8 @@ import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; import com.bytedesk.core.config.properties.BytedeskProperties; +import com.bytedesk.core.constant.RedisConsts; import com.bytedesk.core.enums.ChannelEnum; -import com.bytedesk.core.redis.RedisConsts; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/modules/core/src/main/java/com/bytedesk/core/message/MessagePersistCache.java b/modules/core/src/main/java/com/bytedesk/core/message/MessagePersistCache.java index 0a574e9ac3..6bec4d9de7 100644 --- a/modules/core/src/main/java/com/bytedesk/core/message/MessagePersistCache.java +++ b/modules/core/src/main/java/com/bytedesk/core/message/MessagePersistCache.java @@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; -import com.bytedesk.core.redis.RedisConsts; +import com.bytedesk.core.constant.RedisConsts; import jakarta.annotation.PostConstruct; import lombok.AllArgsConstructor; diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/RedisLoginRetryService.java b/modules/core/src/main/java/com/bytedesk/core/redis/RedisLoginRetryService.java index 0ce6ce8b52..d0bc992a28 100644 --- a/modules/core/src/main/java/com/bytedesk/core/redis/RedisLoginRetryService.java +++ b/modules/core/src/main/java/com/bytedesk/core/redis/RedisLoginRetryService.java @@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import com.bytedesk.core.constant.RedisConsts; + import lombok.extern.slf4j.Slf4j; /** diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/RedisService.java b/modules/core/src/main/java/com/bytedesk/core/redis/RedisService.java index 40fc3b5b5f..a3d0ab1279 100644 --- a/modules/core/src/main/java/com/bytedesk/core/redis/RedisService.java +++ b/modules/core/src/main/java/com/bytedesk/core/redis/RedisService.java @@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import com.bytedesk.core.constant.RedisConsts; + // https://redis.io/docs/latest/develop/data-types/streams/ @Service public class RedisService { diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisKeyExpirationListener.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisKeyExpirationListener.java deleted file mode 100644 index 2055029f4f..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisKeyExpirationListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-11-20 17:25:10 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-11-20 17:32:43 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.stereotype.Component; - -import lombok.extern.slf4j.Slf4j; - -/** - * 需要在redis配置文件中添加如下配置,开启过期事件: - * notify-keyspace-events Ex - * 或者,在redis cli中执行如下命令: - * CONFIG SET notify-keyspace-events Ex - */ -@Slf4j -@Component -public class RedisKeyExpirationListener implements MessageListener { - - @Override - public void onMessage(Message message, byte[] pattern) { - String expiredKey = message.toString(); - log.info("Expired key: {}", expiredKey); - // 处理过期的 clientId - handleExpiredClientId(expiredKey); - } - - private void handleExpiredClientId(String clientId) { - // 处理逻辑,例如从 MqttSessionService 中移除过期的会话 - log.info("Handling expired clientId: {}", clientId); - } -} \ No newline at end of file diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubConfig.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubConfig.java deleted file mode 100644 index 186dd89b60..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubConfig.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-23 17:13:03 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-11-20 17:30:56 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.listener.PatternTopic; -import org.springframework.data.redis.listener.ChannelTopic; -import org.springframework.data.redis.listener.RedisMessageListenerContainer; -import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; -// import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; - -// import com.bytedesk.core.redis.CustomRedisSerializer; - -@Configuration -public class RedisPubsubConfig { - - // @Value("${bytedesk.redis-pubsub-channel}") - // private String redisPubsubChannel; - - // 监听object - @Bean - public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory, - MessageListenerAdapter listener) { - RedisMessageListenerContainer container = new RedisMessageListenerContainer(); - container.setConnectionFactory(connectionFactory); - // 订阅topic - subscribe - container.addMessageListener(listener, new PatternTopic(RedisPubsubConst.BYTEDESK_PUBSUB_CHANNEL_OBJECT)); - return container; - } - - /** - * 消息监听器,使用MessageAdapter可实现自动化解码及方法代理 - * // FIXME: 编码报错 SerializationException: Could not read JSON: Unexpected - * character ('¬' (code 172)): expected a valid value (JSON String, Number, Array, - * Object or token 'null', 'true' or 'false') - * - * @return - */ - @Bean - public MessageListenerAdapter listener(RedisPubsubObjectListener subscriber) { - // - MessageListenerAdapter adapter = new MessageListenerAdapter(subscriber, "onMessage"); - // adapter.setSerializer(new GenericJackson2JsonRedisSerializer()); - // adapter.setSerializer(new CustomRedisSerializer()); - adapter.setSerializer(new JdkSerializationRedisSerializer()); - adapter.afterPropertiesSet(); - // - return adapter; - } - - // 监听string - @Bean - RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory redisConnectionFactory, - RedisPubsubStringListener redisStringListener) { - // - RedisMessageListenerContainer redisMessageListenerContainer = new RedisMessageListenerContainer(); - redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory); - // 订阅topic - subscribe - redisMessageListenerContainer.addMessageListener(redisStringListener, - new ChannelTopic(RedisPubsubConst.BYTEDESK_PUBSUB_CHANNEL_STRING)); - return redisMessageListenerContainer; - } - - // 监听key过期事件 - @Bean - RedisMessageListenerContainer redisKeyExpireListenerContainer(RedisConnectionFactory connectionFactory, - RedisKeyExpirationListener listenerAdapter) { - RedisMessageListenerContainer container = new RedisMessageListenerContainer(); - container.setConnectionFactory(connectionFactory); - container.addMessageListener(listenerAdapter, new PatternTopic(RedisPubsubConst.BYTEDESK_PUBSUB_KEY_EXPIRE)); - return container; - } - - - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubConst.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubConst.java deleted file mode 100644 index 9b620ed133..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubConst.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-23 17:29:34 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-11-20 17:29:43 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import com.bytedesk.core.redis.RedisConsts; - -public class RedisPubsubConst { - private RedisPubsubConst() {} - - public static final String BYTEDESK_PUBSUB_CHANNEL_STRING = RedisConsts.BYTEDESK_REDIS_PREFIX + "pubsub"; - public static final String BYTEDESK_PUBSUB_CHANNEL_OBJECT = RedisConsts.BYTEDESK_REDIS_PREFIX + "pubsub_object"; - public static final String BYTEDESK_PUBSUB_KEY_EXPIRE = RedisConsts.BYTEDESK_REDIS_PREFIX + "__keyevent@*__:expired"; -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubController.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubController.java deleted file mode 100644 index 8895a936d1..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubController.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-04-15 17:14:16 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-23 21:09:41 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import org.springframework.beans.factory.annotation.Autowired; -// import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.bytedesk.core.utils.JsonResult; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; - -/** - * Spring Data Redis - Pub/Sub Messaging - * https://docs.spring.io/spring-data/redis/reference/redis/pubsub.html - * https://redis.io/docs/latest/develop/interact/pubsub/ - */ -@Slf4j -@RestController -@RequestMapping("/redis/pubsub") -@Tag(name = "Redis PubSub Management", description = "Redis publish/subscribe messaging APIs") -public class RedisPubsubController { - - @Autowired - private StringRedisTemplate stringRedisTemplate; - - // @Autowired - // private RedisTemplate redisTemplate; - - /** - * http://127.0.0.1:9003/redis/pubsub/send?message=hello - * - * @param message - * @return - */ - @Operation(summary = "Publish Text Message", description = "Publish a text message to Redis pub/sub channel") - @GetMapping("/send") - public JsonResult publishText(@RequestParam String message) { - log.info("redisPubsub redisMessageSend: {}", message); - stringRedisTemplate.convertAndSend( - RedisPubsubConst.BYTEDESK_PUBSUB_CHANNEL_STRING, - message); - // - return new JsonResult<>("send string", 200, message); - } - - /** - * http://127.0.0.1:9003/redis/pubsub/send/object?message=hello - * - * @param message - * @return - */ - // @GetMapping("/send/object") - // public JsonResult publishObject(@RequestParam String message) { - // log.info("redisPubsub send: {}", message); - // // - // RedisPubsubMessage messageDto = RedisPubsubMessage.builder() - // .type("text") - // .fileUrl("pubsub").fileUid("").kbUid("") - // .build(); - // redisTemplate.convertAndSend(RedisPubsubConst.BYTEDESK_PUBSUB_CHANNEL_OBJECT, messageDto); - - // return new JsonResult<>("send object", 200, message); - // } - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubMessage.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubMessage.java deleted file mode 100644 index 64ef9327e6..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubMessage.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-04-15 17:13:01 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-30 16:05:07 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import java.io.Serializable; - -import lombok.AllArgsConstructor; -import lombok.Builder; -// import lombok.extern.slf4j.Slf4j; -import lombok.NoArgsConstructor; -import lombok.Data; - -// java发送,python接收 -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class RedisPubsubMessage implements Serializable { - - private static final long serialVersionUID = 1L; - - private String type; - - private String content; - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubMessageType.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubMessageType.java deleted file mode 100644 index e504c9e07c..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubMessageType.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-28 14:45:30 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-30 16:42:34 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -public enum RedisPubsubMessageType { - PARSE_FILE, - PARSE_FILE_SUCCESS, - PARSE_FILE_ERROR, - // - DELETE_FILE, - DELETE_FILE_SUCCESS, - DELETE_FILE_ERROR, - // - QUESTION, - ANSWER, - ANSWER_FINISHED, - - ; - - // 根据字符串查找对应的枚举常量 - public static RedisPubsubMessageType fromValue(String value) { - for (RedisPubsubMessageType type : RedisPubsubMessageType.values()) { - if (type.name().equalsIgnoreCase(value)) { - return type; - } - } - throw new IllegalArgumentException("No RedisPubsubMessageType constant with value: " + value); - } - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubObjectListener.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubObjectListener.java deleted file mode 100644 index eeaefa70a3..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubObjectListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-04-15 17:13:01 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-11-20 17:23:20 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.stereotype.Component; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Component -public class RedisPubsubObjectListener implements MessageListener { - - @Override - public void onMessage(Message message, byte[] pattern) { - log.info("RedisPubsubObjectListener onMessage: " + new String(message.getBody())); - } - - - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubParseFileErrorEvent.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubParseFileErrorEvent.java deleted file mode 100644 index 7ea863fd98..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubParseFileErrorEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-30 17:38:05 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-30 17:39:46 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import org.springframework.context.ApplicationEvent; - -import com.bytedesk.core.redis.pubsub.message.RedisPubsubMessageFile; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -public class RedisPubsubParseFileErrorEvent extends ApplicationEvent { - - private static final long serialVersionUID = 1L; - - private RedisPubsubMessageFile messageFile; - - public RedisPubsubParseFileErrorEvent(Object source, RedisPubsubMessageFile messageFile) { - super(source); - this.messageFile = messageFile; - } - -} \ No newline at end of file diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubParseFileSuccessEvent.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubParseFileSuccessEvent.java deleted file mode 100644 index 5bbf7886c9..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubParseFileSuccessEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-30 17:27:47 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-30 17:29:53 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import org.springframework.context.ApplicationEvent; - -import com.bytedesk.core.redis.pubsub.message.RedisPubsubMessageFile; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -public class RedisPubsubParseFileSuccessEvent extends ApplicationEvent { - - private static final long serialVersionUID = 1L; - - private RedisPubsubMessageFile messageFile; - - public RedisPubsubParseFileSuccessEvent(Object source, RedisPubsubMessageFile messageFile) { - super(source); - this.messageFile = messageFile; - } - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubService.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubService.java deleted file mode 100644 index e27aa08aa5..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubService.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-23 19:25:35 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-31 08:06:12 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Service; - -import com.alibaba.fastjson2.JSON; -import com.bytedesk.core.redis.pubsub.message.RedisPubsubMessageFile; -import com.bytedesk.core.redis.pubsub.message.RedisPubsubMessageQa; - -@Service -public class RedisPubsubService { - - @Autowired - private StringRedisTemplate stringRedisTemplate; - - public void sendParseFileMessage(String fileUid, String fileUrl, String kbUid) { - // - RedisPubsubMessageFile messageFile = RedisPubsubMessageFile.builder() - .fileUid(fileUid) - .fileUrl(fileUrl) - .kbUid(kbUid) - .build(); - // - RedisPubsubMessage messageObject = RedisPubsubMessage.builder() - .type(RedisPubsubMessageType.PARSE_FILE.name()) - .content(JSON.toJSONString(messageFile)) - .build(); - // - stringRedisTemplate.convertAndSend( - RedisPubsubConst.BYTEDESK_PUBSUB_CHANNEL_STRING, - JSON.toJSONString(messageObject)); - } - - public void sendDeleteFileMessage(String fileUid, List docIds) { - // - RedisPubsubMessageFile messageFile = RedisPubsubMessageFile.builder() - .fileUid(fileUid) - .docIds(docIds) - .build(); - // - RedisPubsubMessage messageObject = RedisPubsubMessage.builder() - .type(RedisPubsubMessageType.DELETE_FILE.name()) - .content(JSON.toJSONString(messageFile)) - .build(); - // - stringRedisTemplate.convertAndSend( - RedisPubsubConst.BYTEDESK_PUBSUB_CHANNEL_STRING, - JSON.toJSONString(messageObject)); - } - - public void sendQuestionMessage(String uid, String threadTopic, String kbUid, String question) { - // - RedisPubsubMessageQa messageQa = RedisPubsubMessageQa.builder() - .uid(uid) - .threadTopic(threadTopic) - .kbUid(kbUid) - .question(question) - .build(); - // - RedisPubsubMessage messageObject = RedisPubsubMessage.builder() - .type(RedisPubsubMessageType.QUESTION.name()) - .content(JSON.toJSONString(messageQa)) - .build(); - // - stringRedisTemplate.convertAndSend( - RedisPubsubConst.BYTEDESK_PUBSUB_CHANNEL_STRING, - JSON.toJSONString(messageObject)); - } - - - - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubStringListener.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubStringListener.java deleted file mode 100644 index 497711a5a5..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/RedisPubsubStringListener.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-04-15 17:13:01 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-04-14 18:43:19 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub; - -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.stereotype.Service; - -import com.alibaba.fastjson2.JSON; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -@AllArgsConstructor -public class RedisPubsubStringListener implements MessageListener { - - // private final BytedeskEventPublisher eventPublisher; - - // private final MessageCache messageCache; - - // private final IMessageSendService messageSendService; - - // private final Queue messageQueue = new LinkedList<>(); - - @Override - public void onMessage(Message message, byte[] pattern) { - // log.info("onMessage,{}", message.toString()); - String channel = new String(message.getChannel()); - String messageContext = new String(message.getBody()); - // - RedisPubsubMessage redisPubsubMessage = JSON.parseObject(messageContext, RedisPubsubMessage.class); - log.info("redisPubsub receiveString: {}, type {}", channel, redisPubsubMessage.getType()); - // - // if (redisPubsubMessage.getType().equals(RedisPubsubMessageType.PARSE_FILE_SUCCESS.name())) { - // // 解析成功 - // log.info("parse file success, content {}", redisPubsubMessage.getContent()); - // RedisPubsubMessageFile messageFile = JSON.parseObject(redisPubsubMessage.getContent(), - // RedisPubsubMessageFile.class); - // log.info("fileUid {}, docIds {}", messageFile.getFileUid(), messageFile.getDocIds()); - // // - // eventPublisher.publishEvent(new RedisPubsubParseFileSuccessEvent(this, messageFile)); - - // } else if (redisPubsubMessage.getType().equals(RedisPubsubMessageType.PARSE_FILE_ERROR.name())) { - // // 解析失败 - // log.info("parse file error, content {}", redisPubsubMessage.getContent()); - // RedisPubsubMessageFile messageFile = JSON.parseObject(redisPubsubMessage.getContent(), - // RedisPubsubMessageFile.class); - // log.info("fileUid {}", messageFile.getFileUid()); - // // 发送事件,通知前端更新文件状态 - // eventPublisher.publishEvent(new RedisPubsubParseFileErrorEvent(this, messageFile)); - - // } else if (redisPubsubMessage.getType().equals(RedisPubsubMessageType.DELETE_FILE_SUCCESS.name())) { - // // TODO: 删除成功 - // log.info("delete file success, content {}", redisPubsubMessage.getContent()); - - // } else if (redisPubsubMessage.getType().equals(RedisPubsubMessageType.DELETE_FILE_ERROR.name())) { - // // TODO: 删除失败 - // log.info("delete file error, content {}", redisPubsubMessage.getContent()); - - // } else if (redisPubsubMessage.getType().equals(RedisPubsubMessageType.ANSWER.name())) { - // // 回答 - // // answer {"threadTopic": "org/robot/df_rt_uid/1463055175142405", "kbUid": - // // "1461090177253570", "question": "\u4f60\u597d", "answer": - // // "\u53ef\u4ee5\u5e2e\u52a9", "model": "glm-4-flash", "created": 1725063232} - // log.info("answer {}", redisPubsubMessage.getContent()); - // messageQueue.add(redisPubsubMessage); // 添加消息到队列 - // // sendMessage(redisPubsubMessage); - // processMessageQueue(); - // // - // } else if (redisPubsubMessage.getType().equals(RedisPubsubMessageType.ANSWER_FINISHED.name())) { - // // TODO: 回答结束 - // // answer finished {"threadTopic": "org/robot/df_rt_uid/1463055175142405", - // // "kbUid": "1461090177253570", "question": "\u4f60\u597d", "answer": "", - // // "model": "glm-4-flash", "created": 1725063232, "promptTokens": 525, - // // "completionTokens": 9, "totalTokens": 534} - // log.info("answer finished {}", redisPubsubMessage.getContent()); - // messageQueue.add(redisPubsubMessage); // 添加消息到队列 - // // sendMessage(redisPubsubMessage); - // processMessageQueue(); - // } - } - - // FIXME: 直接调用sendMessage会导致消息乱序,增加messageQueue,还是消息乱序,未解决 - // private void processMessageQueue() { - // while (!messageQueue.isEmpty()) { - // RedisPubsubMessage redisPubsubMessage = messageQueue.poll(); - // sendMessage(redisPubsubMessage); - // } - // } - - // private void sendMessage(RedisPubsubMessage redisPubsubMessage) { - // log.info("sendMessage, messageQa content {}", redisPubsubMessage.getContent()); - // RedisPubsubMessageQa messageQa = JSON.parseObject(redisPubsubMessage.getContent(), - // RedisPubsubMessageQa.class); - - // log.info("sendMessage, messageQa Id {}", messageQa.getId()); - // MessageProtobuf messageProtobuf = messageCache.get(messageQa.getUid()); - // if (messageProtobuf == null) { - // log.error("message not found, uid {}", messageQa.getUid()); - // return; - // } - // // - // messageProtobuf.setType(MessageTypeEnum.STREAM); - // messageProtobuf.setContent(messageQa.getAnswer()); - // // MessageUtils.notifyUser(messageProtobuf); - // messageSendService.sendProtobufMessage(messageProtobuf); - // } -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/message/RedisPubsubMessageFile.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/message/RedisPubsubMessageFile.java deleted file mode 100644 index eaa2652623..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/message/RedisPubsubMessageFile.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-30 16:07:09 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-30 18:38:52 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub.message; - -import java.util.List; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -@AllArgsConstructor -public class RedisPubsubMessageFile { - - private String fileUid; - - private String fileUrl; - - private String kbUid; - - private List docIds; - - private String errorMsg; -} diff --git a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/message/RedisPubsubMessageQa.java b/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/message/RedisPubsubMessageQa.java deleted file mode 100644 index a4f01b721a..0000000000 --- a/modules/core/src/main/java/com/bytedesk/core/redis/pubsub/message/RedisPubsubMessageQa.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * @Author: jackning 270580156@qq.com - * @Date: 2024-08-30 16:09:19 - * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2024-08-31 10:19:59 - * @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. - * Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE - * contact: 270580156@qq.com - * 联系:270580156@qq.com - * Copyright (c) 2024 by bytedesk.com, All Rights Reserved. - */ -package com.bytedesk.core.redis.pubsub.message; - -import jakarta.validation.constraints.NotEmpty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -@Data -@Builder -@AllArgsConstructor -public class RedisPubsubMessageQa { - - private Integer id; - - @NotEmpty - private String uid; - - private String threadTopic; - - // - private String kbUid; - - private String fileUid; - - // - private String question; - - private String answer; - - private String model; - - private Integer created; - - private String finishReason; - - // - private String promptTokens; - - private String completionTokens; - - private String totalTokens; - -} diff --git a/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttConnectionService.java b/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttConnectionService.java index d4f397a603..0fd6c7bc96 100644 --- a/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttConnectionService.java +++ b/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttConnectionService.java @@ -21,7 +21,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import com.bytedesk.core.redis.RedisConsts; +import com.bytedesk.core.constant.RedisConsts; import lombok.AllArgsConstructor; diff --git a/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttEventListener.java b/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttEventListener.java index 0d38e46e6f..27de3d0dba 100644 --- a/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttEventListener.java +++ b/modules/core/src/main/java/com/bytedesk/core/socket/mqtt/MqttEventListener.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-08-04 10:44:09 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-06-16 07:45:19 + * @LastEditTime: 2025-08-16 07:07:46 * @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. @@ -20,7 +20,7 @@ import com.bytedesk.core.quartz.event.QuartzOneMinEvent; import com.bytedesk.core.socket.mqtt.event.MqttConnectedEvent; import com.bytedesk.core.socket.mqtt.event.MqttDisconnectedEvent; import com.bytedesk.core.topic.TopicCacheService; -import com.bytedesk.core.topic.TopicService; +import com.bytedesk.core.topic.TopicRestService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -30,7 +30,7 @@ import lombok.extern.slf4j.Slf4j; @AllArgsConstructor public class MqttEventListener { - private final TopicService topicService; + private final TopicRestService topicRestService; private final TopicCacheService topicCacheService; @@ -61,7 +61,7 @@ public class MqttEventListener { public void onMqttSubscribeEvent(MqttSubscribeEvent event) { log.info("topic onMqttSubscribeEvent {}", event); // - topicService.subscribe(event.getTopic(), event.getClientId()); + topicRestService.subscribe(event.getTopic(), event.getClientId()); } @EventListener diff --git a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadEventListener.java b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadEventListener.java index 7833ea5e23..1c772bc872 100644 --- a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadEventListener.java +++ b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadEventListener.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-06-28 13:32:23 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-07-09 17:49:19 + * @LastEditTime: 2025-08-16 07:08:31 * @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. @@ -25,7 +25,6 @@ import com.bytedesk.core.thread.event.ThreadCloseEvent; import com.bytedesk.core.topic.TopicCacheService; import com.bytedesk.core.topic.TopicRequest; import com.bytedesk.core.topic.TopicRestService; -import com.bytedesk.core.topic.TopicService; import com.bytedesk.core.topic.TopicUtils; import lombok.AllArgsConstructor; @@ -36,8 +35,6 @@ import lombok.extern.slf4j.Slf4j; @AllArgsConstructor public class ThreadEventListener { - private final TopicService topicService; - private final TopicCacheService topicCacheService; private final TopicRestService topicRestService; @@ -68,7 +65,7 @@ public class ThreadEventListener { .build(); request.getTopics().add(topic); request.getTopics().add(topicInternal); - topicService.create(request); + topicRestService.create(request); } else { // 文件助手、系统通知会话延迟订阅topic TopicRequest request = TopicRequest.builder() @@ -99,7 +96,7 @@ public class ThreadEventListener { .topic(thread.getTopic()) .userUid(user.getUid()) .build(); - topicService.create(request); + topicRestService.create(request); } else if (thread.getType().equals(ThreadTypeEnum.WORKGROUP.name())) { // 工作组会话,需要订阅topic // 重新订阅 @@ -107,14 +104,14 @@ public class ThreadEventListener { .topic(thread.getTopic()) .userUid(user.getUid()) .build(); - topicService.create(request); + topicRestService.create(request); } else if (thread.getType().equals(ThreadTypeEnum.MEMBER.name())) { // 会员会话,需要订阅topic TopicRequest request = TopicRequest.builder() .topic(thread.getTopic()) .userUid(user.getUid()) .build(); - topicService.create(request); + topicRestService.create(request); } else { // 文件助手、系统通知会话延迟订阅topic TopicRequest request = TopicRequest.builder() diff --git a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadPersistCache.java b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadPersistCache.java index 16b35a64c8..d3b941db3d 100644 --- a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadPersistCache.java +++ b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadPersistCache.java @@ -20,10 +20,7 @@ import java.util.concurrent.TimeUnit; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; -import com.bytedesk.core.redis.RedisConsts; -// import com.github.benmanes.caffeine.cache.Cache; -// import com.github.benmanes.caffeine.cache.CacheLoader; -// import com.github.benmanes.caffeine.cache.Caffeine; +import com.bytedesk.core.constant.RedisConsts; import jakarta.annotation.PostConstruct; import lombok.AllArgsConstructor; diff --git a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java index 58d73d46d7..63f1bb9753 100644 --- a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java +++ b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-02-21 10:01:12 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-08-15 17:36:04 + * @LastEditTime: 2025-08-16 06:32:47 * @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. @@ -19,7 +19,6 @@ import java.util.List; import com.bytedesk.core.base.BaseRequest; import com.bytedesk.core.rbac.user.UserProtobuf; import com.bytedesk.core.thread.enums.ThreadInviteStatusEnum; -import com.bytedesk.core.thread.enums.ThreadSummaryStatusEnum; import com.bytedesk.core.thread.enums.ThreadTransferStatusEnum; import lombok.Builder; diff --git a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java index afdb9da275..047ceda5cf 100644 --- a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java +++ b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-02-21 10:01:27 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-08-15 17:37:52 + * @LastEditTime: 2025-08-16 06:32:54 * @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. @@ -20,8 +20,6 @@ import com.bytedesk.core.base.BaseResponse; import com.bytedesk.core.rbac.user.UserProtobuf; import com.bytedesk.core.thread.enums.ThreadInviteStatusEnum; import com.bytedesk.core.thread.enums.ThreadTransferStatusEnum; -import com.bytedesk.core.thread.enums.ThreadSummaryStatusEnum; - import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/modules/core/src/main/java/com/bytedesk/core/topic/TopicEventListener.java b/modules/core/src/main/java/com/bytedesk/core/topic/TopicEventListener.java index cad4f61251..e767e94c83 100644 --- a/modules/core/src/main/java/com/bytedesk/core/topic/TopicEventListener.java +++ b/modules/core/src/main/java/com/bytedesk/core/topic/TopicEventListener.java @@ -2,7 +2,7 @@ * @Author: import java.util.HashSet; * @Date: 2024-05-29 15:11:57 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-07-09 17:49:06 + * @LastEditTime: 2025-08-16 07:09:54 * @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. @@ -39,7 +39,7 @@ import lombok.extern.slf4j.Slf4j; @AllArgsConstructor public class TopicEventListener { - private final TopicService topicService; + private final TopicRestService topicRestService; private final TopicCacheService topicCacheService; @@ -66,14 +66,14 @@ public class TopicEventListener { topicRequestList.forEach(item -> { // log.info("topic onQuartzFiveSecondEvent {}", item); TopicRequest topicRequest = JSON.parseObject(item, TopicRequest.class); - topicService.create(topicRequest); + topicRestService.create(topicRequest); }); } List clientIdList = topicCacheService.getClientIdList(); if (clientIdList!= null) { clientIdList.forEach(item -> { // log.info("topic onQuartzFiveSecondEvent {}", item); - topicService.addClientId(item); + topicRestService.addClientId(item); }); } } @@ -110,7 +110,7 @@ public class TopicEventListener { log.info("topic onQuartzDay0Event: 开始清理已结束的会话topics"); // 获取所有的 TopicEntity - List allTopics = topicService.findAll(); + List allTopics = topicRestService.findAll(); for (TopicEntity topicEntity : allTopics) { Set topics = topicEntity.getTopics(); @@ -144,7 +144,7 @@ public class TopicEventListener { // 从topics集合中移除符合条件的topic for (String topicToRemove : topicsToRemove) { - topicService.remove(topicToRemove, topicEntity.getUserUid()); + topicRestService.remove(topicToRemove, topicEntity.getUserUid()); log.info("成功删除topic: {} 从 userUid: {}", topicToRemove, topicEntity.getUserUid()); } } diff --git a/modules/core/src/main/java/com/bytedesk/core/topic/TopicRestService.java b/modules/core/src/main/java/com/bytedesk/core/topic/TopicRestService.java index 9670fe66d7..ec1a979f13 100644 --- a/modules/core/src/main/java/com/bytedesk/core/topic/TopicRestService.java +++ b/modules/core/src/main/java/com/bytedesk/core/topic/TopicRestService.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-11-20 11:16:56 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-07-05 15:52:46 + * @LastEditTime: 2025-08-16 07:11:35 * @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. @@ -104,6 +104,14 @@ public class TopicRestService extends BaseRestService findAll() { - return topicRestService.findAll(); - } - - // @Cacheable(value = "topic", key = "#uid") - // public Optional findByUid(String uid) { - // return topicRestService.findByUid(uid); - // } - - // @Cacheable(value = "topic", key = "#clientId", unless = "#result == null") - // public Optional findByClientId(String clientId) { - // // 用户clientId格式: userUid/client/deviceUid - // final String userUid = clientId.split("/")[0]; - // return findByUserUid(userUid); - // } - - // @Cacheable(value = "topic", key = "#uid", unless = "#result == null") - // public Optional findByUserUid(String uid) { - // return topicRestService.findByUid(uid); - // } - - // @Cacheable(value = "topic", key = "#topic", unless="#result == null") - // public Set findByTopic(String topic) { - // return topicRestService.findByTopic(topic); - // } - - // public void update(String uid, String userUid) { - // Optional optionalTopic = findByUid(uid); - // optionalTopic.ifPresent(topic -> { - // topic.setUserUid(userUid); - // topicRestService.save(topic); - // }); - // } - - // @CacheEvict(value = "topic", key = "#topic.userUid") - // public void delete(TopicEntity topic) { - // topicRestService.deleteByUid(topic.getUid()); - // } - - // public TopicResponse convertToTopicResponse(TopicEntity topic) { - // return topicRestService.convertToResponse(topic); - // } - -} diff --git a/modules/service/src/main/java/com/bytedesk/service/workgroup/WorkgroupRoutingService.java b/modules/service/src/main/java/com/bytedesk/service/workgroup/WorkgroupRoutingService.java index da5f6fb4e3..efd2fcc74e 100644 --- a/modules/service/src/main/java/com/bytedesk/service/workgroup/WorkgroupRoutingService.java +++ b/modules/service/src/main/java/com/bytedesk/service/workgroup/WorkgroupRoutingService.java @@ -8,7 +8,7 @@ import java.time.format.DateTimeFormatter; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; -import com.bytedesk.core.redis.RedisConsts; +import com.bytedesk.core.constant.RedisConsts; import com.bytedesk.core.thread.ThreadEntity; import com.bytedesk.core.topic.TopicUtils; import com.bytedesk.service.agent.AgentEntity; diff --git a/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketService.java b/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketService.java index 95c8266d41..d60d501f9c 100644 --- a/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketService.java +++ b/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketService.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2025-01-29 12:24:32 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-07-04 10:49:33 + * @LastEditTime: 2025-08-16 07:11:53 * @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. @@ -31,7 +31,7 @@ import com.bytedesk.core.rbac.user.UserProtobuf; import com.bytedesk.core.rbac.user.UserTypeEnum; import com.bytedesk.core.thread.ThreadEntity; import com.bytedesk.core.thread.ThreadRestService; -import com.bytedesk.core.topic.TopicService; +import com.bytedesk.core.topic.TopicRestService; import com.bytedesk.core.member.MemberEntity; import com.bytedesk.core.member.MemberRestService; import com.bytedesk.ticket.ticket.dto.TicketHistoryActivityResponse; @@ -63,11 +63,10 @@ public class TicketService { private final RuntimeService runtimeService; private final TaskService taskService; - // private final TicketRepository ticketRepository; private final HistoryService historyService; private final MemberRestService memberRestService; private final ThreadRestService threadRestService; - private final TopicService topicService; + private final TopicRestService topicRestService; private final TicketRestService ticketRestService; /** @@ -180,7 +179,7 @@ public class TicketService { threadRestService.save(thread); // 添加订阅 String userUid = member.getUser().getUid(); - topicService.create(thread.getTopic(), userUid); + topicRestService.create(thread.getTopic(), userUid); } // 6. 发布工单分配消息事件