aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPBot.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-27 05:23:00 +0300
committerGravatar Vitaly Takmazov2018-03-27 05:45:37 +0300
commit7bd9d90ce7716a4224442967a6e06f023a2b66a2 (patch)
tree21255cc8cd2a9071b02c86496953bc381fbaa279 /juick-server/src/main/java/com/juick/server/XMPPBot.java
parent83dae6eb77c1e9e720c726af47451bcfea2bd14e (diff)
server: event handling refactoring
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/XMPPBot.java')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPBot.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPBot.java b/juick-server/src/main/java/com/juick/server/XMPPBot.java
index 41c98856..c304473c 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPBot.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPBot.java
@@ -37,6 +37,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Scope;
+import org.springframework.context.annotation.ScopedProxyMode;
+import org.springframework.context.event.EventListener;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.stanza.model.*;
@@ -58,6 +62,7 @@ import java.util.stream.Collectors;
* @author ugnich
*/
@Component
+@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public class XMPPBot implements StanzaListener, AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(XMPPBot.class);
@@ -334,7 +339,10 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
return true;
}
- public void processMessage(com.juick.Message msg) {
+ @EventListener
+ @Async
+ public void processMessageEvent(MessageEvent event) {
+ com.juick.Message msg = event.getMessage();
if (msg.getRid() == 0 && msg.getMid() > 0) {
String notify = "New message posted.\n#" + msg.getMid() + " https://juick.com/" + msg.getMid();
userService.getJIDsbyUID(msg.getUser().getUid())