fix: use inner created_at timestamp nip17
This commit is contained in:
parent
a6e6e0a632
commit
baed390beb
@ -105,7 +105,7 @@ export class Nip17ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
|||||||
participants,
|
participants,
|
||||||
messages: messages.map(m => ({
|
messages: messages.map(m => ({
|
||||||
id: m.id,
|
id: m.id,
|
||||||
created_at: m.created_at,
|
created_at: m.inner.created_at,
|
||||||
from: m.inner.pubkey,
|
from: m.inner.pubkey,
|
||||||
tags: m.tags,
|
tags: m.tags,
|
||||||
content: "",
|
content: "",
|
||||||
|
@ -44,7 +44,7 @@ export function unixNowMs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function jitter(n: number) {
|
export function jitter(n: number) {
|
||||||
return n * 2 * Math.random() - n;
|
return n * Math.random();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deepClone<T>(obj: T) {
|
export function deepClone<T>(obj: T) {
|
||||||
|
@ -98,7 +98,7 @@ export class EventBuilder {
|
|||||||
pubkey: this.#pubkey ?? "",
|
pubkey: this.#pubkey ?? "",
|
||||||
content: this.#content ?? "",
|
content: this.#content ?? "",
|
||||||
kind: this.#kind,
|
kind: this.#kind,
|
||||||
created_at: (this.#createdAt ?? unixNow()) + (this.#jitter ? jitter(this.#jitter) : 0),
|
created_at: (this.#createdAt ?? unixNow()) - (this.#jitter ? jitter(this.#jitter) : 0),
|
||||||
tags: this.#tags.sort((a, b) => a[0].localeCompare(b[0])),
|
tags: this.#tags.sort((a, b) => a[0].localeCompare(b[0])),
|
||||||
} as NostrEvent;
|
} as NostrEvent;
|
||||||
ev.id = EventExt.createId(ev);
|
ev.id = EventExt.createId(ev);
|
||||||
|
@ -314,6 +314,7 @@ export class EventPublisher {
|
|||||||
eb.pow(powTarget, powMiner);
|
eb.pow(powTarget, powMiner);
|
||||||
}
|
}
|
||||||
eb.content(await signer.nip44Encrypt(JSON.stringify(inner), pTag));
|
eb.content(await signer.nip44Encrypt(JSON.stringify(inner), pTag));
|
||||||
|
eb.jitter(60 * 60 * 24);
|
||||||
|
|
||||||
return await eb.buildAndSign(secret);
|
return await eb.buildAndSign(secret);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user