- protected void postProcess(Request request, DataProvider dataProvider) {
- Sone sone = (Sone) dataProvider.get("sone");
- List<Post> posts = sone.getPosts();
- for (Post post : posts) {
- webInterface.getCore().markPostKnown(post);
- for (Reply reply : webInterface.getCore().getReplies(post)) {
- webInterface.getCore().markReplyKnown(reply);
+ protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
+ super.processTemplate(request, templateContext);
+ String soneId = request.getHttpRequest().getParam("sone");
+ Optional<Sone> sone = webInterface.getCore().getSone(soneId);
+ templateContext.set("sone", sone.orNull());
+ templateContext.set("soneId", soneId);
+ if (!sone.isPresent()) {
+ return;
+ }
+ List<Post> sonePosts = sone.get().getPosts();
+ sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.get().getId()));
+ Collections.sort(sonePosts, Post.TIME_COMPARATOR);
+ Pagination<Post> postPagination = new Pagination<Post>(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("postPage"), 0));
+ templateContext.set("postPagination", postPagination);
+ templateContext.set("posts", postPagination.getItems());
+ Set<PostReply> replies = sone.get().getReplies();
+ final Map<Post, List<PostReply>> repliedPosts = new HashMap<Post, List<PostReply>>();
+ for (PostReply reply : replies) {
+ Optional<Post> post = reply.getPost();
+ if (!post.isPresent() || repliedPosts.containsKey(post.get()) || sone.get().equals(post.get().getSone()) || (sone.get().getId().equals(post.get().getRecipientId().orNull()))) {
+ continue;