aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'juick-common/src/main/java/com/juick')
-rw-r--r--juick-common/src/main/java/com/juick/server/CommandsManager.java14
1 files changed, 11 insertions, 3 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 5927ed3a..82d293fe 100644
--- a/juick-common/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java
@@ -32,6 +32,7 @@ import com.juick.server.util.HttpUtils;
import com.juick.server.util.ImageUtils;
import com.juick.server.util.TagUtils;
import com.juick.service.*;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
@@ -100,6 +101,9 @@ public class CommandsManager {
}
// new message
List<Tag> tags = tagService.fromString(input, false);
+ if (tags.size() >= 5) {
+ return CommandResult.fromString("Sorry, 5 tags maximum.");
+ }
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);
@@ -471,13 +475,17 @@ 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);
List<Tag> messageTags = tagService.fromString(txt, true);
if (messageTags.size() > 0) {
- if (user.getUid() != messagesService.getMessageAuthor(mid).getUid()) {
+ if (user.getUid() != msg.getUser().getUid()) {
return CommandResult.fromString("It is not your message");
}
- tagService.updateTags(mid, messageTags);
- return CommandResult.fromString("Tags are updated");
+ if (!CollectionUtils.isEqualCollection(tagService.updateTags(mid, messageTags), msg.getTags())) {
+ return CommandResult.fromString("Tags are updated");
+ } else {
+ return CommandResult.fromString("Tags are NOT updated (5 tags maximum?)");
+ }
} else {
String attachmentStr = attachment.toString();
String attachmentType = StringUtils.isNotEmpty(attachmentStr) ? attachmentStr.substring(attachmentStr.length() - 3) : null;