diff options
author | Abyss777 <abyss@fox5.ru> | 2018-06-26 09:22:22 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2018-06-26 09:22:22 +0500 |
commit | aba402226403f8b3eb58cc01e8f536eb4104d35a (patch) | |
tree | ec884994ad90365fa9b385465a80391606f6d970 /src/org/traccar/database | |
parent | c700bfdb66071ba224ddf01e9827e721562fed7a (diff) | |
parent | 575deac9e2df1cbd0601328f7ea7a9f22029fa43 (diff) | |
download | trackermap-server-aba402226403f8b3eb58cc01e8f536eb4104d35a.tar.gz trackermap-server-aba402226403f8b3eb58cc01e8f536eb4104d35a.tar.bz2 trackermap-server-aba402226403f8b3eb58cc01e8f536eb4104d35a.zip |
Merge remote-tracking branch 'ivanfmartinez/notifications'
# Conflicts:
# src/org/traccar/Context.java
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/CommandsManager.java | 6 | ||||
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 25 |
2 files changed, 8 insertions, 23 deletions
diff --git a/src/org/traccar/database/CommandsManager.java b/src/org/traccar/database/CommandsManager.java index 8ddced5f7..c11f05f9b 100644 --- a/src/org/traccar/database/CommandsManager.java +++ b/src/org/traccar/database/CommandsManager.java @@ -61,10 +61,10 @@ public class CommandsManager extends ExtendedObjectManager<Command> { BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol()); protocol.sendTextCommand(phone, command); } else if (command.getType().equals(Command.TYPE_CUSTOM)) { - if (Context.getSmppManager() != null) { - Context.getSmppManager().sendMessageSync(phone, command.getString(Command.KEY_DATA), true); + if (Context.getSmsManager() != null) { + Context.getSmsManager().sendMessageSync(phone, command.getString(Command.KEY_DATA), true); } else { - throw new RuntimeException("SMPP client is not enabled"); + throw new RuntimeException("SMS is not enabled"); } } else { throw new RuntimeException("Command " + command.getType() + " is not supported"); diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 3bc048356..2c1ffc09c 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> 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()) { - 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; + notificationMethods.addAll(notification.getTransportMethods()); } } + for (String nm : notificationMethods) { + Context.getNotificatorManager().getNotificator(nm).sendAsync(userId, event, position); + } } } if (Context.getEventForwarder() != null) { |