+ /* load new posts. */
+ Set<Post> newPosts = webInterface.getNewPosts();
+ if (currentSone != null) {
+ newPosts = Filters.filteredSet(newPosts, new Filter<Post>() {
+
+ @Override
+ public boolean filterObject(Post post) {
+ return currentSone.hasFriend(post.getSone().getId()) || currentSone.equals(post.getSone()) || currentSone.equals(post.getRecipient());
+ }
+
+ });
+ }
+ 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. */
+ Set<Reply> newReplies = webInterface.getNewReplies();
+ if (currentSone != null) {
+ newReplies = Filters.filteredSet(newReplies, new Filter<Reply>() {
+
+ @Override
+ public boolean filterObject(Reply reply) {
+ return currentSone.hasFriend(reply.getPost().getSone().getId()) || currentSone.equals(reply.getPost().getSone()) || currentSone.equals(reply.getPost().getRecipient());
+ }
+
+ });
+ }
+ JsonArray jsonReplies = new JsonArray();
+ for (Reply reply : newReplies) {
+ JsonObject jsonReply = new JsonObject();
+ jsonReply.put("id", reply.getId());
+ jsonReply.put("sone", reply.getSone().getId());
+ jsonReply.put("post", reply.getPost().getId());
+ jsonReply.put("postSone", reply.getPost().getSone().getId());
+ jsonReplies.add(jsonReply);