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/Notificator.java19
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorFirebase.java9
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorMail.java4
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorNull.java9
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorPushover.java9
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorSms.java18
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorTelegram.java9
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorWeb.java4
8 files changed, 17 insertions, 64 deletions
diff --git a/src/main/java/org/traccar/notificators/Notificator.java b/src/main/java/org/traccar/notificators/Notificator.java
index 3903f3008..052365c7a 100644
--- a/src/main/java/org/traccar/notificators/Notificator.java
+++ b/src/main/java/org/traccar/notificators/Notificator.java
@@ -16,28 +16,13 @@
*/
package org.traccar.notificators;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.model.User;
import org.traccar.notification.MessageException;
-public abstract class Notificator {
+public interface Notificator {
- private static final Logger LOGGER = LoggerFactory.getLogger(Notificator.class);
-
- public void sendAsync(User user, Event event, Position position) {
- new Thread(() -> {
- try {
- sendSync(user, event, position);
- } catch (MessageException | InterruptedException error) {
- LOGGER.warn("Event send error", error);
- }
- }).start();
- }
-
- public abstract void sendSync(User user, Event event, Position position)
- throws MessageException, InterruptedException;
+ void send(User user, Event event, Position position) throws MessageException, InterruptedException;
}
diff --git a/src/main/java/org/traccar/notificators/NotificatorFirebase.java b/src/main/java/org/traccar/notificators/NotificatorFirebase.java
index ee22b3a22..cafd2237d 100644
--- a/src/main/java/org/traccar/notificators/NotificatorFirebase.java
+++ b/src/main/java/org/traccar/notificators/NotificatorFirebase.java
@@ -32,7 +32,7 @@ import org.traccar.session.cache.CacheManager;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
-public class NotificatorFirebase extends Notificator {
+public class NotificatorFirebase implements Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorFirebase.class);
@@ -67,7 +67,7 @@ public class NotificatorFirebase extends Notificator {
}
@Override
- public void sendSync(User user, Event event, Position position) {
+ public void send(User user, Event event, Position position) {
if (user.getAttributes().containsKey("notificationTokens")) {
NotificationMessage shortMessage = NotificationFormatter.formatMessage(
@@ -97,9 +97,4 @@ public class NotificatorFirebase extends Notificator {
}
}
- @Override
- public void sendAsync(User user, Event event, Position position) {
- sendSync(user, event, position);
- }
-
}
diff --git a/src/main/java/org/traccar/notificators/NotificatorMail.java b/src/main/java/org/traccar/notificators/NotificatorMail.java
index 7b85254be..fd7cae7c3 100644
--- a/src/main/java/org/traccar/notificators/NotificatorMail.java
+++ b/src/main/java/org/traccar/notificators/NotificatorMail.java
@@ -28,10 +28,10 @@ import org.traccar.session.cache.CacheManager;
import javax.mail.MessagingException;
-public final class NotificatorMail extends Notificator {
+public final class NotificatorMail implements Notificator {
@Override
- public void sendSync(User user, Event event, Position position) throws MessageException {
+ public void send(User user, Event event, Position position) throws MessageException {
try {
NotificationMessage fullMessage = NotificationFormatter.formatMessage(
Main.getInjector().getInstance(CacheManager.class), user, event, position, "full");
diff --git a/src/main/java/org/traccar/notificators/NotificatorNull.java b/src/main/java/org/traccar/notificators/NotificatorNull.java
index a03a6e2c9..ba9ade9c6 100644
--- a/src/main/java/org/traccar/notificators/NotificatorNull.java
+++ b/src/main/java/org/traccar/notificators/NotificatorNull.java
@@ -22,17 +22,12 @@ import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.model.User;
-public final class NotificatorNull extends Notificator {
+public class NotificatorNull implements Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorNull.class);
@Override
- public void sendAsync(User user, Event event, Position position) {
- LOGGER.warn("You are using null notificatior, please check your configuration, notification not sent");
- }
-
- @Override
- public void sendSync(User user, Event event, Position position) {
+ public void send(User user, Event event, Position position) {
LOGGER.warn("You are using null notificatior, please check your configuration, notification not sent");
}
diff --git a/src/main/java/org/traccar/notificators/NotificatorPushover.java b/src/main/java/org/traccar/notificators/NotificatorPushover.java
index ffd9b426f..70c1a6cdc 100644
--- a/src/main/java/org/traccar/notificators/NotificatorPushover.java
+++ b/src/main/java/org/traccar/notificators/NotificatorPushover.java
@@ -31,7 +31,7 @@ import org.traccar.session.cache.CacheManager;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
-public class NotificatorPushover extends Notificator {
+public class NotificatorPushover implements Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorPushover.class);
@@ -59,7 +59,7 @@ public class NotificatorPushover extends Notificator {
}
@Override
- public void sendSync(User user, Event event, Position position) {
+ public void send(User user, Event event, Position position) {
String device = "";
@@ -100,9 +100,4 @@ public class NotificatorPushover extends Notificator {
});
}
- @Override
- public void sendAsync(User user, Event event, Position position) {
- sendSync(user, event, position);
- }
-
}
diff --git a/src/main/java/org/traccar/notificators/NotificatorSms.java b/src/main/java/org/traccar/notificators/NotificatorSms.java
index ae409c558..f35b797cd 100644
--- a/src/main/java/org/traccar/notificators/NotificatorSms.java
+++ b/src/main/java/org/traccar/notificators/NotificatorSms.java
@@ -27,27 +27,15 @@ import org.traccar.notification.NotificationFormatter;
import org.traccar.notification.NotificationMessage;
import org.traccar.session.cache.CacheManager;
-public final class NotificatorSms extends Notificator {
+public final class NotificatorSms implements Notificator {
@Override
- public void sendAsync(User user, Event event, Position position) {
+ public void send(User user, Event event, Position position) throws MessageException, InterruptedException {
if (user.getPhone() != null) {
NotificationMessage shortMessage = NotificationFormatter.formatMessage(
Main.getInjector().getInstance(CacheManager.class), user, event, position, "short");
Main.getInjector().getInstance(StatisticsManager.class).registerSms();
- Context.getSmsManager().sendMessageAsync(user.getPhone(),
- shortMessage.getBody(), false);
- }
- }
-
- @Override
- public void sendSync(User user, Event event, Position position) throws MessageException, InterruptedException {
- if (user.getPhone() != null) {
- NotificationMessage shortMessage = NotificationFormatter.formatMessage(
- Main.getInjector().getInstance(CacheManager.class), user, event, position, "short");
- Main.getInjector().getInstance(StatisticsManager.class).registerSms();
- Context.getSmsManager().sendMessageSync(user.getPhone(),
- shortMessage.getBody(), false);
+ Context.getSmsManager().sendMessage(user.getPhone(), shortMessage.getBody(), false);
}
}
diff --git a/src/main/java/org/traccar/notificators/NotificatorTelegram.java b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
index 46e29559d..0ed53ac4c 100644
--- a/src/main/java/org/traccar/notificators/NotificatorTelegram.java
+++ b/src/main/java/org/traccar/notificators/NotificatorTelegram.java
@@ -32,7 +32,7 @@ import org.traccar.session.cache.CacheManager;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
-public class NotificatorTelegram extends Notificator {
+public class NotificatorTelegram implements Notificator {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorTelegram.class);
@@ -99,7 +99,7 @@ public class NotificatorTelegram extends Notificator {
}
@Override
- public void sendSync(User user, Event event, Position position) {
+ public void send(User user, Event event, Position position) {
NotificationMessage shortMessage = NotificationFormatter.formatMessage(
Main.getInjector().getInstance(CacheManager.class), user, event, position, "short");
@@ -115,9 +115,4 @@ public class NotificatorTelegram extends Notificator {
}
}
- @Override
- public void sendAsync(User user, Event event, Position position) {
- sendSync(user, event, position);
- }
-
}
diff --git a/src/main/java/org/traccar/notificators/NotificatorWeb.java b/src/main/java/org/traccar/notificators/NotificatorWeb.java
index c9ab93b6d..023cb04af 100644
--- a/src/main/java/org/traccar/notificators/NotificatorWeb.java
+++ b/src/main/java/org/traccar/notificators/NotificatorWeb.java
@@ -21,10 +21,10 @@ import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.model.User;
-public final class NotificatorWeb extends Notificator {
+public final class NotificatorWeb implements Notificator {
@Override
- public void sendSync(User user, Event event, Position position) {
+ public void send(User user, Event event, Position position) {
Context.getConnectionManager().updateEvent(user.getId(), event);
}