aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/notification/EventForwarder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-03-21 08:52:57 +1300
committerGitHub <noreply@github.com>2018-03-21 08:52:57 +1300
commit8c1bf38ae5dc6cf76ef532132acda7984b7bc557 (patch)
tree9eaca738af355bc2c92471820080c871c1bd0d2a /src/org/traccar/notification/EventForwarder.java
parent38c1ff9bccc1c417a0c2b412271aa7240a3b7db7 (diff)
parent02e3f0f196c9dc1227b1074ff39f52efd7ab418c (diff)
downloadtrackermap-server-8c1bf38ae5dc6cf76ef532132acda7984b7bc557.tar.gz
trackermap-server-8c1bf38ae5dc6cf76ef532132acda7984b7bc557.tar.bz2
trackermap-server-8c1bf38ae5dc6cf76ef532132acda7984b7bc557.zip
Merge pull request #3815 from Abyss777/event_forward_users
Add user objects to Event forward payload
Diffstat (limited to 'src/org/traccar/notification/EventForwarder.java')
-rw-r--r--src/org/traccar/notification/EventForwarder.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java
index 8be4c23b0..b13f8fe43 100644
--- a/src/org/traccar/notification/EventForwarder.java
+++ b/src/org/traccar/notification/EventForwarder.java
@@ -30,6 +30,8 @@ import org.traccar.model.Position;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
+
import com.ning.http.client.FluentCaseInsensitiveStringsMap;
public abstract class EventForwarder {
@@ -46,8 +48,9 @@ public abstract class EventForwarder {
private static final String KEY_EVENT = "event";
private static final String KEY_GEOFENCE = "geofence";
private static final String KEY_DEVICE = "device";
+ private static final String KEY_USERS = "users";
- public final void forwardEvent(Event event, Position position) {
+ public final void forwardEvent(Event event, Position position, Set<Long> users) {
BoundRequestBuilder requestBuilder = Context.getAsyncHttpClient().preparePost(url);
requestBuilder.setBodyEncoding(StandardCharsets.UTF_8.name());
@@ -60,7 +63,7 @@ public abstract class EventForwarder {
requestBuilder.setHeaders(params);
}
- setContent(event, position, requestBuilder);
+ setContent(event, position, users, requestBuilder);
requestBuilder.execute();
}
@@ -79,7 +82,7 @@ public abstract class EventForwarder {
return paramsMap;
}
- protected String prepareJsonPayload(Event event, Position position) {
+ protected String prepareJsonPayload(Event event, Position position, Set<Long> users) {
Map<String, Object> data = new HashMap<>();
data.put(KEY_EVENT, event);
if (position != null) {
@@ -95,6 +98,7 @@ public abstract class EventForwarder {
data.put(KEY_GEOFENCE, geofence);
}
}
+ data.put(KEY_USERS, Context.getUsersManager().getItems(users));
try {
return Context.getObjectMapper().writeValueAsString(data);
} catch (JsonProcessingException e) {
@@ -104,6 +108,7 @@ public abstract class EventForwarder {
}
protected abstract String getContentType();
- protected abstract void setContent(Event event, Position position, BoundRequestBuilder requestBuilder);
+ protected abstract void setContent(
+ Event event, Position position, Set<Long> users, BoundRequestBuilder requestBuilder);
}