aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorLuiz Kill <luizkill@gmail.com>2022-07-21 13:55:55 -0300
committerLuiz Kill <luizkill@gmail.com>2022-07-21 13:55:55 -0300
commiteb8d5c2d83a6aa91e0932382a852a3f4aca33120 (patch)
tree3ab8deaeaa6a2143f74b34088eecf589b34c22b2 /src/main/java
parentd42f935e4119fb87002b8b275c4237290ef7f12b (diff)
downloadtrackermap-server-eb8d5c2d83a6aa91e0932382a852a3f4aca33120.tar.gz
trackermap-server-eb8d5c2d83a6aa91e0932382a852a3f4aca33120.tar.bz2
trackermap-server-eb8d5c2d83a6aa91e0932382a852a3f4aca33120.zip
Adds Pushover user attributes
The Pushover integration doesn't allow messages to be delivered per-user, since the NOTIFICATOR_PUSHOVER_USER config is single for the whole instance.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorPushover.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/notificators/NotificatorPushover.java b/src/main/java/org/traccar/notificators/NotificatorPushover.java
index 671984f86..0604c49f3 100644
--- a/src/main/java/org/traccar/notificators/NotificatorPushover.java
+++ b/src/main/java/org/traccar/notificators/NotificatorPushover.java
@@ -56,25 +56,24 @@ public class NotificatorPushover implements Notificator {
url = "https://api.pushover.net/1/messages.json";
token = config.getString(Keys.NOTIFICATOR_PUSHOVER_TOKEN);
user = config.getString(Keys.NOTIFICATOR_PUSHOVER_USER);
- if (token == null || user == null) {
- throw new RuntimeException("Pushover token or user missing");
- }
}
@Override
public void send(User user, Event event, Position position) {
-
- String device = "";
- if (user.hasAttribute("notificator.pushover.device")) {
- device = user.getString("notificator.pushover.device").replaceAll(" *, *", ",");
- }
-
var shortMessage = notificationFormatter.formatMessage(user, event, position, "short");
Message message = new Message();
message.token = token;
- message.user = this.user;
- message.device = device;
+
+ message.user = user.getString("pushoverUserKey");
+ if (message.user == null) {
+ message.user = this.user;
+ }
+
+ if (user.hasAttribute("pushoverDeviceNames")) {
+ message.device = user.getString("pushoverDeviceNames").replaceAll(" *, *", ",");
+ }
+
message.title = shortMessage.getSubject();
message.message = shortMessage.getBody();