diff options
Diffstat (limited to 'src/main/java/org/traccar/notification')
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( |