aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/server/ServerManager.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/com/juick/server/ServerManager.java b/src/main/java/com/juick/server/ServerManager.java
index d3d17c80..a226bf29 100644
--- a/src/main/java/com/juick/server/ServerManager.java
+++ b/src/main/java/com/juick/server/ServerManager.java
@@ -16,6 +16,8 @@
*/
package com.juick.server;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.Message;
import com.juick.User;
import com.juick.model.AnonymousUser;
@@ -58,9 +60,16 @@ public class ServerManager implements NotificationListener {
@Value("${service_user:juick}")
private String serviceUsername;
+ @Value("${service_email:root@localhost}")
+ private String serviceEmail;
private User serviceUser;
+ @Inject
+ private EmailManager emailManager;
+ @Inject
+ private ObjectMapper jsonMapper;
+
@PostConstruct
public void init() {
serviceUser = userService.getUserByName(serviceUsername);
@@ -102,6 +111,11 @@ public class ServerManager implements NotificationListener {
onJuickMessageReply(jmsg, subscribedUsers);
}
messageEvent(jmsg, Collections.singletonList(serviceUser));
+ try {
+ emailManager.sendEmail("noreply@juick.com", serviceEmail, "New event", jsonMapper.writeValueAsString(event), null, Collections.emptyMap());
+ } catch (JsonProcessingException e) {
+ logger.warn("JSON exception", e);
+ }
}
@Override
@@ -147,7 +161,7 @@ public class ServerManager implements NotificationListener {
sendSseEvent(msg, "read", subscribers);
}
- public void messageEvent(Message msg, List<User> subscribers){
+ public void messageEvent(Message msg, List<User> subscribers) {
sendSseEvent(msg, "msg", subscribers);
}