feat: add blacklist message to machine communication

This commit is contained in:
Sérgio Salgado 2022-10-06 19:03:00 +01:00 committed by Rafael
parent 8af7c97c16
commit 677cb39f0c
4 changed files with 7 additions and 8 deletions

View file

@ -32,7 +32,7 @@ function post (machineTx, pi) {
return cashInAtomic.atomic(machineTx, pi)
.then(r => {
const updatedTx = r.tx
let blacklisted = false
let blacklisted = null
let addressReuse = false
let walletScore = {}
@ -50,7 +50,7 @@ function post (machineTx, pi) {
walletScore = fetchedWalletScore
if (_.some(it => it.address === updatedTx.toAddress)(blacklistItems)) {
blacklisted = true
blacklisted = _.find(it => it.address === updatedTx.toAddress)(blacklistItems)
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, false)
} else if (isReusedAddress && rejectAddressReuse) {
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, true)
@ -61,7 +61,8 @@ function post (machineTx, pi) {
.then(changes => _.set('walletScore', _.isNil(walletScore) ? null : walletScore.score, changes))
.then(changes => cashInLow.update(db, updatedTx, changes))
.then(tx => _.set('bills', machineTx.bills, tx))
.then(tx => _.set('blacklisted', blacklisted, tx))
.then(tx => _.set('blacklisted', Boolean(blacklisted), tx))
.then(tx => _.set('blacklistMessage', blacklisted?.content, tx))
.then(tx => _.set('addressReuse', addressReuse, tx))
.then(tx => _.set('validWalletScore', _.isNil(walletScore) ? true : walletScore.isValid, tx))
})