projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Distinguish between local and “normal” Sones in FCP handler.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
fcp
/
GetPostFeedCommand.java
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
index
781bed2
..
dbaf189
100644
(file)
--- 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–201
2
David Roden
+ * Sone - GetPostFeedCommand.java - Copyright © 2011–201
3
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
*
* 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
@@
-18,16
+18,20
@@
package net.pterodactylus.sone.fcp;
import java.util.ArrayList;
package net.pterodactylus.sone.fcp;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.fcp.FcpException;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.fcp.FcpException;
-import net.pterodactylus.util.collection.filter.Filters;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Collections2;
+
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
@@
-54,20
+58,21
@@
public class GetPostFeedCommand extends AbstractSoneCommand {
*/
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
*/
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
-
Sone sone = getSone(parameters, "Sone", true
);
+
LocalSone sone = getLocalSone(parameters, "Sone", true).get(
);
int startPost = getInt(parameters, "StartPost", 0);
int maxPosts = getInt(parameters, "MaxPosts", -1);
int startPost = getInt(parameters, "StartPost", 0);
int maxPosts = getInt(parameters, "MaxPosts", -1);
-
Set
<Post> allPosts = new HashSet<Post>();
+
Collection
<Post> allPosts = new HashSet<Post>();
allPosts.addAll(sone.getPosts());
for (String friendSoneId : sone.getFriends()) {
allPosts.addAll(sone.getPosts());
for (String friendSoneId : sone.getFriends()) {
- if (!getCore().hasSone(friendSoneId)) {
+ Optional<Sone> friendSone = getCore().getSone(friendSoneId);
+ if (!friendSone.isPresent()) {
continue;
}
continue;
}
- allPosts.addAll(
getCore().getSone(friendSoneId, false
).getPosts());
+ allPosts.addAll(
friendSone.get(
).getPosts());
}
}
- allPosts.addAll(getCore().getDirectedPosts(sone));
- allPosts =
Filters.filteredSet
(allPosts, Post.FUTURE_POSTS_FILTER);
+ allPosts.addAll(getCore().getDirectedPosts(sone
.getId()
));
+ allPosts =
Collections2.filter
(allPosts, Post.FUTURE_POSTS_FILTER);
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);