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:
@@ -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()}"
|
||||
|
||||
Reference in New Issue
Block a user