aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/XMPPConnection.java')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java15
1 files changed, 15 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 fdbb5fe6..f405e384 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -119,6 +119,10 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
private ExecutorService service;
@Inject
private ApplicationEventPublisher applicationEventPublisher;
+ @Value("${service_user:juick}")
+ private String serviceUsername;
+
+ private User serviceUser;
@PostConstruct
public void init() {
@@ -267,6 +271,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
logger.warn("xmpp exception", e);
}
});
+ serviceUser = userService.getUserByName(serviceUsername);
}
private String stanzaToString(Stanza stanza) throws XMLStreamException, JAXBException {
@@ -474,6 +479,16 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
}
+ @Override
+ public void processTopEvent(TopEvent topEvent) {
+ com.juick.Message message = topEvent.getMessage();
+ try {
+ commandsManager.processCommand(serviceUser, String.format("! #%d", message.getMid()), URI.create(StringUtils.EMPTY));
+ } catch (Exception e) {
+ logger.warn("XMPP error", e);
+ }
+ }
+
private void incomingPresence(Presence p) {
final String username = p.getTo().getLocal();
final boolean toJuick = username.equals(jid.getLocal());