diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-28 22:24:57 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-28 22:24:57 -0800 |
commit | 5efc76957497b6537d6295d40f2633eef5e54b7b (patch) | |
tree | f5a2b3e4fe264e096ab14d5891206bb5c41e9cb8 /src/main/java/org/traccar | |
parent | 680df72d9dd0178b2bcec60c4e9c1c997c60630c (diff) | |
download | trackermap-server-5efc76957497b6537d6295d40f2633eef5e54b7b.tar.gz trackermap-server-5efc76957497b6537d6295d40f2633eef5e54b7b.tar.bz2 trackermap-server-5efc76957497b6537d6295d40f2633eef5e54b7b.zip |
Enable SMS API for commands
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r-- | src/main/java/org/traccar/Context.java | 9 | ||||
-rw-r--r-- | src/main/java/org/traccar/notificators/NotificatorSms.java | 18 |
2 files changed, 5 insertions, 22 deletions
diff --git a/src/main/java/org/traccar/Context.java b/src/main/java/org/traccar/Context.java index 8492e4230..d23314c06 100644 --- a/src/main/java/org/traccar/Context.java +++ b/src/main/java/org/traccar/Context.java @@ -60,8 +60,8 @@ import org.traccar.notification.EventForwarder; import org.traccar.notification.NotificatorManager; import org.traccar.reports.model.TripsConfig; import org.traccar.schedule.ScheduleManager; +import org.traccar.sms.HttpSmsClient; import org.traccar.sms.SmsManager; -import org.traccar.sms.smpp.SmppClient; import org.traccar.web.WebServer; import javax.ws.rs.client.Client; @@ -326,12 +326,7 @@ public final class Context { tripsConfig = initTripsConfig(); if (config.getBoolean("sms.enable")) { - final String smsManagerClass = config.getString("sms.manager.class", SmppClient.class.getCanonicalName()); - try { - smsManager = (SmsManager) Class.forName(smsManagerClass).newInstance(); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - LOGGER.warn("Error loading SMS Manager class : " + smsManagerClass, e); - } + smsManager = new HttpSmsClient(); } if (config.getBoolean("event.enable")) { diff --git a/src/main/java/org/traccar/notificators/NotificatorSms.java b/src/main/java/org/traccar/notificators/NotificatorSms.java index d5c791eae..8124e40b1 100644 --- a/src/main/java/org/traccar/notificators/NotificatorSms.java +++ b/src/main/java/org/traccar/notificators/NotificatorSms.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2020 Anton Tananaev (anton@traccar.org) * Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,27 +24,15 @@ import org.traccar.model.Position; import org.traccar.model.User; import org.traccar.notification.MessageException; import org.traccar.notification.NotificationFormatter; -import org.traccar.sms.SmsManager; public final class NotificatorSms extends Notificator { - private final SmsManager smsManager; - - public NotificatorSms() throws ClassNotFoundException, InstantiationException, IllegalAccessException { - final String smsClass = Context.getConfig().getString("notificator.sms.manager.class", ""); - if (smsClass.length() > 0) { - smsManager = (SmsManager) Class.forName(smsClass).newInstance(); - } else { - smsManager = Context.getSmsManager(); - } - } - @Override public void sendAsync(long userId, Event event, Position position) { final User user = Context.getPermissionsManager().getUser(userId); if (user.getPhone() != null) { Main.getInjector().getInstance(StatisticsManager.class).registerSms(); - smsManager.sendMessageAsync(user.getPhone(), + Context.getSmsManager().sendMessageAsync(user.getPhone(), NotificationFormatter.formatShortMessage(userId, event, position), false); } } @@ -54,7 +42,7 @@ public final class NotificatorSms extends Notificator { final User user = Context.getPermissionsManager().getUser(userId); if (user.getPhone() != null) { Main.getInjector().getInstance(StatisticsManager.class).registerSms(); - smsManager.sendMessageSync(user.getPhone(), + Context.getSmsManager().sendMessageSync(user.getPhone(), NotificationFormatter.formatShortMessage(userId, event, position), false); } } |