aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/JuickBot.java22
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) {