mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-10 20:23:50 +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) {
|
) : BaseReplaceableEvent(id, pubKey, createdAt, KIND, tags, content, sig) {
|
||||||
fun relays() = tags.mapNotNull(AdvertisedRelayInfo::parse)
|
fun relays() = tags.mapNotNull(AdvertisedRelayInfo::parse)
|
||||||
|
|
||||||
|
fun relaysNorm() = tags.mapNotNull(AdvertisedRelayInfo::parseNorm)
|
||||||
|
|
||||||
fun readRelays() = tags.mapNotNull(AdvertisedRelayInfo::parseRead).ifEmpty { null }
|
fun readRelays() = tags.mapNotNull(AdvertisedRelayInfo::parseRead).ifEmpty { null }
|
||||||
|
|
||||||
fun readRelaysNorm() = tags.mapNotNull(AdvertisedRelayInfo::parseReadNorm).ifEmpty { null }
|
fun readRelaysNorm() = tags.mapNotNull(AdvertisedRelayInfo::parseReadNorm).ifEmpty { null }
|
||||||
|
@@ -58,6 +58,13 @@ class AdvertisedRelayInfo(
|
|||||||
return AdvertisedRelayInfo(normalizedUrl, type)
|
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
|
@JvmStatic
|
||||||
fun parseRead(tag: Array<String>): String? {
|
fun parseRead(tag: Array<String>): String? {
|
||||||
ensure(match(tag)) { return null }
|
ensure(match(tag)) { return null }
|
||||||
|
Reference in New Issue
Block a user