aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notificators
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/notificators')
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorFirebase.java3
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorPushover.java11
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTelegram.java11
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTraccar.java18
4 files changed, 31 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/notificators/NotificatorFirebase.java b/src/main/java/org/traccar/notificators/NotificatorFirebase.java
index 8a3deee92..89cdbcb14 100644
--- a/src/main/java/org/traccar/notificators/NotificatorFirebase.java
+++ b/src/main/java/org/traccar/notificators/NotificatorFirebase.java
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
+import org.traccar.config.Keys;
import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.model.User;
@@ -50,7 +51,7 @@ public class NotificatorFirebase extends Notificator {
public NotificatorFirebase() {
this(
"https://fcm.googleapis.com/fcm/send",
- Context.getConfig().getString("notificator.firebase.key"));
+ Context.getConfig().getString(Keys.NOTIFICATOR_FIREBASE_KEY));
}
protected NotificatorFirebase(String url, String key) {
diff --git a/src/main/java/org/traccar/notificators/NotificatorPushover.java b/src/main/java/org/traccar/notificators/NotificatorPushover.java
index 141d652ca..189af7834 100644
--- a/src/main/java/org/traccar/notificators/NotificatorPushover.java
+++ b/src/main/java/org/traccar/notificators/NotificatorPushover.java
@@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
+import org.traccar.config.Keys;
import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.model.User;
@@ -33,7 +34,7 @@ public class NotificatorPushover extends Notificator {
private final String url;
private final String token;
- private final String puser;
+ private final String user;
public static class Message {
@JsonProperty("token")
@@ -48,8 +49,8 @@ public class NotificatorPushover extends Notificator {
public NotificatorPushover() {
url = "https://api.pushover.net/1/messages.json";
- token = Context.getConfig().getString("notificator.pushover.token");
- puser = Context.getConfig().getString("notificator.pushover.user");
+ token = Context.getConfig().getString(Keys.NOTIFICATOR_PUSHOVER_TOKEN);
+ user = Context.getConfig().getString(Keys.NOTIFICATOR_PUSHOVER_USER);
}
@Override
@@ -68,14 +69,14 @@ public class NotificatorPushover extends Notificator {
return;
}
- if (puser == null) {
+ if (this.user == null) {
LOGGER.warn("Pushover user not found");
return;
}
Message message = new Message();
message.token = token;
- message.user = puser;
+ message.user = this.user;
message.device = device;
message.message = NotificationFormatter.formatShortMessage(userId, event, position);
diff --git a/src/main/java/org/traccar/notificators/NotificatorTelegram.java b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
index c0b51d043..6b8bc426d 100644
--- a/src/main/java/org/traccar/notificators/NotificatorTelegram.java
+++ b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
+import org.traccar.config.Keys;
import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.notification.NotificationFormatter;
@@ -30,8 +31,8 @@ public class NotificatorTelegram extends Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorTelegram.class);
- private String url;
- private String chatId;
+ private final String url;
+ private final String chatId;
public static class Message {
@JsonProperty("chat_id")
@@ -45,8 +46,8 @@ public class NotificatorTelegram extends Notificator {
public NotificatorTelegram() {
url = String.format(
"https://api.telegram.org/bot%s/sendMessage",
- Context.getConfig().getString("notificator.telegram.key"));
- chatId = Context.getConfig().getString("notificator.telegram.chatId");
+ Context.getConfig().getString(Keys.NOTIFICATOR_TELEGRAM_KEY));
+ chatId = Context.getConfig().getString(Keys.NOTIFICATOR_TELEGRAM_CHAT_ID);
}
@Override
diff --git a/src/main/java/org/traccar/notificators/NotificatorTraccar.java b/src/main/java/org/traccar/notificators/NotificatorTraccar.java
index 2b75d60e4..5bcd18b5e 100644
--- a/src/main/java/org/traccar/notificators/NotificatorTraccar.java
+++ b/src/main/java/org/traccar/notificators/NotificatorTraccar.java
@@ -1,13 +1,29 @@
+/*
+ * Copyright 2020 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.traccar.notificators;
import org.traccar.Context;
+import org.traccar.config.Keys;
public class NotificatorTraccar extends NotificatorFirebase {
public NotificatorTraccar() {
super(
"https://www.traccar.org/push/",
- Context.getConfig().getString("notificator.traccar.key"));
+ Context.getConfig().getString(Keys.NOTIFICATOR_TRACCAR_KEY));
}
}