diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-09 17:56:37 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-09 17:56:37 -0700 |
commit | adafc5f6130854dd88c191dd04489073419ee41d (patch) | |
tree | e101d03069894f9a2fbfd388d9b3f93424cbe4d0 /src/main/java/org/traccar/notificators | |
parent | 29b5d05cfd66a9f51b7ce272c1fb07077bc715b2 (diff) | |
download | trackermap-server-adafc5f6130854dd88c191dd04489073419ee41d.tar.gz trackermap-server-adafc5f6130854dd88c191dd04489073419ee41d.tar.bz2 trackermap-server-adafc5f6130854dd88c191dd04489073419ee41d.zip |
Remove SMS from context
Diffstat (limited to 'src/main/java/org/traccar/notificators')
-rw-r--r-- | src/main/java/org/traccar/notificators/NotificatorSms.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/notificators/NotificatorSms.java b/src/main/java/org/traccar/notificators/NotificatorSms.java index f35b797cd..f4d1de0cb 100644 --- a/src/main/java/org/traccar/notificators/NotificatorSms.java +++ b/src/main/java/org/traccar/notificators/NotificatorSms.java @@ -16,8 +16,6 @@ */ package org.traccar.notificators; -import org.traccar.Context; -import org.traccar.Main; import org.traccar.database.StatisticsManager; import org.traccar.model.Event; import org.traccar.model.Position; @@ -26,16 +24,30 @@ import org.traccar.notification.MessageException; import org.traccar.notification.NotificationFormatter; import org.traccar.notification.NotificationMessage; import org.traccar.session.cache.CacheManager; +import org.traccar.sms.SmsManager; -public final class NotificatorSms implements Notificator { +import javax.inject.Inject; + +public class NotificatorSms implements Notificator { + + private final SmsManager smsManager; + private final CacheManager cacheManager; + private final StatisticsManager statisticsManager; + + @Inject + public NotificatorSms(SmsManager smsManager, CacheManager cacheManager, StatisticsManager statisticsManager) { + this.smsManager = smsManager; + this.cacheManager = cacheManager; + this.statisticsManager = statisticsManager; + } @Override public void send(User user, Event event, Position position) throws MessageException, InterruptedException { if (user.getPhone() != null) { NotificationMessage shortMessage = NotificationFormatter.formatMessage( - Main.getInjector().getInstance(CacheManager.class), user, event, position, "short"); - Main.getInjector().getInstance(StatisticsManager.class).registerSms(); - Context.getSmsManager().sendMessage(user.getPhone(), shortMessage.getBody(), false); + cacheManager, user, event, position, "short"); + statisticsManager.registerSms(); + smsManager.sendMessage(user.getPhone(), shortMessage.getBody(), false); } } |