- List<Notification> notifications = new ArrayList<Notification>(webInterface.getNotifications().getChangedNotifications());
- Set<Notification> removedNotifications = webInterface.getNotifications().getRemovedNotifications();
- Collections.sort(notifications, Notification.LAST_UPDATED_TIME_SORTER);
- JsonArray jsonNotifications = new JsonArray();
- for (Notification notification : notifications) {
- jsonNotifications.add(createJsonNotification(notification));
+ List<Notification> notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone);
+ Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
+ /* load new posts. */
+ Collection<Post> newPosts = webInterface.getNewPosts();
+ if (currentSone != null) {
+ newPosts = Collections2.filter(newPosts, new Predicate<Post>() {
+
+ @Override
+ public boolean apply(Post post) {
+ return ListNotificationFilters.isPostVisible(currentSone, post);
+ }
+
+ });
+ }
+ JsonArray jsonPosts = new JsonArray();
+ for (Post post : newPosts) {
+ JsonObject jsonPost = new JsonObject();
+ jsonPost.put("id", post.getId());
+ jsonPost.put("sone", post.getSone().getId());
+ jsonPost.put("recipient", (post.getRecipient() != null) ? post.getRecipient().getId() : null);
+ jsonPost.put("time", post.getTime());
+ jsonPosts.add(jsonPost);
+ }
+ /* load new replies. */
+ Collection<PostReply> newReplies = webInterface.getNewReplies();
+ if (currentSone != null) {
+ newReplies = Collections2.filter(newReplies, new Predicate<PostReply>() {
+
+ @Override
+ public boolean apply(PostReply reply) {
+ return ListNotificationFilters.isReplyVisible(currentSone, reply);
+ }
+
+ });