1
0
mirror of git://jb55.com/damus synced 2024-09-18 19:23:49 +00:00

nip19: allow empty relays in nprofile and nevent

This commit is contained in:
William Casarin 2023-04-11 12:44:56 -07:00
parent e8d63768c1
commit b30d0c01db
2 changed files with 9 additions and 3 deletions

View File

@ -135,7 +135,7 @@ static int tlvs_to_relays(struct nostr_tlvs *tlvs, struct relays *relays) {
str->end = (const char*)(tlv->value + tlv->len);
}
return relays->num_relays > 0;
return 1;
}
static int parse_nostr_bech32_nevent(struct cursor *cur, struct bech32_nevent *nevent) {

View File

@ -349,7 +349,10 @@ func convert_mention_bech32_block(_ b: mention_bech32_block) -> Block?
case NOSTR_BECH32_NEVENT:
let nevent = b.bech32.data.nevent;
let event_id = hex_encode(Data(bytes: nevent.event_id, count: 32))
let relay_id = strblock_to_string(nevent.relays.relays.0)
var relay_id: String? = nil
if nevent.relays.num_relays > 0 {
relay_id = strblock_to_string(nevent.relays.relays.0)
}
let event_id_ref = ReferencedId(ref_id: event_id, relay_id: relay_id, key: "e")
return .mention(Mention(index: nil, type: .event, ref: event_id_ref))
@ -362,7 +365,10 @@ func convert_mention_bech32_block(_ b: mention_bech32_block) -> Block?
case NOSTR_BECH32_NPROFILE:
let nprofile = b.bech32.data.nprofile
let pubkey = hex_encode(Data(bytes: nprofile.pubkey, count: 32))
let relay_id = strblock_to_string(nprofile.relays.relays.0)
var relay_id: String? = nil
if nprofile.relays.num_relays > 0 {
relay_id = strblock_to_string(nprofile.relays.relays.0)
}
let pubkey_ref = ReferencedId(ref_id: pubkey, relay_id: relay_id, key: "p")
return .mention(Mention(index: nil, type: .pubkey, ref: pubkey_ref))