From eb440ea4f120115613880e340b010eed5397e72c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 5 Jan 2017 11:05:43 +0300 Subject: juick-crosspost: get full message from database --- juick-crosspost/src/main/java/com/juick/components/Crosspost.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'juick-crosspost/src/main/java/com/juick') 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); -- cgit v1.2.3