diff options
-rw-r--r-- | src/org/traccar/notification/EventForwarder.java | 7 | ||||
-rw-r--r-- | src/org/traccar/notification/FormTypeEventForwarder.java | 8 |
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);
}
}
|