Only allow posts that have been downloaded.
[Sone.git] / src / main / java / net / pterodactylus / sone / notify / ListNotificationFilters.java
index 2a98ec8..f2bff09 100644 (file)
@@ -84,13 +84,13 @@ public class ListNotificationFilters {
         * @return The filtered new-post notification, or {@code null} if the
         *         notification should be removed
         */
-       private static ListNotification<Post> filterNewPostNotification(ListNotification<Post> newPostNotification, Sone currentSone) {
+       public static ListNotification<Post> filterNewPostNotification(ListNotification<Post> newPostNotification, Sone currentSone) {
                if (currentSone == null) {
                        return null;
                }
                List<Post> newPosts = new ArrayList<Post>();
                for (Post post : newPostNotification.getElements()) {
-                       if (currentSone.hasFriend(post.getSone().getId()) || currentSone.equals(post.getSone()) || currentSone.equals(post.getRecipient())) {
+                       if ((post.getSone() != null) && (currentSone.hasFriend(post.getSone().getId()) || currentSone.equals(post.getSone()) || currentSone.equals(post.getRecipient()))) {
                                newPosts.add(post);
                        }
                }
@@ -119,13 +119,13 @@ public class ListNotificationFilters {
         * @return The filtered new-reply notification, or {@code null} if the
         *         notification should be removed
         */
-       private static ListNotification<Reply> filterNewReplyNotification(ListNotification<Reply> newReplyNotification, Sone currentSone) {
+       public static ListNotification<Reply> filterNewReplyNotification(ListNotification<Reply> newReplyNotification, Sone currentSone) {
                if (currentSone == null) {
                        return null;
                }
                List<Reply> newReplies = new ArrayList<Reply>();
                for (Reply reply : newReplyNotification.getElements()) {
-                       if (currentSone.hasFriend(reply.getPost().getSone().getId()) || currentSone.equals(reply.getPost().getSone()) || currentSone.equals(reply.getPost().getRecipient())) {
+                       if (((reply.getPost().getSone() != null) && currentSone.hasFriend(reply.getPost().getSone().getId())) || currentSone.equals(reply.getPost().getSone()) || currentSone.equals(reply.getPost().getRecipient())) {
                                newReplies.add(reply);
                        }
                }