aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/controllers')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/NewMessage.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
index 6d7de920..a252bb69 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
@@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.stanza.model.Message;
+import rocks.xmpp.extensions.component.accept.ExternalComponent;
import rocks.xmpp.extensions.nick.model.Nickname;
import rocks.xmpp.extensions.oob.model.x.OobX;
@@ -69,6 +70,8 @@ public class NewMessage {
private PMQueriesService pmQueriesService;
@Inject
private WebApp webApp;
+ @Inject
+ private ExternalComponent xmpp;
@Value("${img_path:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
private String imgDir;
@Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
@@ -147,18 +150,18 @@ public class NewMessage {
logger.warn("invalid uri: {} exception {}", attachmentURL, e);
}
}
- if (webApp.getXmpp() != null) {
+ if (xmpp.isConnected()) {
xmsg.setBody("@" + jmsg.getUser().getName() + ":" + MessageUtils.getTagsString(jmsg) + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid);
xmsg.setTo(Jid.of("juick@s2s.juick.com"));
- webApp.getXmpp().send(xmsg);
+ xmpp.send(xmsg);
xmsg.setTo(Jid.of("juick@ws.juick.com"));
- webApp.getXmpp().send(xmsg);
+ xmpp.send(xmsg);
xmsg.setTo(Jid.of("jubo@nologin.ru"));
- webApp.getXmpp().send(xmsg);
+ xmpp.send(xmsg);
} else {
logger.warn("XMPP unavailable");
}
@@ -275,16 +278,16 @@ public class NewMessage {
}
}
- if (webApp.getXmpp() != null) {
+ if (xmpp.isConnected()) {
xmsg.setBody("Reply by @" + jmsg.getUser().getName() + ":\n>" + quote + "\n" + body + "\n\n#" +
mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew);
xmsg.setTo(Jid.of("juick@s2s.juick.com"));
- webApp.getXmpp().send(xmsg);
+ xmpp.send(xmsg);
xmsg.setTo(Jid.of("juick@ws.juick.com"));
- webApp.getXmpp().send(xmsg);
+ xmpp.send(xmsg);
} else {
logger.warn("XMPP unavailable");
}
@@ -310,7 +313,7 @@ public class NewMessage {
boolean res = messagesService.recommendMessage(mid, visitor.getUid());
if (res) {
- if (webApp.getXmpp() != null) {
+ if (xmpp.isConnected()) {
Message xmsg = new Message();
xmsg.setFrom(Jid.of("juick@juick.com"));
xmsg.setTo(Jid.of("recomm@s2s.juick.com"));
@@ -318,7 +321,7 @@ public class NewMessage {
jmsg.setMid(mid);
jmsg.setUser(visitor);
xmsg.addExtension(jmsg);
- webApp.getXmpp().send(xmsg);
+ xmpp.send(xmsg);
} else {
logger.warn("XMPP unavailable");
}
@@ -353,7 +356,7 @@ public class NewMessage {
}
if (pmQueriesService.createPM(visitor.getUid(), userTo.getUid(), body)) {
- if (webApp.getXmpp() != null) {
+ if (xmpp.isConnected()) {
Message msg = new Message();
msg.setFrom(Jid.of("juick@juick.com"));
com.juick.Message jmsg = new com.juick.Message();
@@ -362,7 +365,7 @@ public class NewMessage {
jmsg.setTo(userTo);
msg.addExtension(jmsg);
msg.setTo(Jid.of(String.format("%d@ws.juick.com", userTo.getUid())));
- webApp.getXmpp().send(msg);
+ xmpp.send(msg);
List<String> jids = userService.getJIDsbyUID(userTo.getUid());
for (String jid : jids) {
@@ -376,7 +379,7 @@ public class NewMessage {
mm.setFrom(Jid.of("juick", "juick.com", "Juick"));
mm.setBody("Private message from @" + jmsg.getUser().getName() + ":\n" + body);
}
- webApp.getXmpp().send(mm);
+ xmpp.send(mm);
}
} else {
logger.warn("XMPP unavailable");
@@ -419,7 +422,7 @@ public class NewMessage {
String attachmentUrl = String.format("juick://%s", attachmentFName);
msg.addExtension(new OobX(new URI(attachmentUrl), "!!!!Juick!!"));
}
- webApp.getXmpp().sendMessage(msg);
+ xmpp.sendMessage(msg);
} catch (URISyntaxException e1) {
logger.warn("attachment error", e1);
}