diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2022-08-02 06:36:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 06:36:08 -0700 |
commit | 057262001dd933738fc070a57d51dc57518aa57b (patch) | |
tree | 0176d2fcca4b942c5e839523a33b91a8909e226a /src/main/java/org/traccar | |
parent | 910965c3d08745d68cbf812ed96eef7323dbb893 (diff) | |
parent | ea68646e6572945db82bfdf8e732957492e19b03 (diff) | |
download | trackermap-server-057262001dd933738fc070a57d51dc57518aa57b.tar.gz trackermap-server-057262001dd933738fc070a57d51dc57518aa57b.tar.bz2 trackermap-server-057262001dd933738fc070a57d51dc57518aa57b.zip |
Merge pull request #4908 from lzkill/pushover-user-attributes
Adds Pushover user attributes
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r-- | src/main/java/org/traccar/notificators/NotificatorPushover.java | 21 |
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..105cb27f0 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(); |