Uses note.toEventUri to make sure the relay hint is correct

Avoids crash when adding an event to gallery without a relay hint.
This commit is contained in:
Vitor Pamplona
2025-02-24 20:46:33 -05:00
parent a2d9f31a8a
commit d5d289a834
7 changed files with 21 additions and 10 deletions
@@ -25,9 +25,9 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
fun Event.toNIP19(): String =
fun Event.toNIP19(relayHint: String? = null): String =
if (this is AddressableEvent) {
ATag(kind, pubKey, dTag(), null).toNAddr()
ATag(kind, pubKey, dTag(), relayHint).toNAddr()
} else {
NEvent.create(id, pubKey, kind, null)
NEvent.create(id, pubKey, kind, relayHint)
}
@@ -24,6 +24,6 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle
import com.vitorpamplona.quartz.nip19Bech32.toNIP19
fun Event.toNostrUri(): String = "nostr:${toNIP19()}"
fun Event.toNostrUri(relayHint: String? = null): String = "nostr:${toNIP19(relayHint)}"
fun EventHintBundle<Event>.toNostrUri(): String = "nostr:${toNEvent()}"