aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/server/CommandsManager.java20
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);