aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPBot.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-21 12:20:56 +0300
committerGravatar Vitaly Takmazov2018-03-21 13:52:55 +0300
commit403fab0c39e99ffd0b386eb612f3574938ae2125 (patch)
tree47b99c53134468da50c6f766ebb16043fa984cfa /juick-server/src/main/java/com/juick/server/XMPPBot.java
parentf066f48e4cabd0d7649af2e8c1f4b6a7dea56673 (diff)
add some events
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.java7
1 files changed, 7 insertions, 0 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 ac1c4121..9b6b5fe4 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPBot.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPBot.java
@@ -19,6 +19,8 @@ package com.juick.server;
import com.juick.Tag;
import com.juick.User;
+import com.juick.server.component.LikeEvent;
+import com.juick.server.component.SubscribeEvent;
import com.juick.server.xmpp.s2s.StanzaListener;
import com.juick.formatters.PlainTextFormatter;
import com.juick.server.helpers.TagStats;
@@ -31,6 +33,7 @@ import org.ocpsoft.prettytime.PrettyTime;
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.stanza.model.*;
@@ -79,6 +82,8 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
private PrivacyQueriesService privacyQueriesService;
@Inject
private SubscriptionService subscriptionService;
+ @Inject
+ private ApplicationEventPublisher applicationEventPublisher;
@PostConstruct
public void init() {
@@ -529,6 +534,7 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
MessagesService.RecommendStatus status = messagesService.recommendMessage(mid, user.getUid());
switch (status) {
case Added:
+ applicationEventPublisher.publishEvent(new LikeEvent(this, user, msg));
return "Message is added to your recommendations";
case Deleted:
return "Message deleted from your recommendations.";
@@ -546,6 +552,7 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
User toUser = userService.getUserByName(args[1]);
if (subscribe) {
if (subscriptionService.subscribeUser(user, toUser)) {
+ applicationEventPublisher.publishEvent(new SubscribeEvent(this, user, toUser));
return "Subscribed to @" + toUser.getName();
}
} else {