X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FReplyGroupFilter.java;h=bcf73d8ab97371b881479b36bf533e0b2481cb18;hp=4806ceec25dcebb89c149b0a8ef9ffd88941a6e0;hb=9e8b1de83b5791778788406edbba9ed6d256a63f;hpb=cf16e1fef9f9db74f50fb1d12dbc48a552ec2a1a diff --git a/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java b/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java index 4806cee..bcf73d8 100644 --- a/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java @@ -29,6 +29,8 @@ import net.pterodactylus.sone.data.Sone; import net.pterodactylus.util.template.Filter; import net.pterodactylus.util.template.TemplateContext; +import com.google.common.base.Optional; + /** * {@link Filter} implementation that groups replies by the post the are in * reply to, returning a map with the post as key and the list of replies as @@ -48,17 +50,21 @@ public class ReplyGroupFilter implements Filter { Map> postSones = new HashMap>(); Map> postReplies = new HashMap>(); for (PostReply reply : allReplies) { - Post post = reply.getPost(); - Set sones = postSones.get(post); + /* + * All replies from a new-reply notification have posts, + * ListNotificationFilters takes care of that. + */ + Optional post = reply.getPost(); + Set sones = postSones.get(post.get()); if (sones == null) { sones = new HashSet(); - postSones.put(post, sones); + postSones.put(post.get(), sones); } sones.add(reply.getSone()); - Set replies = postReplies.get(post); + Set replies = postReplies.get(post.get()); if (replies == null) { replies = new HashSet(); - postReplies.put(post, replies); + postReplies.put(post.get(), replies); } replies.add(reply); }