aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/NotificationManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-28 17:07:25 +1200
committerGitHub <noreply@github.com>2018-06-28 17:07:25 +1200
commite849d3a56f55c83dc0ebed02165a124e30e22dbd (patch)
tree730e542145652ca1d06c64a6944dfa70e0b31b6b /src/org/traccar/database/NotificationManager.java
parent4d6229c7daa4a7b8f28337c5eca9a422876c98b1 (diff)
parent14840af2abd9976b8f5634af8e77f4a7126dfac1 (diff)
downloadtraccar-server-e849d3a56f55c83dc0ebed02165a124e30e22dbd.tar.gz
traccar-server-e849d3a56f55c83dc0ebed02165a124e30e22dbd.tar.bz2
traccar-server-e849d3a56f55c83dc0ebed02165a124e30e22dbd.zip
Merge pull request #3950 from Abyss777/notification_refactor
Notification refactor to allow custom "notificators"
Diffstat (limited to 'src/org/traccar/database/NotificationManager.java')
-rw-r--r--src/org/traccar/database/NotificationManager.java25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index 3bc048356..5dcb1d317 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -32,8 +32,6 @@ import org.traccar.model.Event;
import org.traccar.model.Notification;
import org.traccar.model.Position;
import org.traccar.model.Typed;
-import org.traccar.notification.NotificationMail;
-import org.traccar.notification.NotificationSms;
public class NotificationManager extends ExtendedObjectManager<Notification> {
@@ -85,29 +83,16 @@ public class NotificationManager extends ExtendedObjectManager<Notification> {
if (usersToForward != null) {
usersToForward.add(userId);
}
- boolean sentWeb = false;
- boolean sentMail = false;
- boolean sentSms = Context.getSmppManager() == null;
+ final Set<String> notificators = 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()) {
- Context.getConnectionManager().updateEvent(userId, event);
- sentWeb = true;
- }
- if (!sentMail && notification.getMail()) {
- NotificationMail.sendMailAsync(userId, event, position);
- sentMail = true;
- }
- if (!sentSms && notification.getSms()) {
- NotificationSms.sendSmsAsync(userId, event, position);
- sentSms = true;
- }
- }
- if (sentWeb && sentMail && sentSms) {
- break;
+ notificators.addAll(notification.getNotificatorsTypes());
}
}
+ for (String notificator : notificators) {
+ Context.getNotificatorManager().getNotificator(notificator).sendAsync(userId, event, position);
+ }
}
}
if (Context.getEventForwarder() != null) {