diff options
author | Vitaly Takmazov | 2016-02-02 14:59:26 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-02-02 14:59:26 +0300 |
commit | 6d60b86bfddb51c13c118de8e8ad2db59f1fe74f (patch) | |
tree | 92de9a9bf11769706abafd83a777e6d0a9c6e9e0 /src/main/java/com/juick/http | |
parent | 25503dbbd5e286c967bea75a7c0d6963a81b5877 (diff) |
log xmpp problems
Diffstat (limited to 'src/main/java/com/juick/http')
-rw-r--r-- | src/main/java/com/juick/http/www/NewMessage.java | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/src/main/java/com/juick/http/www/NewMessage.java b/src/main/java/com/juick/http/www/NewMessage.java index 22d743b3..4d4ffde6 100644 --- a/src/main/java/com/juick/http/www/NewMessage.java +++ b/src/main/java/com/juick/http/www/NewMessage.java @@ -40,6 +40,7 @@ import java.net.URLEncoder; import java.sql.Connection; import java.util.ArrayList; import java.util.List; +import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -50,6 +51,8 @@ import javax.servlet.http.HttpServletResponse; */ public class NewMessage { + private static final Logger logger = Logger.getLogger(NewMessage.class.getName()); + protected void doGetNewMessage(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); @@ -211,33 +214,34 @@ public class NewMessage { xoob.URL = attachmentURL; xmsg.addChild(xoob); } + if (xmpp != null) { + 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.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 = "crosspost.juick.com"; - xmsg.to.Username = "twitter"; - xmpp.send(xmsg); - xmsg.to.Username = "fb"; - xmpp.send(xmsg); + xmsg.to.Host = "push.juick.com"; + xmpp.send(xmsg); - xmsg.to.Host = "nologin.ru"; - xmsg.to.Username = "jubo"; - 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); + } else { + logger.warning("XMPP is not available, users will not be notified"); + } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { @@ -371,16 +375,20 @@ 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 != null) { + xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; - 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); + } else { + logger.warning("XMPP is not available, users will not be notified"); + } Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getUName() + "/" + mid + "#" + ridnew); } |