diff options
author | Ivan Martinez <ivanfmartinez@users.noreply.github.com> | 2018-06-01 10:43:16 -0300 |
---|---|---|
committer | Ivan Martinez <ivanfmartinez@users.noreply.github.com> | 2018-06-01 10:43:16 -0300 |
commit | 294c399e5b260313a2d49a0fed1516116a23fbd5 (patch) | |
tree | 24207d763ec5ef5bee09975a3c7e4745854a0779 /src/org/traccar/api/resource/NotificationResource.java | |
parent | 4fc750b585dd6b2953b16408dd57a8ef93fdeee9 (diff) | |
download | trackermap-server-294c399e5b260313a2d49a0fed1516116a23fbd5.tar.gz trackermap-server-294c399e5b260313a2d49a0fed1516116a23fbd5.tar.bz2 trackermap-server-294c399e5b260313a2d49a0fed1516116a23fbd5.zip |
update api to support notificators
Diffstat (limited to 'src/org/traccar/api/resource/NotificationResource.java')
-rw-r--r-- | src/org/traccar/api/resource/NotificationResource.java | 21 |
1 files changed, 19 insertions, 2 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(); + } + + } |