Merge branch 'metadata'

This commit is contained in:
Mike Dilger 2023-01-07 16:31:58 +13:00
commit e01f706877
2 changed files with 40 additions and 34 deletions

2
Cargo.lock generated
View File

@ -2352,7 +2352,7 @@ dependencies = [
[[package]]
name = "nostr-types"
version = "0.2.0-unstable"
source = "git+https://github.com/mikedilger/nostr-types#204d4395f7a4cf6b3f9af54f2677863326cbdf94"
source = "git+https://github.com/mikedilger/nostr-types#6af60c195cff89ddf322b113e0014848b6c9ad6c"
dependencies = [
"aes",
"base64 0.13.1",

View File

@ -86,15 +86,22 @@ impl People {
// Update the map
let person = self.people.get_mut(pubkeyhex).unwrap();
// Determine whether to update it
let mut doit = person.metadata_at.is_none();
if let Some(metadata_at) = person.metadata_at {
if asof.0 > metadata_at {
doit = true;
}
}
if doit {
// Process fresh metadata
person.name = metadata.name;
person.about = metadata.about;
person.picture = metadata.picture;
if person.dns_id != metadata.nip05 {
person.dns_id = metadata.nip05;
person.name = metadata.get("name");
person.about = metadata.get("about");
person.picture = metadata.get("picture");
if person.dns_id != metadata.get("nip05") {
person.dns_id = metadata.get("nip05");
person.dns_id_valid = 0; // changed, so reset to invalid
person.dns_id_last_checked = None; // we haven't checked this one yet
}
@ -122,7 +129,6 @@ impl People {
})
.await??;
}
}
// Remove from failed avatars list so the UI will try to fetch the avatar again
GLOBALS.failed_avatars.write().await.remove(pubkeyhex);