Filter out shadowbanned comments
authorLanius Trolling <lanius@laniustrolling.dev>
Tue, 14 Mar 2023 19:01:51 +0000 (15:01 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Tue, 14 Mar 2023 19:01:51 +0000 (15:01 -0400)
src/main/kotlin/info/mechyrdia/data/views_comment.kt

index 896e96fed54cd65dbc9aeaa7531dd90c72c22172..97536a7bc0ca7bcd23befa791bf735d93ba7bb61 100644 (file)
@@ -9,11 +9,11 @@ import info.mechyrdia.lore.*
 import io.ktor.http.*
 import io.ktor.server.application.*
 import io.ktor.server.util.*
+import kotlinx.coroutines.flow.filterNot
 import kotlinx.coroutines.flow.take
 import kotlinx.coroutines.flow.toList
 import kotlinx.html.*
 import org.litote.kmongo.descending
-import java.lang.NullPointerException
 import java.time.Instant
 
 suspend fun ApplicationCall.recentCommentsPage(): HTML.() -> Unit {
@@ -34,6 +34,9 @@ suspend fun ApplicationCall.recentCommentsPage(): HTML.() -> Unit {
        val comments = CommentRenderData(
                Comment.Table
                        .sorted(descending(Comment::submittedAt))
+                       .filterNot { comment ->
+                               NationData.get(comment.submittedBy).isBanned
+                       }
                        .take(limit)
                        .toList(),
                nationCache