Feat: compliance blacklisted addresses notifications

This commit is contained in:
Cesar 2020-12-15 18:55:45 +00:00 committed by Josh Harvey
parent 1ec56cd1ab
commit 705747e9e0
7 changed files with 48 additions and 14 deletions

View file

@ -44,6 +44,18 @@ const configSql = 'insert into user_config (type, data, valid, schema_version) v
function saveConfig (config) { function saveConfig (config) {
return loadLatestConfigOrNone() return loadLatestConfigOrNone()
.then(currentConfig => { .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) const newConfig = _.assign(currentConfig, config)
return db.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION]) return db.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
}) })

View file

@ -512,6 +512,20 @@ const errorAlertsNotify = (alertRec) => {
}, alerts) }, 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 = { module.exports = {
transactionNotify, transactionNotify,
checkNotification, checkNotification,

View file

@ -66,6 +66,11 @@ const hasUnreadNotifications = () => {
return db.oneOrNone(sql).then(res => res.exists) return db.oneOrNone(sql).then(res => res.exists)
} }
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 = { module.exports = {
machineEvents: dbm.machineEvents, machineEvents: dbm.machineEvents,
addNotification, addNotification,

View file

@ -24,7 +24,7 @@ import {
TransactionsList, TransactionsList,
ComplianceDetails ComplianceDetails
} from './components' } from './components'
import { getFormattedPhone, getName } from './helper' import { /* getFormattedPhone, */ getName } from './helper'
const useStyles = makeStyles(styles) const useStyles = makeStyles(styles)
@ -147,12 +147,13 @@ const CustomerProfile = memo(() => {
Customers Customers
</Label1> </Label1>
<Label2 noMargin className={classes.labelLink}> <Label2 noMargin className={classes.labelLink}>
{name.length {name.length ? name : R.path(['phone'])(customerData)}
{/* {name.length
? name ? name
: getFormattedPhone( : getFormattedPhone(
R.path(['phone'])(customerData), R.path(['phone'])(customerData),
locale.country locale.country
)} )} */}
</Label2> </Label2>
</Breadcrumbs> </Breadcrumbs>
<div> <div>

View file

@ -11,7 +11,11 @@ import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-ou
import { ifNotNull } from 'src/utils/nullCheck' import { ifNotNull } from 'src/utils/nullCheck'
import styles from './CustomersList.styles' import styles from './CustomersList.styles'
import { getAuthorizedStatus, getFormattedPhone, getName } from './helper' import {
getAuthorizedStatus,
getName
/* getFormattedPhone */
} from './helper'
const useStyles = makeStyles(styles) const useStyles = makeStyles(styles)
@ -22,7 +26,7 @@ const CustomersList = ({ data, locale, onClick, loading }) => {
{ {
header: 'Phone', header: 'Phone',
width: 172, width: 172,
view: it => getFormattedPhone(it.phone, locale.country) view: it => it.phone // getFormattedPhone(it.phone, locale.country)
}, },
{ {
header: 'Name', header: 'Name',

View file

@ -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 { ReactComponent as LawIcon } from 'src/styling/icons/circle buttons/law/zodiac.svg'
import mainStyles from '../CustomersList.styles' import mainStyles from '../CustomersList.styles'
import { getFormattedPhone, getName } from '../helper' import { /* getFormattedPhone, */ getName } from '../helper'
import FrontCameraPhoto from './FrontCameraPhoto' import FrontCameraPhoto from './FrontCameraPhoto'
@ -22,7 +22,7 @@ const CustomerDetails = memo(({ customer, locale, setShowCompliance }) => {
{ {
header: 'Phone number', header: 'Phone number',
size: 172, size: 172,
value: getFormattedPhone(customer.phone, locale.country) value: customer.phone // getFormattedPhone(customer.phone, locale.country)
}, },
{ {
header: 'ID number', header: 'ID number',
@ -47,9 +47,8 @@ const CustomerDetails = memo(({ customer, locale, setShowCompliance }) => {
<div className={classes.name}> <div className={classes.name}>
<IdIcon className={classes.idIcon} /> <IdIcon className={classes.idIcon} />
<H2 noMargin> <H2 noMargin>
{name.length {name.length ? name : R.path(['phone'])(customer)}
? name {/* getFormattedPhone(R.path(['phone'])(customer), locale.country)} */}
: getFormattedPhone(R.path(['phone'])(customer), locale.country)}
</H2> </H2>
<SubpageButton <SubpageButton
className={classes.subpageButton} className={classes.subpageButton}

View file

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