aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorShinryuken <watertext@hotmail.it>2017-11-08 08:29:45 +0100
committerGitHub <noreply@github.com>2017-11-08 08:29:45 +0100
commit3363f82d05a02be3a035f984b1c7a365f327414f (patch)
tree28e49d3545e51f721f29b2e22a16c8e29ac318bd /src/org/traccar
parente61584b14a2cfe0075964bdc7207adb55062d61b (diff)
downloadtrackermap-server-3363f82d05a02be3a035f984b1c7a365f327414f.tar.gz
trackermap-server-3363f82d05a02be3a035f984b1c7a365f327414f.tar.bz2
trackermap-server-3363f82d05a02be3a035f984b1c7a365f327414f.zip
Default payload format as json, plaintext available as option
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/notification/EventForwarder.java7
-rw-r--r--src/org/traccar/notification/FormTypeEventForwarder.java8
2 files changed, 11 insertions, 4 deletions
diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java
index 5b9af5f1f..4e5d75d68 100644
--- a/src/org/traccar/notification/EventForwarder.java
+++ b/src/org/traccar/notification/EventForwarder.java
@@ -39,6 +39,7 @@ public abstract class EventForwarder {
private String header;
private final String payloadParamName;
private final String additionalParams;
+ private final boolean useTemplatesForPayload;
private final boolean prettyPrinted;
public EventForwarder() {
@@ -46,6 +47,7 @@ public abstract class EventForwarder {
header = Context.getConfig().getString("event.forward.header", "");
payloadParamName = Context.getConfig().getString("event.forward.paramMode.payloadParamName", "payload");
additionalParams = Context.getConfig().getString("event.forward.paramMode.additionalParams", "");
+ useTemplatesForPayload = Context.getConfig().getBoolean("event.forward.paramMode.useTemplatesForPayload");
prettyPrinted = Context.getConfig().getBoolean("event.forward.prettyPrintedPayload");
}
@@ -125,13 +127,14 @@ public abstract class EventForwarder {
protected String getAdditionalParams() {
return additionalParams;
}
+ protected boolean isUseTemplatesForPayload() {
+ return useTemplatesForPayload;
+ }
protected boolean isPrettyPrinted() {
return prettyPrinted;
}
-
protected abstract String getContentType();
-
protected abstract void setContent(Event event, Position position, BoundRequestBuilder requestBuilder);
}
diff --git a/src/org/traccar/notification/FormTypeEventForwarder.java b/src/org/traccar/notification/FormTypeEventForwarder.java
index d2c4aa691..e7564885d 100644
--- a/src/org/traccar/notification/FormTypeEventForwarder.java
+++ b/src/org/traccar/notification/FormTypeEventForwarder.java
@@ -17,8 +17,12 @@ public class FormTypeEventForwarder extends EventForwarder {
if (!getAdditionalParams().equals("")) {
requestBuilder.setFormParams(splitParams(getAdditionalParams(), "="));
}
- requestBuilder.addFormParam(getPayloadParamName(),
- NotificationFormatter.formatForwarderMessage(event, position));
+
+ String payload = isUseTemplatesForPayload()
+ ? NotificationFormatter.formatForwarderMessage(event, position)
+ : prepareJsonPayload(event, position);
+
+ requestBuilder.addFormParam(getPayloadParamName(), payload);
}
}