X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotificationFilters.java;h=f2bff09069db232ed3c14192bba77b1db936ae1b;hb=b1c2516dedba75c15e4b62d9c1630f1c85fa085c;hp=7da483194f661005273276b0c55d58bb68605bcb;hpb=fbd56494f4d26e59ae3872ac2276f631a81da085;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 7da4831..f2bff09 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java @@ -49,28 +49,22 @@ public class ListNotificationFilters { */ public static List filterNotifications(List notifications, Sone currentSone) { ListNotification newPostNotification = getNotification(notifications, "new-post-notification", Post.class); - System.out.println("Found new-post-notification with " + ((newPostNotification != null) ? newPostNotification.getElements().size() : -1) + " posts."); if (newPostNotification != null) { ListNotification filteredNotification = filterNewPostNotification(newPostNotification, currentSone); int notificationIndex = notifications.indexOf(newPostNotification); if (filteredNotification == null) { - System.out.println("Removing notification."); notifications.remove(notificationIndex); } else { - System.out.println("Replacing Notification."); notifications.set(notificationIndex, filteredNotification); } } ListNotification newReplyNotification = getNotification(notifications, "new-replies-notification", Reply.class); - System.out.println("Found new-reply-notification with " + ((newReplyNotification != null) ? newReplyNotification.getElements().size() : -1) + " replies."); if (newReplyNotification != null) { ListNotification filteredNotification = filterNewReplyNotification(newReplyNotification, currentSone); int notificationIndex = notifications.indexOf(newReplyNotification); if (filteredNotification == null) { - System.out.println("Removing Notification."); notifications.remove(notificationIndex); } else { - System.out.println("Replacing Notification."); notifications.set(notificationIndex, filteredNotification); } } @@ -90,16 +84,13 @@ public class ListNotificationFilters { * @return The filtered new-post notification, or {@code null} if the * notification should be removed */ - private static ListNotification filterNewPostNotification(ListNotification newPostNotification, Sone currentSone) { + public static ListNotification filterNewPostNotification(ListNotification newPostNotification, Sone currentSone) { if (currentSone == null) { return null; } List newPosts = new ArrayList(); for (Post post : newPostNotification.getElements()) { - System.out.println("Checking Post: " + post); - if (currentSone.hasFriend(post.getSone().getId()) || currentSone.equals(post.getSone())) { - System.out.println(" CS.hF: " + currentSone.hasFriend(post.getSone().getId())); - System.out.println(" CS.e:" + currentSone.equals(post.getSone())); + if ((post.getSone() != null) && (currentSone.hasFriend(post.getSone().getId()) || currentSone.equals(post.getSone()) || currentSone.equals(post.getRecipient()))) { newPosts.add(post); } } @@ -128,16 +119,13 @@ public class ListNotificationFilters { * @return The filtered new-reply notification, or {@code null} if the * notification should be removed */ - private static ListNotification filterNewReplyNotification(ListNotification newReplyNotification, Sone currentSone) { + public static ListNotification filterNewReplyNotification(ListNotification newReplyNotification, Sone currentSone) { if (currentSone == null) { return null; } List newReplies = new ArrayList(); for (Reply reply : newReplyNotification.getElements()) { - System.out.println("Checking Reply: " + reply); - if (currentSone.hasFriend(reply.getPost().getSone().getId()) || currentSone.equals(reply.getPost().getSone())) { - System.out.println(" CS.hF: " + currentSone.hasFriend(reply.getPost().getSone().getId())); - System.out.println(" CS.e: " + currentSone.equals(reply.getPost().getSone())); + if (((reply.getPost().getSone() != null) && currentSone.hasFriend(reply.getPost().getSone().getId())) || currentSone.equals(reply.getPost().getSone()) || currentSone.equals(reply.getPost().getRecipient())) { newReplies.add(reply); } }