aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorIvan Martinez <ivanfmartinez@users.noreply.github.com>2018-03-25 22:16:09 -0300
committerIvan Martinez <ivanfmartinez@users.noreply.github.com>2018-04-01 18:09:50 -0300
commitbb289a69fa4d292378c5c534e10985be65b2e392 (patch)
tree43ded3eed61aabf70d8212e663aa6c966b55a9dc /src/org/traccar/database
parent0117dfeef0a7ffbc7a47d9681811177136336730 (diff)
downloadtrackermap-server-bb289a69fa4d292378c5c534e10985be65b2e392.tar.gz
trackermap-server-bb289a69fa4d292378c5c534e10985be65b2e392.tar.bz2
trackermap-server-bb289a69fa4d292378c5c534e10985be65b2e392.zip
generalization for notifications processing
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/CommandsManager.java6
-rw-r--r--src/org/traccar/database/NotificationManager.java26
2 files changed, 9 insertions, 23 deletions
diff --git a/src/org/traccar/database/CommandsManager.java b/src/org/traccar/database/CommandsManager.java
index 9ceb995ef..2e68fae5a 100644
--- a/src/org/traccar/database/CommandsManager.java
+++ b/src/org/traccar/database/CommandsManager.java
@@ -58,10 +58,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 1c59a8666..37c6b720c 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -32,8 +32,7 @@ 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;
+import org.traccar.notification.NotificatorManager;
public class NotificationManager extends ExtendedObjectManager<Notification> {
@@ -83,29 +82,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.getMethods());
}
}
+ for (String nm : notificationMethods) {
+ NotificatorManager.getNotificator(nm).sendAsync(userId, event, position);
+ }
}
}
if (Context.getEventForwarder() != null) {