aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notification
diff options
context:
space:
mode:
authorKhaksar Weqar <wkhaksar1@gmail.com>2021-11-04 09:56:42 +0100
committerKhaksar Weqar <wkhaksar1@gmail.com>2021-11-04 09:56:42 +0100
commit2c4b4cdd2e8c8c09bcbdc18dd9cbaeba5bd64ce7 (patch)
tree958d3151cc5cd3d0c4bf2b72016c90c92dc3659b /src/main/java/org/traccar/notification
parent64d38de4a3c8063ca8aabdc5583843e6db3c9446 (diff)
downloadtrackermap-server-2c4b4cdd2e8c8c09bcbdc18dd9cbaeba5bd64ce7.tar.gz
trackermap-server-2c4b4cdd2e8c8c09bcbdc18dd9cbaeba5bd64ce7.tar.bz2
trackermap-server-2c4b4cdd2e8c8c09bcbdc18dd9cbaeba5bd64ce7.zip
formatting-reverted
Diffstat (limited to 'src/main/java/org/traccar/notification')
-rw-r--r--src/main/java/org/traccar/notification/NotificationFormatter.java9
-rw-r--r--src/main/java/org/traccar/notification/NotificationMessage.java (renamed from src/main/java/org/traccar/notification/FullMessage.java)4
-rw-r--r--src/main/java/org/traccar/notification/ShortMessage.java36
-rw-r--r--src/main/java/org/traccar/notification/TextTemplateFormatter.java17
4 files changed, 7 insertions, 59 deletions
diff --git a/src/main/java/org/traccar/notification/NotificationFormatter.java b/src/main/java/org/traccar/notification/NotificationFormatter.java
index f33961c8b..9a6723a71 100644
--- a/src/main/java/org/traccar/notification/NotificationFormatter.java
+++ b/src/main/java/org/traccar/notification/NotificationFormatter.java
@@ -58,14 +58,9 @@ public final class NotificationFormatter {
return velocityContext;
}
- public static FullMessage formatFullMessage(long userId, Event event, Position position) {
+ public static NotificationMessage formatMessage(long userId, Event event, Position position, String templatePath) {
VelocityContext velocityContext = prepareContext(userId, event, position);
- return TextTemplateFormatter.formatFullMessage(velocityContext, event.getType());
- }
-
- public static ShortMessage formatShortMessage(long userId, Event event, Position position) {
- VelocityContext velocityContext = prepareContext(userId, event, position);
- return TextTemplateFormatter.formatShortMessage(velocityContext, event.getType());
+ return TextTemplateFormatter.formatMessage(velocityContext, event.getType(), templatePath);
}
}
diff --git a/src/main/java/org/traccar/notification/FullMessage.java b/src/main/java/org/traccar/notification/NotificationMessage.java
index f66537c6e..0fb8d7654 100644
--- a/src/main/java/org/traccar/notification/FullMessage.java
+++ b/src/main/java/org/traccar/notification/NotificationMessage.java
@@ -16,12 +16,12 @@
*/
package org.traccar.notification;
-public class FullMessage {
+public class NotificationMessage {
private String subject;
private String body;
- public FullMessage(String subject, String body) {
+ public NotificationMessage(String subject, String body) {
this.subject = subject;
this.body = body;
}
diff --git a/src/main/java/org/traccar/notification/ShortMessage.java b/src/main/java/org/traccar/notification/ShortMessage.java
deleted file mode 100644
index 28812a1f1..000000000
--- a/src/main/java/org/traccar/notification/ShortMessage.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 title, String body) {
- this.title = title;
- 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 8a4d35677..6a95628f0 100644
--- a/src/main/java/org/traccar/notification/TextTemplateFormatter.java
+++ b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
@@ -71,22 +71,11 @@ public final class TextTemplateFormatter {
return template;
}
- public static FullMessage formatFullMessage(VelocityContext velocityContext, String name) {
- String formattedMessage = formatMessage(velocityContext, name, "full");
- return new FullMessage((String) velocityContext.get("subject"), formattedMessage);
- }
-
- 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(
- VelocityContext velocityContext, String name, String templatePath) {
-
+ public static NotificationMessage formatMessage(VelocityContext velocityContext, String name, String templatePath) {
StringWriter writer = new StringWriter();
getTemplate(name, templatePath).merge(velocityContext, writer);
- return writer.toString();
+ String formattedMessage = writer.toString();
+ return new NotificationMessage((String) velocityContext.get("subject"), formattedMessage);
}
}