diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mail.js | 33 | ||||
| -rw-r--r-- | lib/payments.js | 4 | ||||
| -rw-r--r-- | lib/whitelist.js | 1 |
3 files changed, 38 insertions, 0 deletions
diff --git a/lib/mail.js b/lib/mail.js new file mode 100644 index 00000000..1dc72b1f --- /dev/null +++ b/lib/mail.js @@ -0,0 +1,33 @@ +import config from "$config"; +import { SESClient } from "@aws-sdk/client-ses"; +import { SendEmailCommand } from "@aws-sdk/client-ses"; +import handlebars from "handlebars"; +import fs from "fs"; +import path from "path"; + +export let templates = { + paymentSent: "templates/payments/sent.html" +}; + +export let mail = async (user, subject, template, params) => { + if (!user.email) return; + + let source = fs.readFileSync(path.join(__dirname, template), "utf8"); + let html = handlebars.compile(source, params); + + let client = new SESClient({ region: "us-east-2" }); + await client.send( + new SendEmailCommand({ + Destination: { + ToAddresses: [user.email] + }, + Message: { + Body: { + Html: { Charset, Data: html } + }, + Subject: { Charset, Data: subject } + }, + Source: config.support + }) + ); +}; diff --git a/lib/payments.js b/lib/payments.js index 098c16f7..510f24e2 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -16,6 +16,7 @@ import EventEmitter from "events"; import crc32 from "buffer-crc32"; import { mqtt1, mqtt2 } from "$lib/mqtt"; import ln from "$lib/ln"; +import { mail, templates } from "$lib/mail"; export const types = { internal: "internal", @@ -98,6 +99,9 @@ export let debit = async ( l("sent", type, user.username, amount); emit(user.id, "payment", p); + mail(user, "Payment sent", templates.paymentSent, { + username: user.username + }); return p; }; diff --git a/lib/whitelist.js b/lib/whitelist.js index 8da60b7f..1d722683 100644 --- a/lib/whitelist.js +++ b/lib/whitelist.js @@ -20,6 +20,7 @@ export default [ "linked", "keys", "locktime", + "nip5", "payments", "profile", "prompt", |
