aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
index 03720a3f..d50c4400 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -18,6 +18,8 @@
package com.juick.server;
import com.juick.User;
+import com.juick.server.component.LikeEvent;
+import com.juick.server.component.MessageEvent;
import com.juick.server.xmpp.s2s.BasicXmppSession;
import com.juick.server.helpers.UserInfo;
import com.juick.service.MessagesService;
@@ -31,6 +33,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.XmppException;
@@ -103,6 +106,8 @@ public class XMPPConnection implements AutoCloseable {
private BasicXmppSession session;
@Inject
private ExecutorService service;
+ @Inject
+ private ApplicationEventPublisher applicationEventPublisher;
@PostConstruct
public void init() {
@@ -158,6 +163,8 @@ public class XMPPConnection implements AutoCloseable {
if (jmsg != null) {
if (jid.getLocal().equals("recomm")) {
sendJuickRecommendation(jmsg);
+ User fromUser = userService.getUserByJID(message.getFrom().asBareJid().toEscapedString());
+ applicationEventPublisher.publishEvent(new LikeEvent(this, fromUser, jmsg));
} else {
if (jmsg.getRid() > 0) {
// to get quote and attachment
@@ -166,6 +173,7 @@ public class XMPPConnection implements AutoCloseable {
} else if (jmsg.getMid() > 0) {
sendJuickMessage(jmsg);
}
+ applicationEventPublisher.publishEvent(new MessageEvent(this, jmsg));
}
}
} else if (jid.getDomain().endsWith(bot.getJid().getDomain()) && (jid.getDomain().equals(bot.getJid().getDomain())