aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notification
diff options
context:
space:
mode:
authorKhaksar Weqar <wkhaksar1@gmail.com>2021-11-02 16:22:03 +0100
committerKhaksar Weqar <wkhaksar1@gmail.com>2021-11-02 16:22:03 +0100
commit12b26830b3eae6fac9e87c462fc09cfe6c962964 (patch)
treebc852a5f7c48b99108be4462a037251d6d384cd9 /src/main/java/org/traccar/notification
parentf686847115097cf388a775fad6f13b8bf6893193 (diff)
downloadtrackermap-server-12b26830b3eae6fac9e87c462fc09cfe6c962964.tar.gz
trackermap-server-12b26830b3eae6fac9e87c462fc09cfe6c962964.tar.bz2
trackermap-server-12b26830b3eae6fac9e87c462fc09cfe6c962964.zip
short-message-title-from-templates
Diffstat (limited to 'src/main/java/org/traccar/notification')
-rw-r--r--src/main/java/org/traccar/notification/NotificationFormatter.java2
-rw-r--r--src/main/java/org/traccar/notification/ShortMessage.java36
-rw-r--r--src/main/java/org/traccar/notification/TextTemplateFormatter.java5
3 files changed, 40 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/notification/NotificationFormatter.java b/src/main/java/org/traccar/notification/NotificationFormatter.java
index dabc75b8b..f33961c8b 100644
--- a/src/main/java/org/traccar/notification/NotificationFormatter.java
+++ b/src/main/java/org/traccar/notification/NotificationFormatter.java
@@ -63,7 +63,7 @@ public final class NotificationFormatter {
return TextTemplateFormatter.formatFullMessage(velocityContext, event.getType());
}
- public static String formatShortMessage(long userId, Event event, Position position) {
+ public static ShortMessage formatShortMessage(long userId, Event event, Position position) {
VelocityContext velocityContext = prepareContext(userId, event, position);
return TextTemplateFormatter.formatShortMessage(velocityContext, event.getType());
}
diff --git a/src/main/java/org/traccar/notification/ShortMessage.java b/src/main/java/org/traccar/notification/ShortMessage.java
new file mode 100644
index 000000000..a0ee61def
--- /dev/null
+++ b/src/main/java/org/traccar/notification/ShortMessage.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar.notification;
+
+public class ShortMessage {
+
+ private String title;
+ private String body;
+
+ public ShortMessage(String subject, String body) {
+ this.title = subject;
+ this.body = body;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getBody() {
+ return body;
+ }
+}
diff --git a/src/main/java/org/traccar/notification/TextTemplateFormatter.java b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
index c7cac2d4d..8a4d35677 100644
--- a/src/main/java/org/traccar/notification/TextTemplateFormatter.java
+++ b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
@@ -76,8 +76,9 @@ public final class TextTemplateFormatter {
return new FullMessage((String) velocityContext.get("subject"), formattedMessage);
}
- public static String formatShortMessage(VelocityContext velocityContext, String name) {
- return formatMessage(velocityContext, name, "short");
+ public static ShortMessage formatShortMessage(VelocityContext velocityContext, String name) {
+ String formattedMessage = formatMessage(velocityContext, name, "short");
+ return new ShortMessage((String) velocityContext.get("title"), formattedMessage);
}
private static String formatMessage(