diff options
author | 2018-11-28 14:58:45 +0300 | |
---|---|---|
committer | 2018-11-28 14:58:45 +0300 | |
commit | 7b97f3df5a5c31c5d85ee71c902fa9bf979ffc54 (patch) | |
tree | d52c9ee2bf5066b84f348a1f4aeb27cbcf5e0678 /src/main/java/com | |
parent | 0fea66317d608cb0f67bb92695a40d100d504c8d (diff) |
Fix EditOrReply command flow
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/juick/server/CommandsManager.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/com/juick/server/CommandsManager.java b/src/main/java/com/juick/server/CommandsManager.java index 2eb58188..3257304b 100644 --- a/src/main/java/com/juick/server/CommandsManager.java +++ b/src/main/java/com/juick/server/CommandsManager.java @@ -498,13 +498,19 @@ public class CommandsManager { int mid = NumberUtils.toInt(args[1]); int rid = NumberUtils.toInt(args[4], 0); String txt = StringUtils.defaultString(args[5]); - Message msg = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new); - Pair<String, List<Tag>> messageTags = tagService.fromString(txt); - if (messageTags.getRight().size() > 0) { - if (user.getUid() != msg.getUser().getUid()) { - return CommandResult.fromString("It is not your message"); + Optional<Message> msg = messagesService.getMessage(mid); + if (!msg.isPresent()) { + return CommandResult.fromString("Message not found"); + } + if (rid > 0) { + Message reply = messagesService.getReply(mid, rid); + if (reply == null) { + return CommandResult.fromString("Reply not found"); } - if (!CollectionUtils.isEqualCollection(tagService.updateTags(mid, messageTags.getRight()), msg.getTags())) { + } + Pair<String, List<Tag>> messageTags = tagService.fromString(txt); + if (user.getUid() == msg.get().getUser().getUid() && rid == 0 && messageTags.getRight().size() > 0) { + if (!CollectionUtils.isEqualCollection(tagService.updateTags(mid, messageTags.getRight()), msg.get().getTags())) { return CommandResult.fromString("Tags are updated"); } else { return CommandResult.fromString("Tags are NOT updated (5 tags maximum?)"); @@ -527,7 +533,7 @@ public class CommandsManager { imagesService.saveImageWithPreviews(attachmentFName, fname); } applicationEventPublisher.publishEvent( - new MessageReadEvent(this, user, msg)); + new MessageReadEvent(this, user, msg.get())); Message original = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new); subscriptionService.subscribeMessage(original, user); Message reply = messagesService.getReply(mid, newrid); |