support bare domains (without "user" part) on dns_ids.

This commit is contained in:
fiatjaf 2023-01-04 22:50:41 -03:00
parent a61d2bd502
commit e5ac91294d
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
2 changed files with 9 additions and 1 deletions

View File

@ -602,6 +602,9 @@ impl Overlord {
async fn get_and_follow_nip35(nip35: String) -> Result<(), Error> {
let mut parts: Vec<&str> = nip35.split('@').collect();
if parts.len() == 1 {
parts = Vec::from(["_", parts.get(0).unwrap()])
}
if parts.len() != 2 {
return Err(Error::InvalidDnsId);
}

View File

@ -316,13 +316,18 @@ impl GossipUi {
ui.label("🚶");
}
if let Some(dns_id) = &person.dns_id {
if let Some(mut dns_id) = person.dns_id.clone() {
if dns_id.starts_with("_@") {
dns_id = dns_id.get(2..).unwrap().to_string();
}
if person.dns_id_valid > 0 {
ui.label(RichText::new(dns_id).monospace().small());
} else {
ui.label(RichText::new(dns_id).monospace().small().strikethrough());
}
}
ui.label(RichText::new("🔑").text_style(TextStyle::Small).weak());
if ui.add(CopyButton {}).clicked() {
ui.output().copied_text = person.pubkey.0.to_owned();