X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotificationFilters.java;h=bc27173dc56c78f54ce69f2bdd9ca2b400c8f91a;hb=91b5acd80fbb818e8b51c20c43660401aad35d3f;hp=207f4cc135c73dd64a104a551c433857244a2e61;hpb=d138151b18222c458eba19528a2a2a9f07ca5a9e;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java
index 207f4cc..bc27173 100644
--- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java
+++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java
@@ -182,6 +182,7 @@ public class ListNotificationFilters {
* Sone.
*
The given Sone has not explicitely assigned negative trust to the
* postâs Sone but the implicit trust is negative.
+ * The postâs {@link Post#getTime() time} is in the future.
*
* If none of these statements is true the post is considered visible.
*
@@ -212,6 +213,50 @@ public class ListNotificationFilters {
if ((!postSone.equals(sone)) && !sone.hasFriend(postSone.getId()) && !sone.equals(post.getRecipient())) {
return false;
}
+ if (post.getTime() > System.currentTimeMillis()) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Checks whether a reply is visible to the given Sone. A reply is not
+ * considered visible if one of the following statements is true:
+ *
+ * - The reply does not have a post.
+ * - The replyâs post does not have a Sone.
+ * - The Sone of the replyâs post is not the given Sone, the given Sone
+ * does not follow the replyâs postâs Sone, and the given Sone is not the
+ * recipient of the replyâs post.
+ * - The trust relationship between the two Sones can not be retrieved.
+ * - The given Sone has explicitely assigned negative trust to the postâs
+ * Sone.
+ * - The given Sone has not explicitely assigned negative trust to the
+ * replyâs postâs Sone but the implicit trust is negative.
+ * - The replyâs postâs {@link Post#getTime() time} is in the future.
+ * - The replyâs {@link Reply#getTime() time} is in the future.
+ *
+ * If none of these statements is true the reply is considered visible.
+ *
+ * @param sone
+ * The Sone that checks for a postâs visibility
+ * @param reply
+ * The reply to check for visibility
+ * @return {@code true} if the reply is considered visible, {@code false}
+ * otherwise
+ */
+ public static boolean isReplyVisible(Sone sone, Reply reply) {
+ Validation.begin().isNotNull("Sone", sone).isNotNull("Reply", reply).check().isNotNull("Soneâs Identity", sone.getIdentity()).check().isInstanceOf("Soneâs Identity", sone.getIdentity(), OwnIdentity.class).check();
+ Post post = reply.getPost();
+ if (post == null) {
+ return false;
+ }
+ if (!isPostVisible(sone, post)) {
+ return false;
+ }
+ if (reply.getTime() > System.currentTimeMillis()) {
+ return false;
+ }
return true;
}