diff options
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/api/resource/NotificationResource.java | 23 | ||||
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 9 | ||||
-rw-r--r-- | src/org/traccar/model/Notification.java | 16 | ||||
-rw-r--r-- | src/org/traccar/notification/NotificatorManager.java | 2 |
4 files changed, 24 insertions, 26 deletions
diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java index 9046569a0..bec1ce3ab 100644 --- a/src/org/traccar/api/resource/NotificationResource.java +++ b/src/org/traccar/api/resource/NotificationResource.java @@ -48,11 +48,17 @@ public class NotificationResource extends ExtendedObjectResource<Notification> { public Collection<Typed> get() { return Context.getNotificationManager().getAllNotificationTypes(); } + + @GET + @Path("notificators") + public Collection<Typed> getNotificators() { + return Context.getNotificatorManager().getAllNotificatorTypes(); + } @POST @Path("test") public Response testMessage() throws NotificationException, InterruptedException { - for (Typed method : Context.getNotificatorManager().getNotificatorTypes()) { + for (Typed method : Context.getNotificatorManager().getAllNotificatorTypes()) { Context.getNotificatorManager() .getNotificator(method.getType()).sendSync(getUserId(), new Event("test", 0), null); } @@ -60,18 +66,11 @@ public class NotificationResource extends ExtendedObjectResource<Notification> { } @POST - @Path("test/{method}") - public Response testMessage(@PathParam("method") String method) throws NotificationException, InterruptedException { - Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null); + @Path("test/{notificator}") + public Response testMessage(@PathParam("notificator") String notificator) + throws NotificationException, InterruptedException { + Context.getNotificatorManager().getNotificator(notificator).sendSync(getUserId(), new Event("test", 0), null); return Response.noContent().build(); } - - @GET - @Path("notificators") - public Collection<Typed> getNotificators() { - return Context.getNotificatorManager().getNotificatorTypes(); - } - - } diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index b2a30e4f1..5dcb1d317 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -83,16 +83,15 @@ public class NotificationManager extends ExtendedObjectManager<Notification> { if (usersToForward != null) { usersToForward.add(userId); } - final Set<String> notificationMethods = new HashSet<>(); + final Set<String> notificators = new HashSet<>(); for (long notificationId : getEffectiveNotifications(userId, deviceId, event.getServerTime())) { Notification notification = getById(notificationId); if (getById(notificationId).getType().equals(event.getType())) { - notificationMethods.addAll(notification.getTransportMethods()); + notificators.addAll(notification.getNotificatorsTypes()); } } - for (String notificationMethod : notificationMethods) { - Context.getNotificatorManager() - .getNotificator(notificationMethod).sendAsync(userId, event, position); + for (String notificator : notificators) { + Context.getNotificatorManager().getNotificator(notificator).sendAsync(userId, event, position); } } } diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java index 4923798c2..f1983a03a 100644 --- a/src/org/traccar/model/Notification.java +++ b/src/org/traccar/model/Notification.java @@ -45,23 +45,23 @@ public class Notification extends ScheduledModel { } - private String transports; + private String notificators; - public String getTransports() { - return transports; + public String getNotificators() { + return notificators; } - public void setTransports(String transports) { - this.transports = transports; + public void setNotificators(String transports) { + this.notificators = transports; } @JsonIgnore @QueryIgnore - public Set<String> getTransportMethods() { + public Set<String> getNotificatorsTypes() { final Set<String> result = new HashSet<>(); - if (transports != null) { - final String[] transportsList = transports.split(","); + if (notificators != null) { + final String[] transportsList = notificators.split(","); for (String transport : transportsList) { result.add(transport.trim()); } diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java index 87a294345..bb55844f3 100644 --- a/src/org/traccar/notification/NotificatorManager.java +++ b/src/org/traccar/notification/NotificatorManager.java @@ -64,7 +64,7 @@ public final class NotificatorManager { } - public Set<Typed> getNotificatorTypes() { + public Set<Typed> getAllNotificatorTypes() { Set<Typed> result = new HashSet<>(); for (String notificator : notificators.keySet()) { result.add(new Typed(notificator)); |