Marks which events can receive Comment replies as root scopes.

This commit is contained in:
Vitor Pamplona 2024-11-19 18:01:56 -05:00
parent 03662b9d1b
commit b3e3b70dd0
6 changed files with 12 additions and 5 deletions

View File

@ -70,6 +70,7 @@ import com.vitorpamplona.quartz.events.FileStorageHeaderEvent
import com.vitorpamplona.quartz.events.GitIssueEvent
import com.vitorpamplona.quartz.events.Price
import com.vitorpamplona.quartz.events.PrivateDmEvent
import com.vitorpamplona.quartz.events.RootScope
import com.vitorpamplona.quartz.events.TextNoteEvent
import com.vitorpamplona.quartz.events.TorrentCommentEvent
import com.vitorpamplona.quartz.events.TorrentEvent
@ -555,7 +556,7 @@ open class NewPostViewModel : ViewModel() {
val replyingTo = originalNote
if (replyingTo?.event is CommentEvent || replyingTo?.event is Event) {
if (replyingTo?.event is CommentEvent || (replyingTo?.event is Event && replyingTo.event is RootScope)) {
account?.sendReplyComment(
message = tagger.message,
replyingTo = replyingTo,

View File

@ -39,7 +39,8 @@ class CommentEvent(
tags: Array<Array<String>>,
content: String,
sig: HexKey,
) : BaseTextNoteEvent(id, pubKey, createdAt, KIND, tags, content, sig) {
) : BaseTextNoteEvent(id, pubKey, createdAt, KIND, tags, content, sig),
RootScope {
fun root() = tags.firstOrNull { it.size > 3 && it[3] == "root" }?.get(1)
fun getRootScopes() = tags.filter { it.size > 1 && it[0] == "I" || it[0] == "A" || it[0] == "E" }

View File

@ -588,3 +588,5 @@ data class ZapSplitSetup(
val weight: Double,
val isLnAddress: Boolean,
)
interface RootScope

View File

@ -38,7 +38,8 @@ class PictureEvent(
tags: Array<Array<String>>,
content: String,
sig: HexKey,
) : Event(id, pubKey, createdAt, KIND, tags, content, sig) {
) : Event(id, pubKey, createdAt, KIND, tags, content, sig),
RootScope {
fun mimeTypes() = tags.filter { it.size > 1 && it[0] == MIME_TYPE }
fun hashes() = tags.filter { it.size > 1 && it[0] == HASH }

View File

@ -34,7 +34,8 @@ abstract class VideoEvent(
tags: Array<Array<String>>,
content: String,
sig: HexKey,
) : BaseAddressableEvent(id, pubKey, createdAt, kind, tags, content, sig) {
) : BaseAddressableEvent(id, pubKey, createdAt, kind, tags, content, sig),
RootScope {
fun url() = tags.firstOrNull { it.size > 1 && it[0] == URL }?.get(1)
fun urls() = tags.filter { it.size > 1 && it[0] == URL }.map { it[1] }

View File

@ -34,7 +34,8 @@ class VideoVerticalEvent(
tags: Array<Array<String>>,
content: String,
sig: HexKey,
) : VideoEvent(id, pubKey, createdAt, KIND, tags, content, sig) {
) : VideoEvent(id, pubKey, createdAt, KIND, tags, content, sig),
RootScope {
companion object {
const val KIND = 34236
const val ALT_DESCRIPTION = "Vertical Video"