Feat: compliance blacklisted addresses notifications

This commit is contained in:
Cesar 2020-12-15 18:55:45 +00:00 committed by Josh Harvey
parent 3b3bdf839b
commit 204e421b3d
9 changed files with 55 additions and 21 deletions

View file

@ -363,11 +363,26 @@ const errorAlertsNotify = (alertRec) => {
}, alerts)
}
const addBlacklistNotification = (tx, isAddressReuse) => {
let detail = ''
let message = ''
if(isAddressReuse) {
detail = `${tx.cryptoCode}_REUSED_${tx.toAddress}`
message = `Blocked address reuse: ${tx.cryptoCode} ${tx.toAddress.substr(0,10)}...`
} else {
detail = `${tx.cryptoCode}_BLOCKED_${tx.toAddress}`
message = `Blocked blacklisted address: ${tx.cryptoCode} ${tx.toAddress.substr(0,10)}...`
}
queries.addComplianceNotification(tx.deviceId, detail, message)
}
module.exports = {
transactionNotify,
checkNotification,
checkPings,
checkStuckScreen,
sendRedemptionMessage,
cashCassettesNotify
cashCassettesNotify,
addBlacklistNotification
}

View file

@ -60,6 +60,11 @@ const invalidateNotification = (id) => {
return db.none(sql, [id])
}
const addComplianceNotification = (deviceId, detail, message) => {
const sql = `INSERT INTO notifications (id, type, detail, device_id, message, created) values ($1, 'compliance', $2, $3, $4, CURRENT_TIMESTAMP)`
return db.oneOrNone(sql, [uuidv4(), detail, deviceId, message])
}
module.exports = {
machineEvents: dbm.machineEvents,
addHighValueTx,
@ -70,4 +75,5 @@ module.exports = {
getAllValidNotifications,
getValidNotifications,
invalidateNotification,
addComplianceNotification
}