Store the “known” status of a post in the database.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / DefaultPost.java
index fa21e7a..a560185 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.sone.data.impl;
 import static com.google.common.collect.FluentIterable.from;
 
 import java.util.List;
+import java.util.Set;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.PostReply;
@@ -54,9 +55,6 @@ public class DefaultPost implements Post {
        /** The text of the post. */
        private final String text;
 
-       /** Whether the post is known. */
-       private volatile boolean known;
-
        /**
         * Creates a new post.
         *
@@ -118,12 +116,12 @@ public class DefaultPost implements Post {
 
        @Override
        public boolean isKnown() {
-               return known;
+               return database.isPostKnown(this);
        }
 
        @Override
-       public DefaultPost setKnown(boolean known) {
-               this.known = known;
+       public DefaultPost setKnown() {
+               database.setPostKnown(this);
                return this;
        }
 
@@ -138,6 +136,16 @@ public class DefaultPost implements Post {
        }
 
        @Override
+       public boolean isLiked(Sone sone) {
+               return database.isLiked(this, sone);
+       }
+
+       @Override
+       public Set<Sone> getLikes() {
+               return database.getLikes(this);
+       }
+
+       @Override
        public List<PostReply> getReplies() {
                return from(database.getReplies(getId())).toSortedList(Reply.TIME_COMPARATOR);
        }