X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FGetPostFeedCommand.java;h=781bed248785a89e8460f5df977499d0f77f10c4;hb=0acd68634f3e73c62087609c1faa2dfc53da506d;hp=2dc59a1b3ab9247d371c9db8b552689befc2a51d;hpb=a50303a787867cdc2449da8846e1e365b771e109;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java index 2dc59a1..781bed2 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetPostFeedCommand.java - Copyright © 2011 David Roden + * Sone - GetPostFeedCommand.java - Copyright © 2011–2012 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 @@ -27,7 +27,7 @@ import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.freenet.fcp.FcpException; -import net.pterodactylus.util.filter.Filters; +import net.pterodactylus.util.collection.filter.Filters; import freenet.support.SimpleFieldSet; import freenet.support.api.Bucket; @@ -53,8 +53,8 @@ public class GetPostFeedCommand extends AbstractSoneCommand { * {@inheritDoc} */ @Override - public Reply execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException { - Sone sone = getSone(parameters, "Sone"); + public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException { + Sone sone = getSone(parameters, "Sone", true); int startPost = getInt(parameters, "StartPost", 0); int maxPosts = getInt(parameters, "MaxPosts", -1); @@ -64,7 +64,7 @@ public class GetPostFeedCommand extends AbstractSoneCommand { if (!getCore().hasSone(friendSoneId)) { continue; } - allPosts.addAll(getCore().getSone(friendSoneId).getPosts()); + allPosts.addAll(getCore().getSone(friendSoneId, false).getPosts()); } allPosts.addAll(getCore().getDirectedPosts(sone)); allPosts = Filters.filteredSet(allPosts, Post.FUTURE_POSTS_FILTER); @@ -73,10 +73,10 @@ public class GetPostFeedCommand extends AbstractSoneCommand { Collections.sort(sortedPosts, Post.TIME_COMPARATOR); if (sortedPosts.size() < startPost) { - return new Reply(encodePosts(Collections. emptyList())); + return new Response("PostFeed", encodePosts(Collections. emptyList(), "Posts.", false)); } - return new Reply(encodePosts(sortedPosts.subList(startPost, (maxPosts == -1) ? sortedPosts.size() : Math.min(startPost + maxPosts, sortedPosts.size())))); + return new Response("PostFeed", encodePosts(sortedPosts.subList(startPost, (maxPosts == -1) ? sortedPosts.size() : Math.min(startPost + maxPosts, sortedPosts.size())), "Posts.", true)); } }