diff options
author | Vitaly Takmazov | 2022-03-03 15:15:39 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2022-03-03 15:15:39 +0300 |
commit | c5d03ea70ce732e0eabc7ea90b13b8ab95601c07 (patch) | |
tree | 394417ff54f2067d0e9882e80275d3fbc597a959 /src/main/java/com/juick/CommandsManager.java | |
parent | 5f06a38b6c2a6641900f79c051c1885a935ff9c3 (diff) |
Fix *readonly tag
Diffstat (limited to 'src/main/java/com/juick/CommandsManager.java')
-rw-r--r-- | src/main/java/com/juick/CommandsManager.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/com/juick/CommandsManager.java b/src/main/java/com/juick/CommandsManager.java index 6ad19bee..0c16fbbd 100644 --- a/src/main/java/com/juick/CommandsManager.java +++ b/src/main/java/com/juick/CommandsManager.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -50,6 +51,7 @@ import com.juick.service.component.PingEvent; import com.juick.service.component.SystemEvent; import com.juick.util.HttpUtils; import com.juick.util.MessageUtils; +import com.juick.util.TagUtils; import com.juick.util.annotation.UserCommand; import com.juick.util.formatters.PlainTextFormatter; import com.juick.www.WebApp; @@ -122,7 +124,7 @@ public class CommandsManager { return commandResult; } } - Pair<String, List<Tag>> tags = tagService.fromString(input); + Pair<String, Set<Tag>> tags = tagService.fromString(input); if (tags.getRight().size() > 5) { return CommandResult.fromString("Sorry, 5 tags maximum."); } @@ -539,9 +541,11 @@ public class CommandsManager { return CommandResult.fromString("Reply not found"); } } - Pair<String, List<Tag>> messageTags = tagService.fromString(txt); + Pair<String, Set<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())) { + var updatedTags = tagService.updateTags(mid, messageTags.getRight()); + if (!CollectionUtils.isEqualCollection(updatedTags, msg.get().getTags())) { + messagesService.setReadOnly(msg.get().getMid(), TagUtils.hasTag(updatedTags, "readonly")); return CommandResult.fromString("Tags are updated"); } else { return CommandResult.fromString("Tags are NOT updated (5 tags maximum?)"); |