diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/api/resource/NotificationResource.java | 21 | ||||
-rw-r--r-- | src/org/traccar/notification/NotificatorManager.java | 8 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java index 830e34fc0..2347b43fa 100644 --- a/src/org/traccar/api/resource/NotificationResource.java +++ b/src/org/traccar/api/resource/NotificationResource.java @@ -21,6 +21,7 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -51,9 +52,25 @@ public class NotificationResource extends ExtendedObjectResource<Notification> { @POST @Path("test") public Response testMessage() throws NotificationException, InterruptedException { - Context.getNotificatorManager().getMail().sendSync(getUserId(), new Event("test", 0), null); - Context.getNotificatorManager().getSms().sendSync(getUserId(), new Event("test", 0), null); + for (String method : Context.getNotificatorManager().getNotificatorTypes()) { + Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null); + } return Response.noContent().build(); } + @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); + return Response.noContent().build(); + } + + + @GET + @Path("notificators") + public Collection<String> getNotificators() { + return Context.getNotificatorManager().getNotificatorTypes(); + } + + } diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java index c58149847..20c7749d2 100644 --- a/src/org/traccar/notification/NotificatorManager.java +++ b/src/org/traccar/notification/NotificatorManager.java @@ -20,6 +20,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; +import java.util.Set; import org.traccar.Context; import org.traccar.helper.Log; @@ -60,12 +61,9 @@ public final class NotificatorManager { return n; } - public Notificator getSms() { - return getNotificator("sms"); - } - public Notificator getMail() { - return getNotificator("mail"); + public Set<String> getNotificatorTypes() { + return notificators.keySet(); } |