nip27: handle nrelay a bit better
This commit is contained in:
@@ -78,6 +78,8 @@ func build_mention_indices(_ blocks: [Block], type: MentionType) -> Set<Int> {
|
||||
acc.insert(idx)
|
||||
}
|
||||
}
|
||||
case .relay:
|
||||
return
|
||||
case .text:
|
||||
return
|
||||
case .hashtag:
|
||||
|
||||
@@ -81,6 +81,7 @@ enum Block: Equatable {
|
||||
case hashtag(String)
|
||||
case url(URL)
|
||||
case invoice(Invoice)
|
||||
case relay(String)
|
||||
|
||||
var is_invoice: Invoice? {
|
||||
if case .invoice(let invoice) = self {
|
||||
@@ -138,6 +139,8 @@ func render_blocks(blocks: [Block]) -> String {
|
||||
} else {
|
||||
return str + "nostr:\(bech32_note_id(m.ref.ref_id)!)"
|
||||
}
|
||||
case .relay(let relay):
|
||||
return str + relay
|
||||
case .text(let txt):
|
||||
return str + txt
|
||||
case .hashtag(let htag):
|
||||
@@ -362,9 +365,18 @@ func convert_mention_bech32_block(_ b: mention_bech32_block) -> Block?
|
||||
return .mention(Mention(index: nil, type: .pubkey, ref: pubkey_ref))
|
||||
|
||||
case NOSTR_BECH32_NRELAY:
|
||||
fallthrough
|
||||
let nrelay = b.bech32.data.nrelay
|
||||
guard let relay_str = strblock_to_string(nrelay.relay) else {
|
||||
return nil
|
||||
}
|
||||
return .relay(relay_str)
|
||||
|
||||
case NOSTR_BECH32_NADDR:
|
||||
return .text(strblock_to_string(b.str)!)
|
||||
// TODO: wtf do I do with this
|
||||
guard let naddr = strblock_to_string(b.str) else {
|
||||
return nil
|
||||
}
|
||||
return .text("nostr:" + naddr)
|
||||
|
||||
default:
|
||||
return nil
|
||||
|
||||
@@ -162,6 +162,7 @@ struct NoteContentView: View {
|
||||
if m.type == .pubkey && m.ref.ref_id == profile.pubkey {
|
||||
self.artifacts = render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey)
|
||||
}
|
||||
case .relay: return
|
||||
case .text: return
|
||||
case .hashtag: return
|
||||
case .url: return
|
||||
@@ -313,6 +314,9 @@ func render_blocks(blocks: [Block], profiles: Profiles, privkey: String?) -> Not
|
||||
}
|
||||
|
||||
return str + CompatibleText(stringLiteral: trimmed)
|
||||
case .relay(let relay):
|
||||
return str + CompatibleText(stringLiteral: relay)
|
||||
|
||||
case .hashtag(let htag):
|
||||
return str + hashtag_str(htag)
|
||||
case .invoice(let invoice):
|
||||
|
||||
Reference in New Issue
Block a user