diff options
Diffstat (limited to 'server-core')
3 files changed, 27 insertions, 6 deletions
diff --git a/server-core/src/main/java/com/juick/server/TagQueries.java b/server-core/src/main/java/com/juick/server/TagQueries.java index 0e3c0c06c..ee9a1e21b 100644 --- a/server-core/src/main/java/com/juick/server/TagQueries.java +++ b/server-core/src/main/java/com/juick/server/TagQueries.java @@ -106,7 +106,7 @@ public class TagQueries { return stmt; }, holder); - return holder.getKey().intValue(); + return holder.getKey().intValue(); } public static List<com.juick.Tag> getUserTagsAll(JdbcTemplate sql, int uid) { @@ -157,8 +157,4 @@ public class TagQueries { } return Collections.emptyList(); } - public static String toString(List<Tag> tags) { - return tags.stream().map(t -> " *" + t.getName()) - .collect(Collectors.joining()); - } } diff --git a/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java b/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java index 5faddd3a4..e9e129a9c 100644 --- a/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java +++ b/server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java @@ -7,6 +7,7 @@ import com.juick.formatters.PlainTextFormatter; import com.juick.json.MessageSerializer; import com.juick.server.*; import com.juick.server.protocol.annotation.UserCommand; +import com.juick.util.TagUtils; import com.juick.xmpp.extensions.JuickMessage; import org.springframework.jdbc.core.JdbcTemplate; @@ -66,7 +67,7 @@ public class JuickProtocol { public ProtocolReply postMessage(User user, String input) { List<Tag> tags = TagQueries.fromString(sql, input, false); - String body = input.substring(TagQueries.toString(tags).length()); + String body = input.substring(TagUtils.toString(tags).length()); int mid = MessagesQueries.createMessage(sql, user.getUID(), body, null, tags); SubscriptionsQueries.subscribeMessage(sql, mid, user.getUID()); //app.events().publishEvent(new JuickMessageEvent(app.messages().getMessage(mid))); diff --git a/server-core/src/main/java/com/juick/util/TagUtils.java b/server-core/src/main/java/com/juick/util/TagUtils.java new file mode 100644 index 000000000..157522ab1 --- /dev/null +++ b/server-core/src/main/java/com/juick/util/TagUtils.java @@ -0,0 +1,24 @@ +package com.juick.util; + +import com.juick.Tag; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Created by aalexeev on 11/13/16. + */ +public class TagUtils { + private TagUtils() { + throw new IllegalStateException(); + } + + public static String toString(final List<Tag> tags) { + if (CollectionUtils.isEmpty(tags)) + return ""; + + return tags.stream().map(t -> " *" + t.getName()) + .collect(Collectors.joining()); + } +} |