feat: diff-sync follows

This commit is contained in:
2024-04-15 22:31:51 +01:00
parent edf64e4125
commit 5a7657a95d
25 changed files with 320 additions and 154 deletions

View File

@ -2,7 +2,7 @@ import { EventKind, HexKey, NostrPrefix, NostrEvent, EventSigner, PowMiner } fro
import { HashtagRegex, MentionNostrEntityRegex } from "./const";
import { getPublicKey, jitter, unixNow } from "@snort/shared";
import { EventExt } from "./event-ext";
import { tryParseNostrLink } from "./nostr-link";
import { NostrLink, tryParseNostrLink } from "./nostr-link";
export class EventBuilder {
#kind?: EventKind;
@ -14,6 +14,21 @@ export class EventBuilder {
#powMiner?: PowMiner;
#jitter?: number;
/**
* Populate builder with values from link
*/
fromLink(link: NostrLink) {
if (link.kind) {
this.#kind = link.kind;
}
if (link.author) {
this.#pubkey = link.author;
}
if (link.type === NostrPrefix.Address && link.id) {
this.tag(["d", link.id]);
}
}
jitter(n: number) {
this.#jitter = n;
return this;