new notifications design
This commit is contained in:
@ -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);
|
||||
|
@ -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";
|
||||
|
Reference in New Issue
Block a user