diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-07 07:16:51 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-07 07:16:51 -0700 |
commit | 3a83acbf92741b34323a74bd1a233186d507c46b (patch) | |
tree | 00cf66581828f7a508eae92e396447b4d2e12848 /src/main/java/org/traccar | |
parent | 65f9e253171dc6805127e5279b97fad05f8c4b9f (diff) | |
download | trackermap-server-3a83acbf92741b34323a74bd1a233186d507c46b.tar.gz trackermap-server-3a83acbf92741b34323a74bd1a233186d507c46b.tar.bz2 trackermap-server-3a83acbf92741b34323a74bd1a233186d507c46b.zip |
Send formatted event message
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r-- | src/main/java/org/traccar/notificators/NotificatorWeb.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/notificators/NotificatorWeb.java b/src/main/java/org/traccar/notificators/NotificatorWeb.java index 023cb04af..e19a94c1d 100644 --- a/src/main/java/org/traccar/notificators/NotificatorWeb.java +++ b/src/main/java/org/traccar/notificators/NotificatorWeb.java @@ -17,15 +17,34 @@ package org.traccar.notificators; import org.traccar.Context; +import org.traccar.Main; import org.traccar.model.Event; import org.traccar.model.Position; import org.traccar.model.User; +import org.traccar.notification.NotificationFormatter; +import org.traccar.notification.NotificationMessage; +import org.traccar.session.cache.CacheManager; public final class NotificatorWeb implements Notificator { @Override public void send(User user, Event event, Position position) { - Context.getConnectionManager().updateEvent(user.getId(), event); + + Event copy = new Event(); + copy.setId(event.getId()); + copy.setDeviceId(event.getDeviceId()); + copy.setType(event.getType()); + copy.setEventTime(event.getEventTime()); + copy.setPositionId(event.getPositionId()); + copy.setGeofenceId(event.getGeofenceId()); + copy.setMaintenanceId(event.getMaintenanceId()); + copy.getAttributes().putAll(event.getAttributes()); + + NotificationMessage message = NotificationFormatter.formatMessage( + Main.getInjector().getInstance(CacheManager.class), user, event, position, "short"); + copy.set("message", message.getBody()); + + Context.getConnectionManager().updateEvent(user.getId(), copy); } } |