UPDATE 02-sept
This commit is contained in:
@@ -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.service.notification;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class NotificationExpirationListener implements MessageListener {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NotificationExpirationListener.class);
|
||||
private final FirestoreNotificationService firestoreNotificationService;
|
||||
private static final String NOTIFICATION_KEY_PREFIX = "notification:";
|
||||
|
||||
public NotificationExpirationListener(FirestoreNotificationService firestoreNotificationService) {
|
||||
this.firestoreNotificationService = firestoreNotificationService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
String expiredKey = new String(message.getBody());
|
||||
logger.info("Expired key: " + expiredKey);
|
||||
if (expiredKey.startsWith(NOTIFICATION_KEY_PREFIX)) {
|
||||
String sessionId = expiredKey.substring(NOTIFICATION_KEY_PREFIX.length());
|
||||
firestoreNotificationService.updateNotificationStatus(sessionId, "inactive")
|
||||
.doOnSuccess(v -> logger.info("Notification status updated to inactive for session: " + sessionId))
|
||||
.doOnError(e -> logger.error("Error updating notification status for session: " + sessionId, e))
|
||||
.subscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user