X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FAbstractSoneCommand.java;h=3698b05afed6675a1d700ed559ada3d4e05fd336;hb=4f1c79caddd4f38e9639f054f7a8800c2a5627b3;hp=d71ffc4481125a6327909a0b4199d4b841023dbe;hpb=6f019de1d4d9742981d851ac3c9097cca8bff58e;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java index d71ffc4..3698b05 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractSoneCommand.java - Copyright © 2011–2013 David Roden + * Sone - AbstractSoneCommand.java - Copyright © 2011–2016 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Profile.Field; -import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder; import net.pterodactylus.sone.freenet.fcp.AbstractCommand; @@ -33,12 +32,11 @@ import net.pterodactylus.sone.freenet.fcp.Command; import net.pterodactylus.sone.freenet.fcp.FcpException; import net.pterodactylus.sone.template.SoneAccessor; -import com.google.common.base.Optional; -import com.google.common.collect.Collections2; - import freenet.node.FSParseException; import freenet.support.SimpleFieldSet; +import com.google.common.base.Optional; + /** * Abstract base implementation of a {@link Command} with Sone-related helper * methods. @@ -114,7 +112,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"); } /** @@ -337,9 +335,6 @@ public abstract class AbstractSoneCommand extends AbstractCommand { for (Post post : posts) { String postPrefix = prefix + postIndex++; postBuilder.put(encodePost(post, postPrefix + ".", includeReplies)); - if (includeReplies) { - postBuilder.put(encodeReplies(Collections2.filter(core.getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER), postPrefix + ".")); - } } return postBuilder.get(); @@ -355,7 +350,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand { * {@code null}) * @return The simple field set containing the replies */ - protected static SimpleFieldSet encodeReplies(Collection replies, String prefix) { + protected SimpleFieldSet encodeReplies(Collection replies, String prefix) { SimpleFieldSetBuilder replyBuilder = new SimpleFieldSetBuilder(); int replyIndex = 0; @@ -366,6 +361,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();