Filter posts and replies from the future.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / SearchPage.java
index 2b854f3..cf79b4d 100644 (file)
@@ -86,7 +86,7 @@ public class SearchPage extends SoneTemplatePage {
                        posts.addAll(sone.getPosts());
                }
                @SuppressWarnings("synthetic-access")
-               Set<Hit<Post>> postHits = getHits(posts, phrases, new PostStringGenerator());
+               Set<Hit<Post>> postHits = getHits(Filters.filteredSet(posts, Post.FUTURE_POSTS_FILTER), phrases, new PostStringGenerator());
 
                /* now filter. */
                soneHits = Filters.filteredSet(soneHits, Hit.POSITIVE_FILTER);
@@ -110,6 +110,17 @@ public class SearchPage extends SoneTemplatePage {
                templateContext.set("soneHits", sonePagination.getItems());
                templateContext.set("postPagination", postPagination);
                templateContext.set("postHits", postPagination.getItems());
+
+               /* mark found posts and Sones as knew. */
+               for (Sone sone : sonePagination.getItems()) {
+                       webInterface.getCore().markSoneKnown(sone);
+               }
+               for (Post post : postPagination.getItems()) {
+                       webInterface.getCore().markPostKnown(post);
+                       for (Reply reply : webInterface.getCore().getReplies(post)) {
+                               webInterface.getCore().markReplyKnown(reply);
+                       }
+               }
        }
 
        //
@@ -318,7 +329,7 @@ public class SearchPage extends SoneTemplatePage {
                        if (post.getRecipient() != null) {
                                postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(post.getRecipient()));
                        }
-                       for (Reply reply : webInterface.getCore().getReplies(post)) {
+                       for (Reply reply : Filters.filteredList(webInterface.getCore().getReplies(post), Reply.FUTURE_REPLIES_FILTER)) {
                                postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(reply.getSone()));
                                postString.append(' ').append(reply.getText());
                        }