Add unit test for get post feed command, add likes to replies
[Sone.git] / src / main / java / net / pterodactylus / sone / fcp / AbstractSoneCommand.java
index b2264a5..33e9233 100644 (file)
@@ -114,7 +114,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
         * @return The encoded text
         */
        protected static String encodeString(String text) {
-               return text.replaceAll("\\\\", "\\\\").replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r");
+               return text.replaceAll("\\\\", "\\\\\\\\").replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r");
        }
 
        /**
@@ -355,7 +355,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
         *            {@code null})
         * @return The simple field set containing the replies
         */
-       protected static SimpleFieldSet encodeReplies(Collection<? extends PostReply> replies, String prefix) {
+       protected SimpleFieldSet encodeReplies(Collection<? extends PostReply> replies, String prefix) {
                SimpleFieldSetBuilder replyBuilder = new SimpleFieldSetBuilder();
 
                int replyIndex = 0;
@@ -366,6 +366,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
                        replyBuilder.put(replyPrefix + "Sone", reply.getSone().getId());
                        replyBuilder.put(replyPrefix + "Time", reply.getTime());
                        replyBuilder.put(replyPrefix + "Text", encodeString(reply.getText()));
+                       replyBuilder.put(encodeLikes(core.getLikes(reply), replyPrefix + "Likes."));
                }
 
                return replyBuilder.get();