aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/database/NotificationManager.java23
-rw-r--r--src/org/traccar/model/Notification.java18
-rw-r--r--src/org/traccar/notification/NotificatorManager.java3
3 files changed, 23 insertions, 21 deletions
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index 1295b5b0c..37c6b720c 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -82,29 +82,16 @@ public class NotificationManager extends ExtendedObjectManager<Notification> {
if (usersToForward != null) {
usersToForward.add(userId);
}
- boolean sentWeb = false;
- boolean sentMail = false;
- boolean sentSms = Context.getSmsManager() == null;
+ final Set<String> notificationMethods = new HashSet<>();
for (long notificationId : getEffectiveNotifications(userId, deviceId, event.getServerTime())) {
Notification notification = getById(notificationId);
if (getById(notificationId).getType().equals(event.getType())) {
- if (!sentWeb && notification.getWeb()) {
- NotificatorManager.getWeb().sendAsync(userId, event, position);
- sentWeb = true;
- }
- if (!sentMail && notification.getMail()) {
- NotificatorManager.getMail().sendAsync(userId, event, position);
- sentMail = true;
- }
- if (!sentSms && notification.getSms()) {
- NotificatorManager.getSms().sendAsync(userId, event, position);
- sentSms = true;
- }
- }
- if (sentWeb && sentMail && sentSms) {
- break;
+ notificationMethods.addAll(notification.getMethods());
}
}
+ for (String nm : notificationMethods) {
+ NotificatorManager.getNotificator(nm).sendAsync(userId, event, position);
+ }
}
}
if (Context.getEventForwarder() != null) {
diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java
index cc80f2ae2..0d0b34cd4 100644
--- a/src/org/traccar/model/Notification.java
+++ b/src/org/traccar/model/Notification.java
@@ -15,6 +15,9 @@
*/
package org.traccar.model;
+import java.util.HashSet;
+import java.util.Set;
+
public class Notification extends ScheduledModel {
private boolean always;
@@ -66,4 +69,19 @@ public class Notification extends ScheduledModel {
public void setSms(boolean sms) {
this.sms = sms;
}
+
+ public Set<String> getMethods() {
+ final Set<String> set = new HashSet<>();
+ if (web) {
+ set.add("web");
+ }
+ if (mail) {
+ set.add("mail");
+ }
+ if (sms) {
+ set.add("sms");
+ }
+ return set;
+ }
+
}
diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java
index 9cf55b496..814c8dc1a 100644
--- a/src/org/traccar/notification/NotificatorManager.java
+++ b/src/org/traccar/notification/NotificatorManager.java
@@ -46,9 +46,6 @@ public class NotificatorManager {
return getNotificator("mail");
}
- public static Notificator getWeb() {
- return getNotificator("web");
- }
}