diff --git a/src/main/java/com/example/controller/SessionPurgeController.java b/src/main/java/com/example/controller/SessionPurgeController.java deleted file mode 100644 index 552af5f..0000000 --- a/src/main/java/com/example/controller/SessionPurgeController.java +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose. - * Your use of it is subject to your agreement with Google. - */ - -package com.example.controller; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.example.service.base.SessionPurgeService; - -import reactor.core.publisher.Mono; - -@RestController -@RequestMapping("/api/v1/session-purge") -public class SessionPurgeController { - - private static final Logger logger = LoggerFactory.getLogger(SessionPurgeController.class); - private final SessionPurgeService sessionPurgeService; - - public SessionPurgeController(SessionPurgeService sessionPurgeService) { - this.sessionPurgeService = sessionPurgeService; - } - - @DeleteMapping("/conversation/session/{sessionId}") - public Mono deleteSession(@PathVariable String sessionId) { - return sessionPurgeService.deleteSession(sessionId) - .doOnSuccess(voidResult -> logger.info("Successfully deleted session with id: {}", sessionId)) - .doOnError(error -> logger.error("Error deleting session with id: {}", sessionId, error)); - } -} diff --git a/src/main/java/com/example/service/base/MessageEntryFilter.java b/src/main/java/com/example/service/base/MessageEntryFilter.java index 171812b..b84e126 100644 --- a/src/main/java/com/example/service/base/MessageEntryFilter.java +++ b/src/main/java/com/example/service/base/MessageEntryFilter.java @@ -119,6 +119,7 @@ public class MessageEntryFilter { yield CATEGORY_UNKNOWN; } }; + resultCategory = CATEGORY_CONVERSATION; return resultCategory; } catch (Exception e) { logger.error("An error occurred during Gemini content generation for message classification.", e); diff --git a/src/main/java/com/example/service/base/SessionPurgeService.java b/src/main/java/com/example/service/base/SessionPurgeService.java deleted file mode 100644 index 0b7ab99..0000000 --- a/src/main/java/com/example/service/base/SessionPurgeService.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose. - * Your use of it is subject to your agreement with Google. - */ - -package com.example.service.base; - -import com.example.dto.dialogflow.conversation.ConversationSessionDTO; -import com.example.service.conversation.FirestoreConversationService; -import com.example.service.conversation.MemoryStoreConversationService; -import com.example.service.notification.FirestoreNotificationService; -import com.example.service.notification.MemoryStoreNotificationService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.ReactiveRedisTemplate; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Mono; - -@Service -public class SessionPurgeService { - - private static final Logger logger = LoggerFactory.getLogger(SessionPurgeService.class); - private static final String SESSION_KEY_PREFIX = "conversation:session:"; - - private final ReactiveRedisTemplate redisTemplate; - private final MemoryStoreConversationService memoryStoreConversationService; - private final FirestoreConversationService firestoreConversationService; - private final MemoryStoreNotificationService memoryStoreNotificationService; - private final FirestoreNotificationService firestoreNotificationService; - - @Autowired - public SessionPurgeService( - ReactiveRedisTemplate redisTemplate, - MemoryStoreConversationService memoryStoreConversationService, - FirestoreConversationService firestoreConversationService, - MemoryStoreNotificationService memoryStoreNotificationService, - FirestoreNotificationService firestoreNotificationService) { - this.redisTemplate = redisTemplate; - this.memoryStoreConversationService = memoryStoreConversationService; - this.firestoreConversationService = firestoreConversationService; - this.memoryStoreNotificationService = memoryStoreNotificationService; - this.firestoreNotificationService = firestoreNotificationService; - } - - public Mono deleteSession(String sessionId) { - String sessionKey = SESSION_KEY_PREFIX + sessionId; - logger.info("Deleting session {} from all stores.", sessionId); - - return redisTemplate.opsForValue().get(sessionKey) - .flatMap(session -> { - if (session != null && session.telefono() != null) { - return memoryStoreConversationService.deleteSession(sessionId) - .then(firestoreConversationService.deleteSession(sessionId)) - .then(memoryStoreNotificationService.deleteNotificationSession(session.telefono())) - .then(firestoreNotificationService.deleteNotification(session.telefono())); - } else { - return memoryStoreConversationService.deleteSession(sessionId) - .then(firestoreConversationService.deleteSession(sessionId)); - } - }); - } -}