aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-05-10 16:49:30 +0300
committerGravatar Vitaly Takmazov2018-05-10 16:49:30 +0300
commit9ec026f7cf42facbfdb6ad0330533ae2e1de24cd (patch)
tree0d18010a93b2e77585f8c41a9027318ab7384ccd /juick-common/src/main/java
parentf2715b10d4f0c2d9fe69b12b96a385e4b845b1d5 (diff)
CommandsManager: respond OTR error for OTR messages
Diffstat (limited to 'juick-common/src/main/java')
-rw-r--r--juick-common/src/main/java/com/juick/server/CommandsManager.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/juick-common/src/main/java/com/juick/server/CommandsManager.java b/juick-common/src/main/java/com/juick/server/CommandsManager.java
index d3be371f..6b759bed 100644
--- a/juick-common/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java
@@ -77,6 +77,9 @@ public class CommandsManager {
public CommandResult processCommand(User user, String data, @Nonnull URI attachment) throws Exception {
String strippedData = StringUtils.stripStart(data, null);
+ if (strippedData.startsWith("?OTR")) {
+ return CommandResult.fromString("?OTR Error: we are not using OTR");
+ }
String input = MessageUtils.stripNonSafeUrls(strippedData);
Optional<Method> cmd = MethodUtils.getMethodsListWithAnnotation(getClass(), UserCommand.class).stream()
.filter(m -> Pattern.compile(m.getAnnotation(UserCommand.class).pattern(),
@@ -97,11 +100,11 @@ public class CommandsManager {
return commandResult;
}
}
- // new message
List<Tag> tags = tagService.fromString(input, false);
if (tags.size() >= 5) {
return CommandResult.fromString("Sorry, 5 tags maximum.");
}
+ // new message
String body = TagUtils.toString(tags).equals(input) ? StringUtils.EMPTY : input.substring(TagUtils.toString(tags).length()).trim();
String attachmentType = StringUtils.isNotEmpty(attachment.toString()) ? attachment.toString().substring(attachment.toString().length() - 3) : null;
int mid = messagesService.createMessage(user.getUid(), body, attachmentType, tags);