aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-09-18 16:47:32 +0300
committerGravatar Vitaly Takmazov2019-09-18 16:47:32 +0300
commit7ca0d89a7207994a8d03c8e38c1aef96fcda23ff (patch)
tree48bcf8e41b7e4707dbfbf189b8fadd3a83a350fa /src
parent3626c982d7444ad4606f0a7723538614ddfb5c77 (diff)
Send events to service email
Diffstat (limited to 'src')
-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);
}