aboutsummaryrefslogtreecommitdiffstats
path: root/lib/notifications.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/notifications.ts')
-rw-r--r--lib/notifications.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/notifications.ts b/lib/notifications.ts
index e988a728..5d602291 100644
--- a/lib/notifications.ts
+++ b/lib/notifications.ts
@@ -7,7 +7,8 @@ import mqtt from "$lib/mqtt";
import { publish, serverSecret } from "$lib/nostr";
import { emit } from "$lib/sockets";
import { f, fiat, fmt, getUser, link, nada, t } from "$lib/utils";
-import { finalizeEvent } from "nostr-tools";
+import { hexToBytes } from "@noble/hashes/utils";
+import { finalizeEvent, nip04 } from "nostr-tools";
import webpush from "web-push";
if (config.vapid) {
@@ -98,11 +99,13 @@ export const nwcNotify = async (p) => {
settled_at: p.created,
};
- const content = JSON.stringify({
+ const payload = JSON.stringify({
notification_type: p.amount > 0 ? "payment_received" : "payment_sent",
notification,
});
+ const content = await nip04.encrypt(serverSecret, pubkey, payload);
+
const unsigned = {
content,
tags: [["p", pubkey]],
@@ -110,7 +113,7 @@ export const nwcNotify = async (p) => {
created_at: Math.floor(Date.now() / 1000),
};
- const event = finalizeEvent(unsigned, serverSecret);
+ const event = finalizeEvent(unsigned, hexToBytes(serverSecret));
publish(event).catch(nada);
}