aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server')
-rw-r--r--src/main/java/com/juick/server/XMPPConnection.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/main/java/com/juick/server/XMPPConnection.java b/src/main/java/com/juick/server/XMPPConnection.java
index 979ba1fd..f77b2354 100644
--- a/src/main/java/com/juick/server/XMPPConnection.java
+++ b/src/main/java/com/juick/server/XMPPConnection.java
@@ -216,7 +216,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
Jid initiator = e.getInitiator();
ClientMessage result = incomingMessageJuick(
userService.getUserByJID(initiator.asBareJid().toEscapedString()), initiator,
- e.getDescription(), URI.create(String.format("juick://%s", targetFilename)));
+ jid.getLocal(), StringUtils.defaultString(e.getDescription()).trim(), URI.create(String.format("juick://%s", targetFilename)));
if (result != null) {
router.send(result);
}
@@ -594,16 +594,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
attachment = oobX.getUri();
}
try {
- if (msg.getTo().asBareJid().equals(jid.asBareJid())) {
- return incomingMessageJuick(user_from, msg.getFrom(), StringUtils.defaultString(msg.getBody()), attachment);
- } else {
- // PM
- if (!StringUtils.isEmpty(msg.getBody())) {
- result = incomingMessageJuick(user_from, msg.getFrom(),
- String.format("@%s %s", msg.getTo().getLocal(), StringUtils.defaultString(msg.getBody())), attachment);
- }
- }
- messagesService.getUnread(user_from).forEach(mid -> messagesService.setRead(user_from, mid));
+ return incomingMessageJuick(user_from, msg.getFrom(), msg.getTo().getLocal(), StringUtils.defaultString(msg.getBody()).trim(), attachment);
} catch (Exception e1) {
logger.warn("message exception", e1);
}
@@ -621,11 +612,13 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
}
return result;
}
- private ClientMessage incomingMessageJuick(User user_from, Jid from, String command, @Nonnull URI attachment) {
+ private ClientMessage incomingMessageJuick(User user_from, Jid from, String to, String command, @Nonnull URI attachment) {
if (StringUtils.isBlank(command) && attachment.toString().isEmpty()) {
return null;
}
+ messagesService.getUnread(user_from).forEach(mid -> messagesService.setRead(user_from, mid));
+
int commandlen = command.length();
// COMPATIBILITY
@@ -633,8 +626,16 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
command = command.substring(3);
}
+ if (!jid.getLocal().equals(to)) {
+ // PM
+ if (!StringUtils.isEmpty(command)) {
+ commandsManager.commandPM(user_from, null, to, command);
+ return null;
+ }
+ }
+
try {
- CommandResult result = commandsManager.processCommand(user_from, command.trim(), attachment);
+ CommandResult result = commandsManager.processCommand(user_from, command, attachment);
if (StringUtils.isNotBlank(result.getText())) {
return makeReply(from, result.getText());
}