aboutsummaryrefslogtreecommitdiff
path: root/juick-crosspost/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-01-05 11:05:43 +0300
committerGravatar Vitaly Takmazov2017-01-05 11:05:43 +0300
commiteb440ea4f120115613880e340b010eed5397e72c (patch)
tree33b2a97493575af3133f00ba66473c61bad625ba /juick-crosspost/src
parent7bab164a420b8d575f9690715af8f213c2a32efe (diff)
juick-crosspost: get full message from database
Diffstat (limited to 'juick-crosspost/src')
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/Crosspost.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
index 7cf4ad3e..769fb892 100644
--- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
+++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
@@ -19,6 +19,7 @@ package com.juick.components;
import com.juick.Tag;
import com.juick.service.CrosspostService;
+import com.juick.service.MessagesService;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.CharEncoding;
@@ -39,6 +40,7 @@ import rocks.xmpp.extensions.component.accept.ExternalComponent;
import javax.annotation.PostConstruct;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
+import javax.inject.Inject;
import javax.net.ssl.HttpsURLConnection;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
@@ -66,6 +68,8 @@ public class Crosspost implements AutoCloseable {
private final String crosspostJid;
private final String password;
private final int port;
+ @Inject
+ MessagesService messagesService;
public Crosspost(final Environment env, final CrosspostService crosspostService) {
Assert.notNull(env);
@@ -98,7 +102,7 @@ public class Crosspost implements AutoCloseable {
xmpp = ExternalComponent.create(crosspostJid, password, configuration, "localhost", port);
xmpp.addInboundMessageListener(e -> {
Message msg = e.getMessage();
- com.juick.Message jmsg = msg.getExtension(com.juick.Message.class);
+ com.juick.Message jmsg = messagesService.getMessage(msg.getExtension(com.juick.Message.class).getMid());
if (msg.getTo() != null && msg.getTo().getLocal() != null && jmsg != null && jmsg.getRid() == 0) {
if (msg.getTo().getLocal().equals("twitter")) {
twitterPost(jmsg);