new notifications design

This commit is contained in:
2023-08-02 18:27:29 +01:00
parent 2adce0ead1
commit f968299f4d
17 changed files with 327 additions and 44 deletions

View File

@ -1,5 +1,5 @@
import { bech32ToHex, hexToBech32 } from "@snort/shared";
import { NostrPrefix, decodeTLV, TLVEntryType } from ".";
import { NostrPrefix, decodeTLV, TLVEntryType, encodeTLV } from ".";
export interface NostrLink {
type: NostrPrefix;
@ -10,6 +10,24 @@ export interface NostrLink {
encode(): string;
}
export function createNostrLink(prefix: NostrPrefix, id: string, relays?: string[], kind?: number, author?: string) {
return {
type: prefix,
id,
relays,
kind, author,
encode: () => {
if(prefix === NostrPrefix.Note || prefix === NostrPrefix.PublicKey) {
return hexToBech32(prefix, id);
}
if(prefix === NostrPrefix.Address || prefix === NostrPrefix.Event || prefix === NostrPrefix.Profile) {
return encodeTLV(prefix, id, relays, kind, author);
}
return "";
}
} as NostrLink;
}
export function validateNostrLink(link: string): boolean {
try {
const parsedLink = parseNostrLink(link);

View File

@ -2,7 +2,7 @@ import debug from "debug";
import { v4 as uuid } from "uuid";
import { appendDedupe, sanitizeRelayUrl, unixNowMs } from "@snort/shared";
import { ReqFilter, u256, HexKey, EventKind } from ".";
import { ReqFilter, u256, HexKey, EventKind, TaggedRawEvent, OnEventCallback, OnEventCallbackRelease } from ".";
import { diffFilters } from "./request-splitter";
import { RelayCache, splitByWriteRelays, splitFlatByWriteRelays } from "./gossip-model";
import { flatMerge, mergeSimilar } from "./request-merger";