aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notification
diff options
context:
space:
mode:
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/TextTemplateFormatter.java15
3 files changed, 6 insertions, 22 deletions
diff --git a/src/main/java/org/traccar/notification/NotificationFormatter.java b/src/main/java/org/traccar/notification/NotificationFormatter.java
index dabc75b8b..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 String 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/TextTemplateFormatter.java b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
index c7cac2d4d..b7058c824 100644
--- a/src/main/java/org/traccar/notification/TextTemplateFormatter.java
+++ b/src/main/java/org/traccar/notification/TextTemplateFormatter.java
@@ -71,21 +71,10 @@ 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 String formatShortMessage(VelocityContext velocityContext, String name) {
- return formatMessage(velocityContext, name, "short");
- }
-
- 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();
+ return new NotificationMessage((String) velocityContext.get("subject"), writer.toString());
}
}