aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-08-16 16:52:45 +0500
committerAbyss777 <abyss@fox5.ru>2017-08-16 16:52:45 +0500
commit9476e6be8fae228cda5867750bc4d102b1f9497d (patch)
tree3e0d2a9627f7b13d70df06a971e2fd36b2b0df76 /src/org/traccar/database
parente8739edc4e2b3a945c2b0eeec6286f7ef59037cf (diff)
downloadtrackermap-server-9476e6be8fae228cda5867750bc4d102b1f9497d.tar.gz
trackermap-server-9476e6be8fae228cda5867750bc4d102b1f9497d.tar.bz2
trackermap-server-9476e6be8fae228cda5867750bc4d102b1f9497d.zip
- Map correct position to delayed event notification
- Fix nested condition
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/NotificationManager.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index 0987f255b..8eea287de 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -48,8 +48,13 @@ public class NotificationManager {
}
public void updateEvent(Event event, Position position) {
+ Position relatedPosition = position;
try {
dataManager.addObject(event);
+ if (event.getPositionId() != 0 && (relatedPosition == null
+ || event.getPositionId() != relatedPosition.getId())) {
+ relatedPosition = dataManager.getObject(Position.class, event.getPositionId());
+ }
} catch (SQLException error) {
Log.warning(error);
}
@@ -64,16 +69,16 @@ public class NotificationManager {
Context.getConnectionManager().updateEvent(userId, event);
}
if (notification.getMail()) {
- NotificationMail.sendMailAsync(userId, event, position);
+ NotificationMail.sendMailAsync(userId, event, relatedPosition);
}
if (notification.getSms()) {
- NotificationSms.sendSmsAsync(userId, event, position);
+ NotificationSms.sendSmsAsync(userId, event, relatedPosition);
}
}
}
}
if (Context.getEventForwarder() != null) {
- Context.getEventForwarder().forwardEvent(event, position);
+ Context.getEventForwarder().forwardEvent(event, relatedPosition);
}
}