Feat: save highVolumeTxs on DB and plugins code refactor

Fix: remove unused module and add space before '('

Chore: add jest tests for transactionNotify
This commit is contained in:
Cesar 2020-12-04 19:58:17 +00:00 committed by Josh Harvey
parent 75bfb4b991
commit 2ced230020
8 changed files with 646 additions and 414 deletions

View file

@ -1,3 +1,12 @@
const dbm = require('../postgresql_interface')
const db = require('../db')
const { v4: uuidv4 } = require('uuid')
module.exports = { machineEvents: dbm.machineEvents }
const addHighValueTx = (tx) => {
const sql = `INSERT INTO notifications (id, type, device_id, message, created) values($1, $2, $3, $4, CURRENT_TIMESTAMP)`
const direction = tx.direction === "cashOut" ? 'cash-out' : 'cash-in'
const message = `${tx.fiat} ${tx.fiatCode} ${direction} transaction`
return db.oneOrNone(sql, [uuidv4(), 'highValueTransaction', tx.deviceId, message])
}
module.exports = { machineEvents: dbm.machineEvents, addHighValueTx }