applesauce-core 0.0.0-next-20250124151214 → 0.0.0-next-20250124165845
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,8 +38,8 @@ export declare function unlockHiddenTags(event: NostrEvent, signer: HiddenTagsSi
|
|
|
38
38
|
* @throws
|
|
39
39
|
*/
|
|
40
40
|
export declare function modifyEventTags(event: NostrEvent | UnsignedEvent, operations: {
|
|
41
|
-
public?: TagOperation;
|
|
42
|
-
hidden?: TagOperation;
|
|
41
|
+
public?: TagOperation | TagOperation[];
|
|
42
|
+
hidden?: TagOperation | TagOperation[];
|
|
43
43
|
}, signer?: HiddenTagsSigner): Promise<EventTemplate>;
|
|
44
44
|
/**
|
|
45
45
|
* Override the hidden tags in an event
|
|
@@ -72,9 +72,21 @@ export async function unlockHiddenTags(event, signer, store) {
|
|
|
72
72
|
* @throws
|
|
73
73
|
*/
|
|
74
74
|
export async function modifyEventTags(event, operations, signer) {
|
|
75
|
-
const draft = {
|
|
75
|
+
const draft = {
|
|
76
|
+
content: event.content,
|
|
77
|
+
tags: Array.from(event.tags),
|
|
78
|
+
kind: event.kind,
|
|
79
|
+
created_at: unixNow(),
|
|
80
|
+
};
|
|
76
81
|
if (operations.public) {
|
|
77
|
-
|
|
82
|
+
if (Array.isArray(operations.public)) {
|
|
83
|
+
for (const operation of operations.public) {
|
|
84
|
+
draft.tags = operation(draft.tags);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
draft.tags = operations.public(draft.tags);
|
|
89
|
+
}
|
|
78
90
|
}
|
|
79
91
|
if (operations.hidden) {
|
|
80
92
|
if (!signer)
|
|
@@ -84,7 +96,15 @@ export async function modifyEventTags(event, operations, signer) {
|
|
|
84
96
|
const hidden = hasHiddenTags(event) ? getHiddenTags(event) : [];
|
|
85
97
|
if (!hidden)
|
|
86
98
|
throw new Error("Hidden tags are locked");
|
|
87
|
-
|
|
99
|
+
let newHidden = Array.from(hidden);
|
|
100
|
+
if (Array.isArray(operations.hidden)) {
|
|
101
|
+
for (const operation of operations.hidden) {
|
|
102
|
+
newHidden = operation(newHidden);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
newHidden = operations.hidden(newHidden);
|
|
107
|
+
}
|
|
88
108
|
const encryption = getEventEncryption(event.kind, signer);
|
|
89
109
|
draft.content = await encryption.encrypt(event.pubkey, JSON.stringify(newHidden));
|
|
90
110
|
}
|