applesauce-core
Advanced tools
Comparing version 0.0.0-next-20250124151214 to 0.0.0-next-20250124165845
@@ -41,4 +41,4 @@ import { EventTemplate, NostrEvent, UnsignedEvent } from "nostr-tools"; |
export declare function modifyEventTags(event: NostrEvent | UnsignedEvent, operations: { |
public?: TagOperation; |
hidden?: TagOperation; |
public?: TagOperation | TagOperation[]; |
hidden?: TagOperation | TagOperation[]; |
}, signer?: HiddenTagsSigner): Promise<EventTemplate>; |
@@ -45,0 +45,0 @@ /** |
@@ -75,5 +75,17 @@ import { unixNow } from "applesauce-core/helpers"; |
export async function modifyEventTags(event, operations, signer) { |
const draft = { content: event.content, tags: event.tags, kind: event.kind, created_at: unixNow() }; |
const draft = { |
content: event.content, |
tags: Array.from(event.tags), |
kind: event.kind, |
created_at: unixNow(), |
}; |
if (operations.public) { |
draft.tags = operations.public(event.tags); |
if (Array.isArray(operations.public)) { |
for (const operation of operations.public) { |
draft.tags = operation(draft.tags); |
} |
} |
else { |
draft.tags = operations.public(draft.tags); |
} |
} |
@@ -88,3 +100,11 @@ if (operations.hidden) { |
throw new Error("Hidden tags are locked"); |
const newHidden = operations.hidden(hidden); |
let newHidden = Array.from(hidden); |
if (Array.isArray(operations.hidden)) { |
for (const operation of operations.hidden) { |
newHidden = operation(newHidden); |
} |
} |
else { |
newHidden = operations.hidden(newHidden); |
} |
const encryption = getEventEncryption(event.kind, signer); |
@@ -91,0 +111,0 @@ draft.content = await encryption.encrypt(event.pubkey, JSON.stringify(newHidden)); |
{ | ||
"name": "applesauce-core", | ||
"version": "0.0.0-next-20250124151214", | ||
"version": "0.0.0-next-20250124165845", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
144227
3620