refactor: deduplicate addNotification() use
This commit is contained in:
parent
d2cdca701a
commit
ef7f3d519d
1 changed files with 3 additions and 5 deletions
|
|
@ -20,12 +20,10 @@ const { STALE, PING } = codes
|
||||||
const sanctionsNotify = (customer, phone) => {
|
const sanctionsNotify = (customer, phone) => {
|
||||||
const code = 'SANCTIONS'
|
const code = 'SANCTIONS'
|
||||||
const detailB = utils.buildDetail({ customerId: customer.id, code })
|
const detailB = utils.buildDetail({ customerId: customer.id, code })
|
||||||
|
const addNotif = phone =>
|
||||||
|
queries.addNotification(COMPLIANCE, `Blocked customer with phone ${phone} for being on the OFAC sanctions list`, detailB)
|
||||||
// if it's a new customer then phone comes as undefined
|
// if it's a new customer then phone comes as undefined
|
||||||
if (phone) {
|
return phone ? addNotif(phone) : customers.getById(customer.id).then(c => addNotif(c.phone))
|
||||||
return queries.addNotification(COMPLIANCE, `Blocked customer with phone ${phone} for being on the OFAC sanctions list`, detailB)
|
|
||||||
}
|
|
||||||
return customers.getById(customer.id).then(c => queries.addNotification(COMPLIANCE, `Blocked customer with phone ${c.phone} for being on the OFAC sanctions list`, detailB))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearOldCustomerSuspendedNotifications = (customerId, deviceId) => {
|
const clearOldCustomerSuspendedNotifications = (customerId, deviceId) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue