Merge branch 'release-0.4.3'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ViewPostPage.java
index 9bc28fa..864dc84 100644 (file)
@@ -18,7 +18,9 @@
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.util.template.Template;
+import net.pterodactylus.util.template.TemplateContext;
 
 /**
  * This page lets the user view a post and all its replies.
@@ -47,11 +49,26 @@ public class ViewPostPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, Template template) throws RedirectException {
-               super.processTemplate(request, template);
+       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+               super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getParam("post");
                Post post = webInterface.getCore().getPost(postId);
-               template.set("post", post);
+               templateContext.set("post", post);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected void postProcess(Request request, TemplateContext templateContext) {
+               Post post = (Post) templateContext.get("post");
+               if (post == null) {
+                       return;
+               }
+               webInterface.getCore().markPostKnown(post);
+               for (Reply reply : webInterface.getCore().getReplies(post)) {
+                       webInterface.getCore().markReplyKnown(reply);
+               }
        }
 
 }