aboutsummaryrefslogtreecommitdiffstats
path: root/lib/payments.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-07-13 01:03:36 -0700
committerAdam Soltys <[email protected]>2023-07-13 01:03:36 -0700
commitd18b06483a4b62b2d871d8c3cbbc5be4dec042fc (patch)
tree26b90525775e67d2173652fc791fcdf9e85e9259 /lib/payments.js
parenta30f2b4bc85ff9823e9c03fbfaae1685d081d708 (diff)
downloadcoinos-server-d18b06483a4b62b2d871d8c3cbbc5be4dec042fc.tar.gz
coinos-server-d18b06483a4b62b2d871d8c3cbbc5be4dec042fc.zip
text to speech notification
Diffstat (limited to 'lib/payments.js')
-rw-r--r--lib/payments.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/payments.js b/lib/payments.js
index e1e0590e..2d322a15 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -7,6 +7,8 @@ import { db, g, s, t } from "$lib/db";
import { l, err, warn } from "$lib/logging";
import { fail } from "$lib/utils";
import { callWebhook } from "$lib/webhooks";
+import dollarsToWords from "dollars-to-words";
+import got from "got";
export const types = {
internal: "internal",
@@ -122,7 +124,6 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
let equivalentRate =
invoice.rate * (store.rates[currency] / store.rates[invoice.currency]);
-
if (Math.abs(invoice.rate / store.rates[invoice.currency] - 1) < 0.01) {
rate = equivalentRate;
} else {
@@ -171,6 +172,19 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
emit(uid, "payment", p);
notify(user, `Received ${amount} sats`);
callWebhook(invoice, p);
+ if (user.username === "bob") {
+ let words = dollarsToWords(
+ parseFloat(((amount * p.rate) / 100000000).toFixed(2))
+ );
+
+ try {
+ let r = await got
+ .post("http://172.42.0.1:4020/tts", { json: { words, name: p.id } })
+ .json();
+ } catch (e) {
+ console.log(e);
+ }
+ }
return p;
};