mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-17 21:31:57 +01:00
Fixes isTagged for events
This commit is contained in:
parent
4fcf962c71
commit
bcb3838e85
@ -60,6 +60,12 @@ data class ETag(
|
||||
@JvmStatic
|
||||
fun isTagged(tag: Array<String>) = tag.size >= TAG_SIZE && tag[0] == TAG_NAME && tag[1].isNotEmpty()
|
||||
|
||||
@JvmStatic
|
||||
fun isTagged(
|
||||
tag: Array<String>,
|
||||
eventId: HexKey,
|
||||
) = tag.size >= TAG_SIZE && tag[0] == TAG_NAME && tag[1] == eventId
|
||||
|
||||
@JvmStatic
|
||||
fun parse(tag: Array<String>): ETag? {
|
||||
if (tag.size < TAG_SIZE || tag[0] != TAG_NAME) return null
|
||||
|
@ -22,6 +22,7 @@ package com.vitorpamplona.quartz.nip01Core.tags.events
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArray
|
||||
import com.vitorpamplona.quartz.nip01Core.core.any
|
||||
import com.vitorpamplona.quartz.nip01Core.core.forEachTagged
|
||||
import com.vitorpamplona.quartz.nip01Core.core.isTagged
|
||||
import com.vitorpamplona.quartz.nip01Core.core.mapValueTagged
|
||||
@ -36,4 +37,4 @@ fun TagArray.taggedEventIds() = this.mapNotNull(ETag::parseId)
|
||||
|
||||
fun TagArray.firstTaggedEvent() = this.firstNotNullOfOrNull(ETag::parse)
|
||||
|
||||
fun TagArray.isTaggedEvent(idHex: String) = this.isTagged(ETag.TAG_NAME, idHex)
|
||||
fun TagArray.isTaggedEvent(idHex: String) = this.any(ETag::isTagged, idHex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user