From 9ec026f7cf42facbfdb6ad0330533ae2e1de24cd Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 10 May 2018 16:49:30 +0300 Subject: CommandsManager: respond OTR error for OTR messages --- juick-common/src/main/java/com/juick/server/CommandsManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 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 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); -- cgit v1.2.3