diff options
| author | Adam Soltys <[email protected]> | 2025-03-12 15:19:05 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-03-12 15:19:05 -0700 |
| commit | 48001868b418c500d96801bf31b5f7b5c4f4d79c (patch) | |
| tree | 041ba62c85df3d251b97db82528c1f6ba4a0fc74 | |
| parent | 69c2e2c0066304679abacd8314fe4de9dcb71287 (diff) | |
| download | coinos-server-48001868b418c500d96801bf31b5f7b5c4f4d79c.tar.gz coinos-server-48001868b418c500d96801bf31b5f7b5c4f4d79c.zip | |
opt in nwc notifications
| -rw-r--r-- | lib/notifications.ts | 5 | ||||
| -rw-r--r-- | routes/users.ts | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/notifications.ts b/lib/notifications.ts index 528ac0ae..d5b4f73f 100644 --- a/lib/notifications.ts +++ b/lib/notifications.ts @@ -1,5 +1,5 @@ import config from "$config"; -import { db } from "$lib/db"; +import { db, g } from "$lib/db"; import ln from "$lib/ln"; import { err, l, warn } from "$lib/logging"; import { mail, templates } from "$lib/mail"; @@ -87,6 +87,9 @@ export const nwcNotify = async (p) => { let payment_hash = ""; if (p.type === "lightning") ({ payment_hash } = await ln.decode(p.hash)); for (const pubkey of pubkeys) { + const { notify } = await g(`app:${pubkey}`); + if (!notify) continue; + l("notifying", pubkey, p.type, p.amount); const notification = { type: p.amount > 0 ? "incoming" : "outgoing", diff --git a/routes/users.ts b/routes/users.ts index 6e4c98dd..ab8cb61a 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -883,13 +883,23 @@ export default { async updateApp(req, res) { try { - let { secret, pubkey, max_amount, max_fee, budget_renewal, name } = req.body; + let { + secret, + pubkey, + max_amount, + max_fee, + budget_renewal, + name, + notify, + } = req.body; + const { user } = req; const uid = user.id; let app = await g(pubkey); if (app && uid !== app.uid) fail("Unauthorized"); if (secret) pubkey = getPublicKey(secret); + notify = String(notify) === "true"; app = { ...app, @@ -898,6 +908,7 @@ export default { max_fee, budget_renewal, name, + notify, uid, secret, }; |
