add NotificationLimiter to avoid sending too many notifications per hour
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -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
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user