diff options
author | Anton Tananaev <anton@traccar.org> | 2023-11-18 06:00:37 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-11-18 06:00:37 -0800 |
commit | a9ba9a58a868309a9fc83cdb8710159c7786ca32 (patch) | |
tree | c074fada48f5c65f532af0b355ab36d3937dd4da /src/main/java/org/traccar/database | |
parent | e5827b74db9432392b702f676fedb2aaacfd69f0 (diff) | |
download | trackermap-server-a9ba9a58a868309a9fc83cdb8710159c7786ca32.tar.gz trackermap-server-a9ba9a58a868309a9fc83cdb8710159c7786ca32.tar.bz2 trackermap-server-a9ba9a58a868309a9fc83cdb8710159c7786ca32.zip |
Skip old event notifications (fix #5217)
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r-- | src/main/java/org/traccar/database/NotificationManager.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/database/NotificationManager.java b/src/main/java/org/traccar/database/NotificationManager.java index 3a57788fb..03cfba418 100644 --- a/src/main/java/org/traccar/database/NotificationManager.java +++ b/src/main/java/org/traccar/database/NotificationManager.java @@ -58,6 +58,7 @@ public class NotificationManager { private final Geocoder geocoder; private final boolean geocodeOnRequest; + private final long timeThreshold; @Inject public NotificationManager( @@ -69,6 +70,7 @@ public class NotificationManager { this.notificatorManager = notificatorManager; this.geocoder = geocoder; geocodeOnRequest = config.getBoolean(Keys.GEOCODER_ON_REQUEST); + timeThreshold = config.getLong(Keys.NOTIFICATOR_TIME_THRESHOLD); } private void updateEvent(Event event, Position position) { @@ -78,6 +80,13 @@ public class NotificationManager { LOGGER.warn("Event save error", error); } + forwardEvent(event, position); + + if (System.currentTimeMillis() - event.getEventTime().getTime() > timeThreshold) { + LOGGER.info("Skipping notifications for old event"); + return; + } + var notifications = cacheManager.getDeviceObjects(event.getDeviceId(), Notification.class).stream() .filter(notification -> notification.getType().equals(event.getType())) .filter(notification -> { @@ -115,8 +124,6 @@ public class NotificationManager { }); }); } - - forwardEvent(event, position); } private void forwardEvent(Event event, Position position) { |