forked from traccar/traccar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added notifications settings
- Loading branch information
Showing
32 changed files
with
1,009 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,21 @@ | |
|
||
<entry key='event.geofenceHandler'>true</entry> | ||
|
||
|
||
<!--<entry key='mail.smtp.host'>smtp.example.com</entry> | ||
for STARTTLS | ||
<entry key='mail.smtp.port'>587</entry> | ||
<entry key='mail.smtp.starttls.enable'>true</entry> | ||
for SSL | ||
<entry key='mail.smtp.port'>465</entry> | ||
<entry key='mail.smtp.ssl.enable'>true</entry> | ||
<entry key='mail.smtp.from'>[email protected]</entry> | ||
<entry key='mail.smtp.auth'>true</entry> | ||
<entry key='mail.smtp.username'>[email protected]</entry> | ||
<entry key='mail.smtp.password'>password</entry>--> | ||
|
||
<!-- DATABASE CONFIG --> | ||
|
||
<!--<entry key='database.driverFile'>hsqldb.jar</entry>--> | ||
|
@@ -280,6 +295,27 @@ | |
DELETE FROM device_geofence WHERE deviceId = :deviceId AND geofenceId = :geofenceId; | ||
</entry> | ||
|
||
<entry key='database.selectNotifications'> | ||
SELECT * FROM notifications; | ||
</entry> | ||
|
||
<entry key='database.insertNotification'> | ||
INSERT INTO notifications (userId, type, attributes) | ||
VALUES (:userId, :type, :attributes); | ||
</entry> | ||
|
||
<entry key='database.updateNotification'> | ||
UPDATE notifications SET | ||
userId = :userId, | ||
type = :type, | ||
attributes = :attributes | ||
WHERE id = :id; | ||
</entry> | ||
|
||
<entry key='database.deleteNotification'> | ||
DELETE FROM notifications WHERE id = :id; | ||
</entry> | ||
|
||
<!-- PROTOCOL CONFIG --> | ||
|
||
<entry key='gps103.port'>5001</entry> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,20 @@ | |
|
||
<entry key='event.geofenceHandler'>true</entry> | ||
|
||
<!--<entry key='mail.smtp.host'>smtp.example.com</entry> | ||
for STARTTLS | ||
<entry key='mail.smtp.port'>587</entry> | ||
<entry key='mail.smtp.starttls.enable'>true</entry> | ||
for SSL | ||
<entry key='mail.smtp.port'>465</entry> | ||
<entry key='mail.smtp.ssl.enable'>true</entry> | ||
<entry key='mail.smtp.from'>[email protected]</entry> | ||
<entry key='mail.smtp.auth'>true</entry> | ||
<entry key='mail.smtp.username'>[email protected]</entry> | ||
<entry key='mail.smtp.password'>password</entry>--> | ||
|
||
<!-- DATABASE CONFIG --> | ||
|
||
<entry key='database.driver'>org.h2.Driver</entry> | ||
|
@@ -252,6 +266,27 @@ | |
DELETE FROM device_geofence WHERE deviceId = :deviceId AND geofenceId = :geofenceId; | ||
</entry> | ||
|
||
<entry key='database.selectNotifications'> | ||
SELECT * FROM notifications; | ||
</entry> | ||
|
||
<entry key='database.insertNotification'> | ||
INSERT INTO notifications (userId, type, attributes) | ||
VALUES (:userId, :type, :attributes); | ||
</entry> | ||
|
||
<entry key='database.updateNotification'> | ||
UPDATE notifications SET | ||
userId = :userId, | ||
type = :type, | ||
attributes = :attributes | ||
WHERE id = :id; | ||
</entry> | ||
|
||
<entry key='database.deleteNotification'> | ||
DELETE FROM notifications WHERE id = :id; | ||
</entry> | ||
|
||
<!-- PROTOCOL CONFIG --> | ||
|
||
<entry key='gps103.port'>5001</entry> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,20 @@ | |
|
||
<entry key='event.geofenceHandler'>true</entry> | ||
|
||
<!--<entry key='mail.smtp.host'>smtp.example.com</entry> | ||
for STARTTLS | ||
<entry key='mail.smtp.port'>587</entry> | ||
<entry key='mail.smtp.starttls.enable'>true</entry> | ||
for SSL | ||
<entry key='mail.smtp.port'>465</entry> | ||
<entry key='mail.smtp.ssl.enable'>true</entry> | ||
<entry key='mail.smtp.from'>[email protected]</entry> | ||
<entry key='mail.smtp.auth'>true</entry> | ||
<entry key='mail.smtp.username'>[email protected]</entry> | ||
<entry key='mail.smtp.password'>password</entry>--> | ||
|
||
<!-- DATABASE CONFIG --> | ||
|
||
<entry key='database.driver'>org.h2.Driver</entry> | ||
|
@@ -252,6 +266,27 @@ | |
DELETE FROM device_geofence WHERE deviceId = :deviceId AND geofenceId = :geofenceId; | ||
</entry> | ||
|
||
<entry key='database.selectNotifications'> | ||
SELECT * FROM notifications; | ||
</entry> | ||
|
||
<entry key='database.insertNotification'> | ||
INSERT INTO notifications (userId, type, attributes) | ||
VALUES (:userId, :type, :attributes); | ||
</entry> | ||
|
||
<entry key='database.updateNotification'> | ||
UPDATE notifications SET | ||
userId = :userId, | ||
type = :type, | ||
attributes = :attributes | ||
WHERE id = :id; | ||
</entry> | ||
|
||
<entry key='database.deleteNotification'> | ||
DELETE FROM notifications WHERE id = :id; | ||
</entry> | ||
|
||
<!-- PROTOCOL CONFIG --> | ||
|
||
<entry key='gps103.port'>5001</entry> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.traccar.api.resource; | ||
|
||
import java.sql.SQLException; | ||
import java.util.Collection; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.traccar.Context; | ||
import org.traccar.api.BaseResource; | ||
import org.traccar.model.Notification; | ||
|
||
@Path("users/notifications") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public class NotificationResource extends BaseResource { | ||
|
||
@GET | ||
public Collection<Notification> get(@QueryParam("all") boolean all, | ||
@QueryParam("userId") long userId) throws SQLException { | ||
if (all) { | ||
return Context.getNotificationManager().getAllNotifications(); | ||
} | ||
if (userId == 0) { | ||
userId = getUserId(); | ||
} | ||
Context.getPermissionsManager().checkUser(getUserId(), userId); | ||
return Context.getNotificationManager().getUserNotifications(userId); | ||
} | ||
|
||
@POST | ||
public Response update(Notification entity) throws SQLException { | ||
Context.getPermissionsManager().checkReadonly(getUserId()); | ||
Context.getPermissionsManager().checkUser(getUserId(), entity.getUserId()); | ||
Context.getNotificationManager().updateNotification(entity); | ||
return Response.ok(entity).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.