From 204e421b3de61c2218ab087204090ffc99d3724e Mon Sep 17 00:00:00 2001 From: Cesar <26280794+csrapr@users.noreply.github.com> Date: Tue, 15 Dec 2020 18:55:45 +0000 Subject: [PATCH] Feat: compliance blacklisted addresses notifications --- lib/cash-in/cash-in-tx.js | 4 +++- lib/new-settings-loader.js | 12 ++++++++++++ lib/notifier/index.js | 17 ++++++++++++++++- lib/notifier/queries.js | 6 ++++++ .../src/pages/Blacklist/Blacklist.js | 6 +----- .../src/pages/Customers/CustomerProfile.js | 7 ++++--- .../src/pages/Customers/CustomersList.js | 8 ++++++-- .../Customers/components/CustomerDetails.js | 9 ++++----- new-lamassu-admin/src/pages/Customers/helper.js | 7 +++---- 9 files changed, 55 insertions(+), 21 deletions(-) diff --git a/lib/cash-in/cash-in-tx.js b/lib/cash-in/cash-in-tx.js index 286408a4..93d9acde 100644 --- a/lib/cash-in/cash-in-tx.js +++ b/lib/cash-in/cash-in-tx.js @@ -8,6 +8,7 @@ const plugins = require('../plugins') const logger = require('../logger') const settingsLoader = require('../new-settings-loader') const configManager = require('../new-config-manager') +const notifier = require("../notifier/index") const cashInAtomic = require('./cash-in-atomic') const cashInLow = require('./cash-in-low') @@ -30,10 +31,11 @@ function post (machineTx, pi) { if (_.some(it => it.created_by_operator === true)(blacklistItems)) { blacklisted = true + notifier.addBlacklistNotification(r.tx, false) } else if (_.some(it => it.created_by_operator === false)(blacklistItems) && rejectAddressReuseActive) { + notifier.addBlacklistNotification(r.tx, true) addressReuse = true } - return postProcess(r, pi, blacklisted, addressReuse) }) .then(changes => cashInLow.update(db, updatedTx, changes)) diff --git a/lib/new-settings-loader.js b/lib/new-settings-loader.js index 916c6c5b..1f88ce8b 100644 --- a/lib/new-settings-loader.js +++ b/lib/new-settings-loader.js @@ -44,6 +44,18 @@ const configSql = 'insert into user_config (type, data, valid, schema_version) v function saveConfig (config) { return loadLatestConfigOrNone() .then(currentConfig => { + if(config.notifications_cryptoHighBalance || config.notifications_cryptoLowBalance) { + clearCryptoBalanceNotifications(currentConfig, config, false) + } + if(config.notifications_cryptoBalanceOverrides) { + clearCryptoBalanceNotifications(currentConfig.notifications_cryptoBalanceOverrides, config.notifications_cryptoBalanceOverrides, true) + } + if(config.notifications_fiatBalanceCassette1 || config.notifications_fiatBalanceCassette2) { + clearCassetteNotifications(currentConfig, config, false) + } + if(config.notifications_fiatBalanceOverrides) { + clearCassetteNotifications(currentConfig.notifications_fiatBalanceOverrides, config.notifications_fiatBalanceOverrides, true) + } const newConfig = _.assign(currentConfig, config) return db.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION]) }) diff --git a/lib/notifier/index.js b/lib/notifier/index.js index 6c5a1099..4f378288 100644 --- a/lib/notifier/index.js +++ b/lib/notifier/index.js @@ -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 } diff --git a/lib/notifier/queries.js b/lib/notifier/queries.js index 2e556451..ad397cef 100644 --- a/lib/notifier/queries.js +++ b/lib/notifier/queries.js @@ -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 } diff --git a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js index 1b6c8eb4..de62a090 100644 --- a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js +++ b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js @@ -134,11 +134,7 @@ const Blacklist = () => { return ( <> -
- setShowModal(true)}> - Blacklist new addresses - -
+ setShowModal(true)}>Blacklist new addresses
{ Customers - {name.length + {name.length ? name : R.path(['phone'])(customerData)} + {/* {name.length ? name : getFormattedPhone( R.path(['phone'])(customerData), locale.country - )} + )} */}
diff --git a/new-lamassu-admin/src/pages/Customers/CustomersList.js b/new-lamassu-admin/src/pages/Customers/CustomersList.js index e65efcf1..8f0a9a21 100644 --- a/new-lamassu-admin/src/pages/Customers/CustomersList.js +++ b/new-lamassu-admin/src/pages/Customers/CustomersList.js @@ -11,7 +11,11 @@ import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-ou import { ifNotNull } from 'src/utils/nullCheck' import styles from './CustomersList.styles' -import { getAuthorizedStatus, getFormattedPhone, getName } from './helper' +import { + getAuthorizedStatus, + getName + /* getFormattedPhone */ +} from './helper' const useStyles = makeStyles(styles) @@ -22,7 +26,7 @@ const CustomersList = ({ data, locale, onClick, loading }) => { { header: 'Phone', width: 172, - view: it => getFormattedPhone(it.phone, locale.country) + view: it => it.phone // getFormattedPhone(it.phone, locale.country) }, { header: 'Name', diff --git a/new-lamassu-admin/src/pages/Customers/components/CustomerDetails.js b/new-lamassu-admin/src/pages/Customers/components/CustomerDetails.js index 7fd988e7..6d94f801 100644 --- a/new-lamassu-admin/src/pages/Customers/components/CustomerDetails.js +++ b/new-lamassu-admin/src/pages/Customers/components/CustomerDetails.js @@ -9,7 +9,7 @@ import { ReactComponent as LawIconInverse } from 'src/styling/icons/circle butto import { ReactComponent as LawIcon } from 'src/styling/icons/circle buttons/law/zodiac.svg' import mainStyles from '../CustomersList.styles' -import { getFormattedPhone, getName } from '../helper' +import { /* getFormattedPhone, */ getName } from '../helper' import FrontCameraPhoto from './FrontCameraPhoto' @@ -22,7 +22,7 @@ const CustomerDetails = memo(({ customer, locale, setShowCompliance }) => { { header: 'Phone number', size: 172, - value: getFormattedPhone(customer.phone, locale.country) + value: customer.phone // getFormattedPhone(customer.phone, locale.country) }, { header: 'ID number', @@ -47,9 +47,8 @@ const CustomerDetails = memo(({ customer, locale, setShowCompliance }) => {

- {name.length - ? name - : getFormattedPhone(R.path(['phone'])(customer), locale.country)} + {name.length ? name : R.path(['phone'])(customer)} + {/* getFormattedPhone(R.path(['phone'])(customer), locale.country)} */}

: { label: 'Authorized', type: 'success' } const getFormattedPhone = (phone, country) => { - const phoneNumber = - phone && country ? parsePhoneNumberFromString(phone, country) : null - - return phoneNumber ? phoneNumber.formatInternational() : phone + return phone && country + ? parsePhoneNumberFromString(phone, country).formatInternational() + : '' } const getName = it => {