Minor tweaks
authorLanius Trolling <lanius@laniustrolling.dev>
Thu, 11 Jan 2024 16:06:32 +0000 (11:06 -0500)
committerLanius Trolling <lanius@laniustrolling.dev>
Thu, 11 Jan 2024 16:06:32 +0000 (11:06 -0500)
src/jvmMain/kotlin/info/mechyrdia/lore/views_rss.kt

index f2bd7004406fb52ea0f208ab092dcb7290723a06..2cd2f601d7c0bcadf30e0655a0efcefd41eaba1d 100644 (file)
@@ -3,6 +3,7 @@ package info.mechyrdia.lore
 import com.mongodb.client.model.Sorts
 import info.mechyrdia.Configuration
 import info.mechyrdia.data.*
+import io.ktor.http.*
 import io.ktor.server.application.*
 import io.ktor.util.*
 import kotlinx.coroutines.flow.filterNot
@@ -63,13 +64,7 @@ fun Appendable.generateRecentPageEdits() {
                                RssItemEnclosure(
                                        url = url,
                                        length = file.length(),
-                                       type = when {
-                                               url.endsWith(".png") -> "image/png"
-                                               url.endsWith(".gif") -> "image/gif"
-                                               url.endsWith(".jpg") || url.endsWith(".jpeg") -> "image/jpeg"
-                                               url.endsWith(".svg") -> "image/svg+xml"
-                                               else -> "application/octet-stream"
-                                       }
+                                       type = ContentType.defaultForFile(file).toString()
                                )
                        }
                        
@@ -114,7 +109,7 @@ suspend fun ApplicationCall.recentCommentsRssFeedGenerator(): Appendable.() -> U
                nationCache
        )
        
-       val mostRecentComment = comments.firstOrNull()?.submittedAt
+       val mostRecentComment = comments.firstOrNull()?.let { it.lastEdit ?: it.submittedAt }
        
        return RssChannel(
                title = "Recent Comments | The Hour of Decision",
@@ -132,7 +127,7 @@ suspend fun ApplicationCall.recentCommentsRssFeedGenerator(): Appendable.() -> U
                                description = commentToPlainText(comment.contentsRaw),
                                link = "https://mechyrdia.info/comment/view/${comment.id}",
                                author = null,
-                               comments = "https://mechyrdia.info/lore/${comment.submittedIn}#comments",
+                               comments = "https://mechyrdia.info/lore/${comment.submittedIn}#comment-${comment.id}",
                                pubDate = comment.lastEdit ?: comment.submittedAt,
                                categories = listOf(
                                        RssCategory(domain = "https://nationstates.net", category = comment.submittedBy.name)