diff options
author | Abyss777 <abyss@fox5.ru> | 2017-02-21 15:20:25 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-02-21 15:20:25 +0500 |
commit | bd2a8efaddacbd8d8386ae38f000b633845639ab (patch) | |
tree | 80d4454311d9656fe79850ebcdb4131e3cc32634 /src/org/traccar/database/NotificationManager.java | |
parent | b6af1e997c125336e2ce9f5056d9502743f22034 (diff) | |
download | trackermap-server-bd2a8efaddacbd8d8386ae38f000b633845639ab.tar.gz trackermap-server-bd2a8efaddacbd8d8386ae38f000b633845639ab.tar.bz2 trackermap-server-bd2a8efaddacbd8d8386ae38f000b633845639ab.zip |
Implement SMS notifications with help smpp protocol
Diffstat (limited to 'src/org/traccar/database/NotificationManager.java')
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 4ae173c6a..48caa615c 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.traccar.model.Event; import org.traccar.model.Notification; import org.traccar.model.Position; import org.traccar.notification.NotificationMail; +import org.traccar.notification.NotificationSms; public class NotificationManager { @@ -65,6 +66,9 @@ public class NotificationManager { if (notification.getMail()) { NotificationMail.sendMailAsync(userId, event, position); } + if (notification.getSms()) { + NotificationSms.sendSmsAsync(userId, event, position); + } } } } @@ -131,8 +135,9 @@ public class NotificationManager { Notification cachedNotification = getUserNotificationByType(notification.getUserId(), notification.getType()); if (cachedNotification != null) { if (cachedNotification.getWeb() != notification.getWeb() - || cachedNotification.getMail() != notification.getMail()) { - if (!notification.getWeb() && !notification.getMail()) { + || cachedNotification.getMail() != notification.getMail() + || cachedNotification.getSms() != notification.getSms()) { + if (!notification.getWeb() && !notification.getMail() && !notification.getSms()) { try { dataManager.removeNotification(cachedNotification); } catch (SQLException error) { @@ -149,6 +154,7 @@ public class NotificationManager { try { cachedNotification.setWeb(notification.getWeb()); cachedNotification.setMail(notification.getMail()); + cachedNotification.setSms(notification.getSms()); cachedNotification.setAttributes(notification.getAttributes()); } finally { notificationsLock.writeLock().unlock(); @@ -162,7 +168,7 @@ public class NotificationManager { } else { notification.setId(cachedNotification.getId()); } - } else if (notification.getWeb() || notification.getMail()) { + } else if (notification.getWeb() || notification.getMail() || notification.getSms()) { try { dataManager.addNotification(notification); } catch (SQLException error) { |