Fixes isTagged for events
This commit is contained in:
@@ -60,6 +60,12 @@ data class ETag(
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isTagged(tag: Array<String>) = tag.size >= TAG_SIZE && tag[0] == TAG_NAME && tag[1].isNotEmpty()
|
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
|
@JvmStatic
|
||||||
fun parse(tag: Array<String>): ETag? {
|
fun parse(tag: Array<String>): ETag? {
|
||||||
if (tag.size < TAG_SIZE || tag[0] != TAG_NAME) return null
|
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.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.TagArray
|
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.forEachTagged
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.isTagged
|
import com.vitorpamplona.quartz.nip01Core.core.isTagged
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.mapValueTagged
|
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.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)
|
||||||
|
|||||||
Reference in New Issue
Block a user