diff options
author | 2018-01-30 16:39:20 +0300 | |
---|---|---|
committer | 2018-01-30 16:39:20 +0300 | |
commit | bbd3faa0ff2f65aa852e0995d8fa3a46d17b485f (patch) | |
tree | e181e6b13c7c1490a2ed4e3e661089faa778d8d2 /juick-xmpp/src/main/java | |
parent | 7f2ae26dbe83875f733219357c11aad78e580e0e (diff) |
xmpp: serialize PM
Diffstat (limited to 'juick-xmpp/src/main/java')
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/JuickBot.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java index 42a5f8a6..2b1c7ac9 100644 --- a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java +++ b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java @@ -348,24 +348,17 @@ public class JuickBot implements StanzaListener, AutoCloseable { } @UserCommand(pattern = "^\\@(\\S+)\\s+([\\s\\S]+)$", help = "@username message - send PM to username") public String commandPM(User user_from, Jid from, String... arguments) { - String user_to = arguments[0]; String body = arguments[1]; int ret = 0; - int uid_to = 0; + User user_to = userService.getUserByName(arguments[0]); List<String> jids_to = null; boolean haveInRoster = false; - if (user_to.indexOf('@') > 0) { - uid_to = userService.getUIDbyJID(user_to); - } else { - uid_to = userService.getUIDbyName(user_to); - } - - if (uid_to > 0) { - if (!userService.isInBLAny(uid_to, user_from.getUid())) { - if (pmQueriesService.createPM(user_from.getUid(), uid_to, body)) { - jids_to = userService.getJIDsbyUID(uid_to); + if (user_to.getUid() > 0) { + if (!userService.isInBLAny(user_to.getUid(), user_from.getUid())) { + if (pmQueriesService.createPM(user_from.getUid(), user_to.getUid(), body)) { + jids_to = userService.getJIDsbyUID(user_to.getUid()); ret = 200; } else { ret = 500; @@ -380,14 +373,15 @@ public class JuickBot implements StanzaListener, AutoCloseable { if (ret == 200) { Message msg = new Message(); msg.setFrom(jid.asBareJid()); - msg.setTo(Jid.of(Integer.toString(uid_to), "push.juick.com", null)); + msg.setTo(Jid.of(Integer.toString(user_to.getUid()), "push.juick.com", null)); com.juick.Message jmsg = new com.juick.Message(); jmsg.setUser(user_from); + jmsg.setTo(user_to); jmsg.setText(body); msg.addExtension(jmsg); router.sendStanza(msg); - msg.setTo(Jid.of(Integer.toString(uid_to), "ws.juick.com", null)); + msg.setTo(Jid.of(Integer.toString(user_to.getUid()), "ws.juick.com", null)); router.sendStanza(msg); for (String userJid : jids_to) { |