Chore: fiatBalancesNotify refactor Chore: removed now-unused code in some files Feat: change column "detail" in database to use jsonb Chore: add notification center background and button Chore: notifications screen scaffolding Fix: change position of notification UI Feat: join backend and frontend Feat: notification icons and machine names Feat: add clear all button, stripe overlay on invalid notification Fix: rework notification styles Feat: use popper to render notifications Feat: make notification center UI Fix: fix css on notification center Fix: fix invalidateNotification Chore: apply PR requested changes Fix: PR fixes Fix: make toggleable body/root styles be handled by react Chore: delete old notifier file Fix: undo variable name changes for cryptobalance notifs
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
const db = require('./db')
|
|
const notifier = require('./notifier')
|
|
|
|
// Get all blacklist rows from the DB "blacklist" table that were manually inserted by the operator
|
|
const getBlacklist = () => {
|
|
return db.any(`SELECT * FROM blacklist WHERE created_by_operator = 't'`).then(res =>
|
|
res.map(item => ({
|
|
cryptoCode: item.crypto_code,
|
|
address: item.address,
|
|
createdByOperator: item.created_by_operator
|
|
}))
|
|
)
|
|
}
|
|
|
|
// Delete row from blacklist table by crypto code and address
|
|
const deleteFromBlacklist = (cryptoCode, address) => {
|
|
const sql = `DELETE FROM blacklist WHERE crypto_code = $1 AND address = $2`
|
|
notifier.clearBlacklistNotification(cryptoCode, address)
|
|
return db.none(sql, [cryptoCode, address])
|
|
}
|
|
|
|
const insertIntoBlacklist = (cryptoCode, address) => {
|
|
return db
|
|
.none(
|
|
'insert into blacklist(crypto_code, address, created_by_operator) values($1, $2, $3);',
|
|
[cryptoCode, address, true]
|
|
)
|
|
}
|
|
|
|
function blocked (address, cryptoCode) {
|
|
const sql = `select * from blacklist where address = $1 and crypto_code = $2`
|
|
return db.any(sql, [address, cryptoCode])
|
|
}
|
|
|
|
function addToUsedAddresses (address, cryptoCode) {
|
|
// ETH reuses addresses
|
|
if (cryptoCode === 'ETH') return Promise.resolve()
|
|
|
|
const sql = `insert into blacklist(crypto_code, address, created_by_operator) values ($1, $2, 'f')`
|
|
return db.oneOrNone(sql, [cryptoCode, address])
|
|
}
|
|
|
|
module.exports = {
|
|
blocked,
|
|
addToUsedAddresses,
|
|
getBlacklist,
|
|
deleteFromBlacklist,
|
|
insertIntoBlacklist
|
|
}
|