aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notification
diff options
context:
space:
mode:
authorKhaksar Weqar <wkhaksar1@gmail.com>2021-11-03 09:42:35 +0100
committerKhaksar Weqar <wkhaksar1@gmail.com>2021-11-03 09:42:35 +0100
commit9fd24af30db35411de8d30b96be665f00d75c0ad (patch)
treed37d51cff9e0aefddb242194487ff6435bc61814 /src/main/java/org/traccar/notification
parent64d38de4a3c8063ca8aabdc5583843e6db3c9446 (diff)
downloadtrackermap-server-9fd24af30db35411de8d30b96be665f00d75c0ad.tar.gz
trackermap-server-9fd24af30db35411de8d30b96be665f00d75c0ad.tar.bz2
trackermap-server-9fd24af30db35411de8d30b96be665f00d75c0ad.zip
redundant-code-removed
Diffstat (limited to 'src/main/java/org/traccar/notification')
-rw-r--r--src/main/java/org/traccar/notification/Message.java (renamed from src/main/java/org/traccar/notification/FullMessage.java)4
-rw-r--r--src/main/java/org/traccar/notification/NotificationFormatter.java10
-rw-r--r--src/main/java/org/traccar/notification/ShortMessage.java36
-rw-r--r--src/main/java/org/traccar/notification/TextTemplateFormatter.java13
4 files changed, 8 insertions, 55 deletions
diff --git a/src/main/java/org/traccar/notification/FullMessage.java b/src/main/java/org/traccar/notification/Message.java
index f66537c6e..33f38007c 100644
--- a/src/main/java/org/traccar/notification/FullMessage.java
+++ b/src/main/java/org/traccar/notification/Message.java
@@ -16,12 +16,12 @@
*/
package org.traccar.notification;
-public class FullMessage {
+public class Message {
private String subject;
private String body;
- public FullMessage(String subject, String body) {
+ public Message(String subject, String body) {
this.subject = subject;
this.body = body;
}
diff --git a/src/main/java/org/traccar/notification/NotificationFormatter.java b/src/main/java/org/traccar/notification/NotificationFormatter.java
index f33961c8b..3170d1204 100644
--- a/src/main/java/org/traccar/notification/NotificationFormatter.java
+++ b/src/main/java/org/traccar/notification/NotificationFormatter.java
@@ -58,14 +58,8 @@ public final class NotificationFormatter {
return velocityContext;
}
- public static FullMessage formatFullMessage(long userId, Event event, Position position) {
+ public static Message formatMessage(long userId, Event event, Position position, String templatePath) {
VelocityContext velocityContext = prepareContext(userId, event, position);
- return TextTemplateFormatter.formatFullMessage(velocityContext, event.getType());
+ return TextTemplateFormatter.formatMessage(velocityContext, event.getType(), templatePath);
}
-
- 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
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..77a2fea05 100644
--- a/src/main/java/org/traccar/notification/TextTemplateFormatter.java
+++ b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
@@ -71,17 +71,12 @@ 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 Message formatMessage(VelocityContext velocityContext, String name, String templatePath) {
+ String formattedMessage = format(velocityContext, name, templatePath);
+ return new Message((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(
+ private static String format(
VelocityContext velocityContext, String name, String templatePath) {
StringWriter writer = new StringWriter();