mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-19 16:51:08 +02:00
Fixes showing blog posts in the future
This commit is contained in:
@@ -132,7 +132,18 @@ class LongTextNoteEvent(
|
||||
|
||||
fun summary() = tags.firstNotNullOfOrNull(SummaryTag::parse)
|
||||
|
||||
override fun publishedAt() = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
override fun publishedAt(): Long? {
|
||||
val publishedAt = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
|
||||
if (publishedAt == null) return null
|
||||
|
||||
// removes posts in the future.
|
||||
return if (publishedAt <= createdAt) {
|
||||
publishedAt
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KIND = 30023
|
||||
|
@@ -46,6 +46,8 @@ import com.vitorpamplona.quartz.nip19Bech32.eventHints
|
||||
import com.vitorpamplona.quartz.nip19Bech32.eventIds
|
||||
import com.vitorpamplona.quartz.nip19Bech32.pubKeyHints
|
||||
import com.vitorpamplona.quartz.nip19Bech32.pubKeys
|
||||
import com.vitorpamplona.quartz.nip23LongContent.tags.PublishedAtTag
|
||||
import com.vitorpamplona.quartz.nip23LongContent.tags.PublishedAtTag.Companion.parse
|
||||
import com.vitorpamplona.quartz.nip31Alts.AltTag
|
||||
import com.vitorpamplona.quartz.nip50Search.SearchableEvent
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
@@ -129,12 +131,18 @@ class WikiNoteEvent(
|
||||
|
||||
fun image() = tags.firstOrNull { it.size > 1 && it[0] == "image" }?.get(1)
|
||||
|
||||
override fun publishedAt() =
|
||||
try {
|
||||
tags.firstOrNull { it.size > 1 && it[0] == "published_at" }?.get(1)?.toLongOrNull()
|
||||
} catch (_: Exception) {
|
||||
override fun publishedAt(): Long? {
|
||||
val publishedAt = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
|
||||
if (publishedAt == null) return null
|
||||
|
||||
// removes posts in the future.
|
||||
return if (publishedAt <= createdAt) {
|
||||
publishedAt
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KIND = 30818
|
||||
|
@@ -53,7 +53,18 @@ abstract class ReplaceableVideoEvent(
|
||||
|
||||
override fun title() = tags.firstNotNullOfOrNull(TitleTag::parse)
|
||||
|
||||
override fun publishedAt() = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
override fun publishedAt(): Long? {
|
||||
val publishedAt = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
|
||||
if (publishedAt == null) return null
|
||||
|
||||
// removes posts in the future.
|
||||
return if (publishedAt <= createdAt) {
|
||||
publishedAt
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun duration() = tags.firstNotNullOfOrNull(DurationTag::parse)
|
||||
|
||||
|
@@ -79,7 +79,18 @@ class AppDefinitionEvent(
|
||||
|
||||
fun includeKind(kind: Int) = tags.isTaggedKind(kind)
|
||||
|
||||
override fun publishedAt() = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
override fun publishedAt(): Long? {
|
||||
val publishedAt = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
|
||||
if (publishedAt == null) return null
|
||||
|
||||
// removes posts in the future.
|
||||
return if (publishedAt <= createdAt) {
|
||||
publishedAt
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KIND = 31990
|
||||
|
@@ -70,7 +70,18 @@ class ClassifiedsEvent(
|
||||
|
||||
fun location() = tags.firstNotNullOfOrNull(LocationTag::parse)
|
||||
|
||||
override fun publishedAt() = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
override fun publishedAt(): Long? {
|
||||
val publishedAt = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||
|
||||
if (publishedAt == null) return null
|
||||
|
||||
// removes posts in the future.
|
||||
return if (publishedAt <= createdAt) {
|
||||
publishedAt
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun categories() = tags.hashtags()
|
||||
|
||||
|
Reference in New Issue
Block a user