add NotificationLimiter to avoid sending too many notifications per hour
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-02-05 11:56:24 +01:00
parent 4fe86b6845
commit fb41f80061
9 changed files with 117 additions and 17 deletions
@@ -1,9 +1,13 @@
package SuMoC.backend.notification.config;
import SuMoC.backend.notification.enums.NotificationType;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Data
@Component
@ConfigurationProperties(prefix = "sumoc.notification")
@@ -12,4 +16,14 @@ public class NotificationProperties {
* Maximum number of failed send attempts before giving up on a notification.
*/
private int maxFailedSendAttempts = 3;
/**
* Maximum number of notifications to send to a user per hour per notification type.
*/
private Map<NotificationType, Integer> maxNotificationsPerHourPerType = new HashMap<>(Map.of(
NotificationType.TREND, 1,
NotificationType.ADHOC_ALTERNATIVE, 1,
NotificationType.REGULAR_TRIP_ALTERNATIVE, 1,
NotificationType.FRIENDSHIP_REQUEST_RECEIVED, 3
));
}