aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/NewMessage.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-31 02:02:32 +0300
committerGravatar Vitaly Takmazov2016-07-31 02:02:32 +0300
commit2b4b08c7954f5ae03681401b613318cfbfde1c76 (patch)
treea33493d7ee948d2aa0d24abc53234a128fc768ab /juick-www/src/main/java/com/juick/www/NewMessage.java
parent27bb19646fe4046628e9a21e63a425c1f7a8f15f (diff)
www: do not throw on xmpp errors
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/NewMessage.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java81
1 files changed, 47 insertions, 34 deletions
diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java
index d64fce78..8efec54c 100644
--- a/juick-www/src/main/java/com/juick/www/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/NewMessage.java
@@ -228,31 +228,35 @@ public class NewMessage {
xoob.URL = attachmentURL;
xmsg.addChild(xoob);
}
+ if (xmpp.isLoggedIn()) {
- String tagsStr2 = "";
- for (String tag : tagsArr) {
- tagsStr2 += " *" + tag;
- }
- xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid;
+ String tagsStr2 = "";
+ for (String tag : tagsArr) {
+ tagsStr2 += " *" + tag;
+ }
+ xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid;
- xmsg.to = new JID("juick", "s2s.juick.com", null);
- xmpp.send(xmsg);
+ xmsg.to = new JID("juick", "s2s.juick.com", null);
+ xmpp.send(xmsg);
- xmsg.to.Host = "ws.juick.com";
- xmpp.send(xmsg);
+ xmsg.to.Host = "ws.juick.com";
+ xmpp.send(xmsg);
- xmsg.to.Host = "push.juick.com";
- xmpp.send(xmsg);
+ xmsg.to.Host = "push.juick.com";
+ xmpp.send(xmsg);
- xmsg.to.Host = "crosspost.juick.com";
- xmsg.to.Username = "twitter";
- xmpp.send(xmsg);
- xmsg.to.Username = "fb";
- xmpp.send(xmsg);
+ xmsg.to.Host = "crosspost.juick.com";
+ xmsg.to.Username = "twitter";
+ xmpp.send(xmsg);
+ xmsg.to.Username = "fb";
+ xmpp.send(xmsg);
- xmsg.to.Host = "nologin.ru";
- xmsg.to.Username = "jubo";
- xmpp.send(xmsg);
+ xmsg.to.Host = "nologin.ru";
+ xmsg.to.Username = "jubo";
+ xmpp.send(xmsg);
+ } else {
+ logger.log(Level.WARNING, "XMPP unavailable");
+ }
//
@@ -395,16 +399,21 @@ public class NewMessage {
xmsg.addChild(xoob);
}
- xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew;
+ if (xmpp.isLoggedIn()) {
- xmsg.to = new JID("juick", "s2s.juick.com", null);
- xmpp.send(xmsg);
+ xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew;
- xmsg.to.Host = "ws.juick.com";
- xmpp.send(xmsg);
+ xmsg.to = new JID("juick", "s2s.juick.com", null);
+ xmpp.send(xmsg);
- xmsg.to.Host = "push.juick.com";
- xmpp.send(xmsg);
+ xmsg.to.Host = "ws.juick.com";
+ xmpp.send(xmsg);
+
+ xmsg.to.Host = "push.juick.com";
+ xmpp.send(xmsg);
+ } else {
+ logger.log(Level.WARNING, "XMPP unavailable");
+ }
Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getUName() + "/" + mid + "#" + ridnew);
}
@@ -428,14 +437,18 @@ public class NewMessage {
boolean res = MessagesQueries.recommendMessage(sql, mid, visitor.getUID());
if (res) {
- Message xmsg = new Message();
- xmsg.from = new JID("juick", "juick.com", null);
- xmsg.to = new JID("recomm", "s2s.juick.com", null);
- JuickMessage jmsg = new JuickMessage();
- jmsg.setMID(mid);
- jmsg.setUser(new JuickUser(visitor));
- xmsg.addChild(jmsg);
- xmpp.send(xmsg);
+ if (xmpp.isLoggedIn()) {
+ Message xmsg = new Message();
+ xmsg.from = new JID("juick", "juick.com", null);
+ xmsg.to = new JID("recomm", "s2s.juick.com", null);
+ JuickMessage jmsg = new JuickMessage();
+ jmsg.setMID(mid);
+ jmsg.setUser(new JuickUser(visitor));
+ xmsg.addChild(jmsg);
+ xmpp.send(xmsg);
+ } else {
+ logger.log(Level.WARNING, "XMPP unavailable");
+ }
Utils.replyJSON(request, response, "{\"status\":\"ok\"}");
} else {