X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fnotify%2FListNotificationFilters.java;h=3db8912779cc570907468a118a4ac00155f3da64;hb=012439f891860c345b6bcab68e663bdd93c9aeb5;hp=908ea2be50f054644d077c5d5d612583978eeb13;hpb=a2c1ff645a1c1369f75e145932637721538d3794;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 908ea2b..3db8912 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java @@ -54,8 +54,8 @@ public class ListNotificationFilters { public static List filterNotifications(Collection notifications, Sone currentSone) { List filteredNotifications = new ArrayList(); for (Notification notification : notifications) { - if (notification.getId().equals("new-post-notification") || notification.getId().equals("mention-notification")) { - ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, currentSone); + if (notification.getId().equals("new-post-notification")) { + ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, currentSone, true); if (filteredNotification != null) { filteredNotifications.add(filteredNotification); } @@ -64,6 +64,11 @@ public class ListNotificationFilters { if (filteredNotification != null) { filteredNotifications.add(filteredNotification); } + } else if (notification.getId().equals("mention-notification")) { + ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, null, false); + if (filteredNotification != null) { + filteredNotifications.add(filteredNotification); + } } else { filteredNotifications.add(notification); } @@ -73,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();