X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotificationFilters.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotificationFilters.java;h=3db8912779cc570907468a118a4ac00155f3da64;hp=52f85ba61659fb4732289e3536635a05480eaa91;hb=012439f891860c345b6bcab68e663bdd93c9aeb5;hpb=67e70ae26d1b8dc644013cddb85e90c7944bafe0 diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java index 52f85ba..3db8912 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java @@ -55,7 +55,7 @@ public class ListNotificationFilters { List filteredNotifications = new ArrayList(); for (Notification notification : notifications) { if (notification.getId().equals("new-post-notification")) { - ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, currentSone); + ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, currentSone, true); if (filteredNotification != null) { filteredNotifications.add(filteredNotification); } @@ -65,7 +65,7 @@ public class ListNotificationFilters { filteredNotifications.add(filteredNotification); } } else if (notification.getId().equals("mention-notification")) { - ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, null); + ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, null, false); if (filteredNotification != null) { filteredNotifications.add(filteredNotification); } @@ -78,19 +78,23 @@ public class ListNotificationFilters { /** * Filters the new posts of the given notification. If {@code currentSone} - * is {@code null}, {@code null} is returned and the notification is - * subsequently removed. Otherwise only posts that are posted by friend - * Sones of the given Sone are retained; all other posts are removed. + * is {@code null} and {@code soneRequired} is {@code true}, {@code null} is + * returned and the notification is subsequently removed. Otherwise only + * posts that are posted by friend Sones of the given Sone are retained; all + * other posts are removed. * * @param newPostNotification * The new-post notification * @param currentSone * The current Sone, or {@code null} if not logged in + * @param soneRequired + * Whether a non-{@code null} Sone in {@code currentSone} is + * required * @return The filtered new-post notification, or {@code null} if the * notification should be removed */ - public static ListNotification filterNewPostNotification(ListNotification newPostNotification, Sone currentSone) { - if (currentSone == null) { + public static ListNotification filterNewPostNotification(ListNotification newPostNotification, Sone currentSone, boolean soneRequired) { + if (soneRequired && (currentSone == null)) { return null; } List newPosts = new ArrayList();