bug: always write relay list to bootstrap relays

This commit is contained in:
2023-01-21 17:55:49 +00:00
parent 079b4ff9a9
commit abeb2f5a6c
4 changed files with 61 additions and 4 deletions

View File

@ -50,6 +50,9 @@ export class NostrSystem {
for (let [_, s] of this.Subscriptions) {
c.AddSubscription(s);
}
} else {
// update settings if already connected
this.Sockets.get(address)!.Settings = options;
}
} catch (e) {
console.error(e);
@ -90,6 +93,15 @@ export class NostrSystem {
}
}
/**
* Write an event to a relay then disconnect
*/
async WriteOnceToRelay(address: string, ev: Event) {
let c = new Connection(address, { write: true, read: false });
await c.SendAsync(ev);
c.Close();
}
/**
* Request profile metadata for a set of pubkeys
*/
@ -179,9 +191,9 @@ export class NostrSystem {
let profile = mapEventToProfile(e);
if (profile) {
let existing = await db.users.get(profile.pubkey);
if((existing?.created ?? 0) < profile.created) {
if ((existing?.created ?? 0) < profile.created) {
await db.users.put(profile);
} else if(existing) {
} else if (existing) {
await db.users.update(profile.pubkey, { loaded: new Date().getTime() });
}
}