aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/notification/NotificatorManager.java6
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorFirebase.java18
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTraccar.java13
3 files changed, 30 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/notification/NotificatorManager.java b/src/main/java/org/traccar/notification/NotificatorManager.java
index c5f1ad8a0..dfd8cd3d6 100644
--- a/src/main/java/org/traccar/notification/NotificatorManager.java
+++ b/src/main/java/org/traccar/notification/NotificatorManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2020 Anton Tananaev (anton@traccar.org)
* Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,7 @@ import org.traccar.notificators.NotificatorMail;
import org.traccar.notificators.NotificatorNull;
import org.traccar.notificators.Notificator;
import org.traccar.notificators.NotificatorSms;
+import org.traccar.notificators.NotificatorTraccar;
import org.traccar.notificators.NotificatorWeb;
import org.traccar.notificators.NotificatorTelegram;
import org.traccar.notificators.NotificatorPushover;
@@ -59,6 +60,9 @@ public final class NotificatorManager {
case "firebase":
defaultNotificator = NotificatorFirebase.class.getCanonicalName();
break;
+ case "traccar":
+ defaultNotificator = NotificatorTraccar.class.getCanonicalName();
+ break;
case "telegram":
defaultNotificator = NotificatorTelegram.class.getCanonicalName();
break;
diff --git a/src/main/java/org/traccar/notificators/NotificatorFirebase.java b/src/main/java/org/traccar/notificators/NotificatorFirebase.java
index 75d325de2..8a3deee92 100644
--- a/src/main/java/org/traccar/notificators/NotificatorFirebase.java
+++ b/src/main/java/org/traccar/notificators/NotificatorFirebase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2020 Anton Tananaev (anton@traccar.org)
* Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,9 +32,8 @@ public class NotificatorFirebase extends Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorFirebase.class);
- private static final String URL = "https://fcm.googleapis.com/fcm/send";
-
- private String key;
+ private final String url;
+ private final String key;
public static class Notification {
@JsonProperty("body")
@@ -49,7 +48,14 @@ public class NotificatorFirebase extends Notificator {
}
public NotificatorFirebase() {
- key = Context.getConfig().getString("notificator.firebase.key");
+ this(
+ "https://fcm.googleapis.com/fcm/send",
+ Context.getConfig().getString("notificator.firebase.key"));
+ }
+
+ protected NotificatorFirebase(String url, String key) {
+ this.url = url;
+ this.key = key;
}
@Override
@@ -64,7 +70,7 @@ public class NotificatorFirebase extends Notificator {
message.tokens = user.getString("notificationTokens").split("[, ]");
message.notification = notification;
- Context.getClient().target(URL).request()
+ Context.getClient().target(url).request()
.header("Authorization", "key=" + key)
.async().post(Entity.json(message), new InvocationCallback<Object>() {
@Override
diff --git a/src/main/java/org/traccar/notificators/NotificatorTraccar.java b/src/main/java/org/traccar/notificators/NotificatorTraccar.java
new file mode 100644
index 000000000..2b75d60e4
--- /dev/null
+++ b/src/main/java/org/traccar/notificators/NotificatorTraccar.java
@@ -0,0 +1,13 @@
+package org.traccar.notificators;
+
+import org.traccar.Context;
+
+public class NotificatorTraccar extends NotificatorFirebase {
+
+ public NotificatorTraccar() {
+ super(
+ "https://www.traccar.org/push/",
+ Context.getConfig().getString("notificator.traccar.key"));
+ }
+
+}