mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 14:01:22 +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)
|
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 {
|
companion object {
|
||||||
const val KIND = 30023
|
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.eventIds
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.pubKeyHints
|
import com.vitorpamplona.quartz.nip19Bech32.pubKeyHints
|
||||||
import com.vitorpamplona.quartz.nip19Bech32.pubKeys
|
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.nip31Alts.AltTag
|
||||||
import com.vitorpamplona.quartz.nip50Search.SearchableEvent
|
import com.vitorpamplona.quartz.nip50Search.SearchableEvent
|
||||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||||
@@ -129,12 +131,18 @@ class WikiNoteEvent(
|
|||||||
|
|
||||||
fun image() = tags.firstOrNull { it.size > 1 && it[0] == "image" }?.get(1)
|
fun image() = tags.firstOrNull { it.size > 1 && it[0] == "image" }?.get(1)
|
||||||
|
|
||||||
override fun publishedAt() =
|
override fun publishedAt(): Long? {
|
||||||
try {
|
val publishedAt = tags.firstNotNullOfOrNull(PublishedAtTag::parse)
|
||||||
tags.firstOrNull { it.size > 1 && it[0] == "published_at" }?.get(1)?.toLongOrNull()
|
|
||||||
} catch (_: Exception) {
|
if (publishedAt == null) return null
|
||||||
|
|
||||||
|
// removes posts in the future.
|
||||||
|
return if (publishedAt <= createdAt) {
|
||||||
|
publishedAt
|
||||||
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val KIND = 30818
|
const val KIND = 30818
|
||||||
|
@@ -53,7 +53,18 @@ abstract class ReplaceableVideoEvent(
|
|||||||
|
|
||||||
override fun title() = tags.firstNotNullOfOrNull(TitleTag::parse)
|
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)
|
override fun duration() = tags.firstNotNullOfOrNull(DurationTag::parse)
|
||||||
|
|
||||||
|
@@ -79,7 +79,18 @@ class AppDefinitionEvent(
|
|||||||
|
|
||||||
fun includeKind(kind: Int) = tags.isTaggedKind(kind)
|
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 {
|
companion object {
|
||||||
const val KIND = 31990
|
const val KIND = 31990
|
||||||
|
@@ -70,7 +70,18 @@ class ClassifiedsEvent(
|
|||||||
|
|
||||||
fun location() = tags.firstNotNullOfOrNull(LocationTag::parse)
|
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()
|
fun categories() = tags.hashtags()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user