import java.util.Collections;
import java.util.List;
+import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.notify.ListNotificationFilters;
import net.pterodactylus.util.notify.Notification;
import net.pterodactylus.util.notify.NotificationManager;
-import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
+import net.pterodactylus.util.template.TemplateContext;
/**
* Adds additional properties to a {@link NotificationManager}.
* {@inheritDoc}
*/
@Override
- public Object get(DataProvider dataProvider, Object object, String member) {
+ public Object get(TemplateContext templateContext, Object object, String member) {
NotificationManager notificationManager = (NotificationManager) object;
if ("all".equals(member)) {
- List<Notification> notifications = new ArrayList<Notification>(notificationManager.getNotifications());
+ List<Notification> notifications = ListNotificationFilters.filterNotifications(new ArrayList<Notification>(notificationManager.getNotifications()), (Sone) templateContext.get("currentSone"));
Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
return notifications;
- } else if ("new".equals(member)) {
- List<Notification> notifications = new ArrayList<Notification>(notificationManager.getChangedNotifications());
- Collections.sort(notifications, Notification.LAST_UPDATED_TIME_SORTER);
- return notifications;
}
- return super.get(dataProvider, object, member);
+ return super.get(templateContext, object, member);
}
}