diff options
author | Vitaly Takmazov | 2016-06-05 10:33:54 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-06-05 10:33:54 +0300 |
commit | e31024bb7cef19c2a783b5f728a8c0cfe6a9925a (patch) | |
tree | 70b875b89ada6286477f06feb83ac7a7b9aa2bbb /src/main | |
parent | 3b0567e6e98411be4b2f55d06d557be831738089 (diff) |
add nick to xmpp reply notification
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java b/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java index 48d2efd5..2a1fed5d 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java @@ -166,13 +166,17 @@ public class ConnectionRouter extends Connection implements Runnable { public void sendJuickComment(JuickMessage jmsg) throws Exception { List<String> jids; String replyQuote; + String replyTo; synchronized (XMPPComponent.sqlSync) { jids = SubscriptionsQueries.getJIDSubscribedToComments(XMPPComponent.sql, jmsg.getMID(), jmsg.getUser().getUID()); - replyQuote = getReplyQuote(XMPPComponent.sql, jmsg.getMID(), jmsg.ReplyTo); + com.juick.Message replyMessage = jmsg.ReplyTo > 0 ? MessagesQueries.getReply(XMPPComponent.sql, jmsg.getMID(), jmsg.ReplyTo) + : MessagesQueries.getMessage(XMPPComponent.sql, jmsg.getMID()); + replyTo = replyMessage.getUser().getUName(); + replyQuote = getReplyQuote(replyMessage); } - String txt = "Reply by @" + jmsg.getUser().getUName() + ":\n" + replyQuote + "\n"; + String txt = "Reply by @" + jmsg.getUser().getUName() + ":\n" + replyQuote + "\n@" + replyTo + " "; String attachment = jmsg.getAttachmentURL(); if (attachment != null) { txt += attachment + "\n"; @@ -190,19 +194,8 @@ public class ConnectionRouter extends Connection implements Runnable { } } - private String getReplyQuote(java.sql.Connection sql, int MID, int ReplyTo) { - String quote = ""; - if (ReplyTo > 0) { - com.juick.Message q = MessagesQueries.getReply(sql, MID, ReplyTo); - if (q != null) { - quote = q.getText(); - } - } else { - com.juick.Message q = MessagesQueries.getMessage(sql, MID); - if (q != null) { - quote = q.getText(); - } - } + private String getReplyQuote(com.juick.Message q) { + String quote = q.getText(); if (quote.length() > 50) { quote = ">" + quote.substring(0, 47).replace('\n', ' ') + "...\n"; } else if (quote.length() > 0) { |