mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-11-19 18:37:45 +01:00
fixed so that newer nip05 id's will supersede older ones
tested with my own two id's with raw.github and github.io id's
This commit is contained in:
@@ -961,14 +961,13 @@ bool processKind0Event(Event e) {
|
|||||||
bool newEntry = false, entryModified = false;
|
bool newEntry = false, entryModified = false;
|
||||||
if( !gKindONames.containsKey(e.eventData.pubkey)) {
|
if( !gKindONames.containsKey(e.eventData.pubkey)) {
|
||||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, null);
|
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, null);
|
||||||
|
|
||||||
newEntry = true;;
|
newEntry = true;;
|
||||||
} else {
|
} else {
|
||||||
int oldTime = gKindONames[e.eventData.pubkey]?.createdAt??0;
|
int oldTime = gKindONames[e.eventData.pubkey]?.createdAt??0;
|
||||||
if( oldTime < e.eventData.createdAt) {
|
if( oldTime < e.eventData.createdAt) {
|
||||||
Event? oldContactEvent = gKindONames[e.eventData.pubkey]?.latestContactEvent;
|
Event? oldContactEvent = gKindONames[e.eventData.pubkey]?.latestContactEvent;
|
||||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, oldContactEvent);
|
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, oldContactEvent);
|
||||||
entryModified = true;;
|
entryModified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,22 +975,18 @@ bool processKind0Event(Event e) {
|
|||||||
print("At end of processKind0Events: for name = $name ${newEntry? "added entry": ( entryModified?"modified entry": "No change done")} ");
|
print("At end of processKind0Events: for name = $name ${newEntry? "added entry": ( entryModified?"modified entry": "No change done")} ");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nipVerified = false;
|
|
||||||
|
|
||||||
bool localDebug = false; //e.eventData.pubkey == "9ec7a778167afb1d30c4833de9322da0c08ba71a69e1911d5578d3144bb56437"? true: false;
|
bool localDebug = false; //e.eventData.pubkey == "9ec7a778167afb1d30c4833de9322da0c08ba71a69e1911d5578d3144bb56437"? true: false;
|
||||||
|
|
||||||
if( newEntry || entryModified) {
|
if( newEntry || entryModified) {
|
||||||
if(nip05.length > 0) {
|
if(nip05.length > 0) {
|
||||||
//print("---");
|
|
||||||
List<String> urlSplit = nip05.split("@");
|
List<String> urlSplit = nip05.split("@");
|
||||||
//print(nip05);
|
|
||||||
if( urlSplit.length == 2) {
|
if( urlSplit.length == 2) {
|
||||||
|
|
||||||
String urlNip05 = urlSplit[1] + "/.well-known/nostr.json?name=" + urlSplit[0];
|
String urlNip05 = urlSplit[1] + "/.well-known/nostr.json?name=" + urlSplit[0];
|
||||||
if( !urlNip05.startsWith("http")) {
|
if( !urlNip05.startsWith("http")) {
|
||||||
urlNip05 = "http://"+ urlNip05;
|
urlNip05 = "http://"+ urlNip05;
|
||||||
}
|
}
|
||||||
//print("got $urlNip05 for $name");
|
|
||||||
fetchNip05Info(urlNip05)
|
fetchNip05Info(urlNip05)
|
||||||
.then((httpResponse) {
|
.then((httpResponse) {
|
||||||
if( localDebug ) print("-----\nnip future for $urlNip05 returned body ${httpResponse.body}");
|
if( localDebug ) print("-----\nnip future for $urlNip05 returned body ${httpResponse.body}");
|
||||||
@@ -1001,19 +996,22 @@ bool processKind0Event(Event e) {
|
|||||||
dynamic json = jsonDecode(httpResponse.body);
|
dynamic json = jsonDecode(httpResponse.body);
|
||||||
namesInResponse = json["names"];
|
namesInResponse = json["names"];
|
||||||
if( namesInResponse.length > 0) {
|
if( namesInResponse.length > 0) {
|
||||||
//print(names.runtimeType);
|
|
||||||
for(var returntedName in namesInResponse.keys) {
|
for(var returntedName in namesInResponse.keys) {
|
||||||
//print('in name for loop');
|
|
||||||
//if( true) print(" urlSplit[0] = ${urlSplit[0]} $returntedName = ${namesInResponse[returntedName]}");
|
|
||||||
|
|
||||||
if( returntedName == urlSplit[0] && namesInResponse[returntedName] == e.eventData.pubkey) {
|
if( returntedName == urlSplit[0] && namesInResponse[returntedName] == e.eventData.pubkey) {
|
||||||
nipVerified = true;
|
int oldTime = 0;
|
||||||
if( !gKindONames.containsKey(e.eventData.pubkey)) {
|
if( !gKindONames.containsKey(e.eventData.pubkey)) {
|
||||||
|
//printWarning("in response handing. creating user info");
|
||||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, e);
|
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, e);
|
||||||
|
} else {
|
||||||
|
oldTime = gKindONames[e.eventData.pubkey]?.createdAt??0;
|
||||||
|
//print("in response handing. user info exists with old time = $oldTime and this event time = ${e.eventData.createdAt}");
|
||||||
}
|
}
|
||||||
|
|
||||||
gKindONames[e.eventData.pubkey]?.nip05Verified = true;
|
if( oldTime <= e.eventData.createdAt ) {
|
||||||
gKindONames[e.eventData.pubkey]?.nip05Id = nip05;
|
gKindONames[e.eventData.pubkey]?.nip05Verified = true;
|
||||||
|
gKindONames[e.eventData.pubkey]?.nip05Id = nip05;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user