aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/http/www/NewMessage.java66
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 22d743b38..4d4ffde69 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);
}