feat: UserState

This commit is contained in:
2024-04-22 14:38:14 +01:00
parent 5a7657a95d
commit 80a4b5d8e6
103 changed files with 4179 additions and 1165 deletions

View File

@ -1,5 +1,4 @@
import { unwrap } from "@snort/shared";
import { EventExt, EventKind, NostrLink, TaggedNostrEvent } from "@snort/system";
import { EventKind, NostrLink, TaggedNostrEvent, Nip10 } from "@snort/system";
export function getNotificationContext(ev: TaggedNostrEvent) {
switch (ev.kind) {
@ -20,10 +19,10 @@ export function getNotificationContext(ev: TaggedNostrEvent) {
}
case EventKind.Repost:
case EventKind.Reaction: {
const thread = EventExt.extractThread(ev);
const tag = unwrap(thread?.replyTo ?? thread?.root ?? { value: ev.id, key: "e" });
if (tag.key === "e" || tag.key === "a") {
return NostrLink.fromThreadTag(tag);
const thread = Nip10.parseThread(ev);
const tag = thread?.replyTo ?? thread?.root;
if (tag) {
return tag;
} else {
throw new Error("Unknown thread context");
}