aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPConnection.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-05 01:38:04 +0300
committerGravatar Vitaly Takmazov2018-10-05 01:38:04 +0300
commitfe761771ce3cb65b00dc3a826c51b9f20ff6c72d (patch)
tree7671e1bd31dfc10f10d1110048efc313762c6dfe /juick-server/src/main/java/com/juick/server/XMPPConnection.java
parenta6824b011325df07caf284352f09c2b9f76155c7 (diff)
TopEvent: Announce in Fediverse, like in XMPP/Telegram
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());