aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notificators
diff options
context:
space:
mode:
authorAndreas <andreas-huth@freenet.de>2020-03-06 16:51:15 +0100
committerAndreas <andreas-huth@freenet.de>2020-03-06 16:51:15 +0100
commitd2835b2c6152b448179c0ecae6c9aadc4dce60a6 (patch)
treea8d3669fa71d683c6b702c92bedb998d198fb5e9 /src/main/java/org/traccar/notificators
parente46cb0260f224ec296feb7087cdfb05371e6f550 (diff)
downloadtraccar-server-d2835b2c6152b448179c0ecae6c9aadc4dce60a6.tar.gz
traccar-server-d2835b2c6152b448179c0ecae6c9aadc4dce60a6.tar.bz2
traccar-server-d2835b2c6152b448179c0ecae6c9aadc4dce60a6.zip
simplify code
Diffstat (limited to 'src/main/java/org/traccar/notificators')
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorPushover.java42
1 files changed, 8 insertions, 34 deletions
diff --git a/src/main/java/org/traccar/notificators/NotificatorPushover.java b/src/main/java/org/traccar/notificators/NotificatorPushover.java
index 6cad6f766..5c86503f3 100644
--- a/src/main/java/org/traccar/notificators/NotificatorPushover.java
+++ b/src/main/java/org/traccar/notificators/NotificatorPushover.java
@@ -21,11 +21,8 @@ import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.model.Event;
import org.traccar.model.Position;
-import org.traccar.notification.NotificationFormatter;
-
import org.traccar.model.User;
-import org.traccar.notification.PropertiesProvider;
-import java.util.Properties;
+import org.traccar.notification.NotificationFormatter;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
@@ -34,22 +31,9 @@ public class NotificatorPushover extends Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorPushover.class);
- private static Properties getProperties(PropertiesProvider provider) {
- Properties properties = new Properties();
- // optional: your user's device name to send the message directly
- // to that device, rather than all of the user's devices (multiple devices may be separated by a comma)
- String device = provider.getString("notificator.pushover.device");
- if (device != null) {
- properties.put("notificator.pushover.device", device);
- }
- return properties;
- }
-
-
private final String url;
private final String token;
private final String puser;
- private String device;
public static class Message {
@JsonProperty("token")
@@ -72,21 +56,15 @@ public class NotificatorPushover extends Notificator {
@Override
public void sendSync(long userId, Event event, Position position) {
- User user = Context.getPermissionsManager().getUser(userId);
-
- device = null;
- Properties properties = null;
+ final User user = Context.getPermissionsManager().getUser(userId);
- properties = getProperties(new PropertiesProvider(Context.getConfig()));
- if (properties != null) {
- device = properties.getProperty("notificator.pushover.device");
- }
+ String device = "";
- properties = getProperties(new PropertiesProvider(user));
- if (properties != null) {
- if (properties.getProperty("notificator.pushover.device") != null) {
- device = properties.getProperty("notificator.pushover.device");
- }
+ if (user.getAttributes().containsKey("notificator.pushover.device")) {
+ // optional: your user's device name to send the message directly
+ // to that device, rather than all of the user's devices (multiple devices may be separated by a comma)
+ // i.e.: device1,device2 (no space)
+ device = user.getString("notificator.pushover.device").replaceAll(" *, *", ",");
}
if (token == null) {
@@ -99,10 +77,6 @@ public class NotificatorPushover extends Notificator {
return;
}
- if (device == null) {
- device = "";
- }
-
Message message = new Message();
message.token = token;
message.user = puser;