.flatMap(ListNotification<Post>::elements)
.filter { postVisibilityFilter.isPostVisible(currentSone, it) }
- fun newReplies(): Collection<PostReply> =
+ fun newReplies(currentSone: Sone? = null): Collection<PostReply> =
listOf(newReplyNotification, localReplyNotification)
.flatMap(ListNotification<PostReply>::elements)
- .filter { replyVisibilityFilter.isReplyVisible(null, it) }
+ .filter { replyVisibilityFilter.isReplyVisible(currentSone, it) }
}
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.notify.ListNotification
import net.pterodactylus.sone.notify.PostVisibilityFilter
+import net.pterodactylus.sone.notify.ReplyVisibilityFilter
import net.pterodactylus.sone.notify.matchThisPost
import net.pterodactylus.sone.notify.matchThisReply
import net.pterodactylus.sone.notify.showAllPosts
assertThat(newElements.newPosts(localSone), contains(post2))
}
+ @Test
+ fun `new replies are filtered using the given Sone`() {
+ val replyVisibilityFilter = object : ReplyVisibilityFilter {
+ override fun isReplyVisible(sone: Sone?, reply: PostReply) = (sone == localSone) && (reply == reply2)
+ }
+ val newElements = NewElements(newPostNotification, newReplyNotification, localPostNotification, localReplyNotification, showAllPosts, replyVisibilityFilter)
+ assertThat(newElements.newReplies(localSone), contains(reply2))
+ }
+
}
private val post1 = createPost()