Uses NIP-65 preferably for zap requests.

This commit is contained in:
Vitor Pamplona 2024-05-30 13:51:14 -04:00
parent f81c83326c
commit 4a43b57f79
2 changed files with 32 additions and 2 deletions

View File

@ -730,8 +730,10 @@ class Account(
note.event?.let { event ->
LnZapRequestEvent.create(
event,
userProfile().latestContactList?.relays()?.keys?.ifEmpty { null }
?: localRelays.map { it.url }.toSet(),
relays =
getNIP65RelayList()?.readRelays()?.toSet()
?: userProfile().latestContactList?.relays()?.keys?.ifEmpty { null }
?: localRelays.map { it.url }.toSet(),
signer,
pollOption,
message,

View File

@ -54,6 +54,34 @@ class AdvertisedRelayListEvent(
}
}
fun readRelays(): List<String>? {
return tags.mapNotNull {
if (it.size > 1 && it[0] == "r") {
when (it.getOrNull(2)) {
"read" -> it[1]
"write" -> null
else -> it[1]
}
} else {
null
}
}.ifEmpty { null }
}
fun writeRelays(): List<String> {
return tags.mapNotNull {
if (it.size > 1 && it[0] == "r") {
when (it.getOrNull(2)) {
"read" -> null
"write" -> it[1]
else -> it[1]
}
} else {
null
}
}
}
companion object {
const val KIND = 10002
const val FIXED_D_TAG = ""