aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/notifications.ts9
-rw-r--r--routes/users.ts1
2 files changed, 6 insertions, 4 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);
}
diff --git a/routes/users.ts b/routes/users.ts
index 930c3881..fbeb409e 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -933,7 +933,6 @@ export default {
const { id: uid } = req.user;
const { id } = req.body;
await db.sAdd(`${uid}:pins`, id);
- console.log("added", id);
res.send({});
},