mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-21 18:40:38 +02:00
Adds a normalized parser to all nip65 relays
This commit is contained in:
@@ -41,6 +41,8 @@ class AdvertisedRelayListEvent(
|
||||
) : BaseReplaceableEvent(id, pubKey, createdAt, KIND, tags, content, sig) {
|
||||
fun relays() = tags.mapNotNull(AdvertisedRelayInfo::parse)
|
||||
|
||||
fun relaysNorm() = tags.mapNotNull(AdvertisedRelayInfo::parseNorm)
|
||||
|
||||
fun readRelays() = tags.mapNotNull(AdvertisedRelayInfo::parseRead).ifEmpty { null }
|
||||
|
||||
fun readRelaysNorm() = tags.mapNotNull(AdvertisedRelayInfo::parseReadNorm).ifEmpty { null }
|
||||
|
@@ -58,6 +58,13 @@ class AdvertisedRelayInfo(
|
||||
return AdvertisedRelayInfo(normalizedUrl, type)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun parseNorm(tag: Array<String>): NormalizedRelayUrl? {
|
||||
ensure(match(tag)) { return null }
|
||||
val normalizedUrl = RelayUrlNormalizer.normalizeOrNull(tag[1])
|
||||
return normalizedUrl
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun parseRead(tag: Array<String>): String? {
|
||||
ensure(match(tag)) { return null }
|
||||
|
Reference in New Issue
Block a user