aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/notificators
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-10 07:06:43 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-10 07:06:43 -0700
commitc03b4a2ace925e6a0d7c43ce59e14ddb9cbf18a9 (patch)
tree148e1946041f4dad429cb4575b8ebfba7a3a4d85 /src/main/java/org/traccar/notificators
parent336d6c4353fd77ad268aaf5cfe9c0296edfb0201 (diff)
downloadtrackermap-server-c03b4a2ace925e6a0d7c43ce59e14ddb9cbf18a9.tar.gz
trackermap-server-c03b4a2ace925e6a0d7c43ce59e14ddb9cbf18a9.tar.bz2
trackermap-server-c03b4a2ace925e6a0d7c43ce59e14ddb9cbf18a9.zip
Inject mail manager
Diffstat (limited to 'src/main/java/org/traccar/notificators')
-rw-r--r--src/main/java/org/traccar/notificators/NotificatorMail.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/notificators/NotificatorMail.java b/src/main/java/org/traccar/notificators/NotificatorMail.java
index fd7cae7c3..fe8d69af2 100644
--- a/src/main/java/org/traccar/notificators/NotificatorMail.java
+++ b/src/main/java/org/traccar/notificators/NotificatorMail.java
@@ -16,8 +16,7 @@
*/
package org.traccar.notificators;
-import org.traccar.Context;
-import org.traccar.Main;
+import org.traccar.database.MailManager;
import org.traccar.model.Event;
import org.traccar.model.Position;
import org.traccar.model.User;
@@ -26,16 +25,26 @@ import org.traccar.notification.MessageException;
import org.traccar.notification.NotificationFormatter;
import org.traccar.session.cache.CacheManager;
+import javax.inject.Inject;
import javax.mail.MessagingException;
-public final class NotificatorMail implements Notificator {
+public class NotificatorMail implements Notificator {
+
+ private final MailManager mailManager;
+ private final CacheManager cacheManager;
+
+ @Inject
+ public NotificatorMail(MailManager mailManager, CacheManager cacheManager) {
+ this.mailManager = mailManager;
+ this.cacheManager = cacheManager;
+ }
@Override
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");
- Context.getMailManager().sendMessage(user, fullMessage.getSubject(), fullMessage.getBody());
+ cacheManager, user, event, position, "full");
+ mailManager.sendMessage(user, fullMessage.getSubject(), fullMessage.getBody());
} catch (MessagingException e) {
throw new MessageException(e);
}