chore: remove ekata feature

This commit is contained in:
Rafael Taranto 2025-05-12 09:24:35 +01:00
parent 8b3f93d8f0
commit c593b60a4e
12 changed files with 8 additions and 184 deletions

View file

@ -137,12 +137,6 @@ async function updateCustomer (id, data, userToken) {
await db.none(sql, [id]) await db.none(sql, [id])
} }
if (data.subscriberInfo) {
await Promise.all([getCustomerById(id), settingsLoader.loadLatest()])
.then(([customer, config]) => sms.getLookup(config, customer.phone))
.then(res => updateSubscriberData(id, res, userToken))
.catch(logger.error)
}
invalidateCustomerNotifications(id, formattedData) invalidateCustomerNotifications(id, formattedData)
return getCustomerById(id) return getCustomerById(id)
} }

View file

@ -68,7 +68,6 @@ const typeDef = gql`
lastTxFiatCode: String lastTxFiatCode: String
lastTxClass: String lastTxClass: String
suspendedUntil: DateTimeISO suspendedUntil: DateTimeISO
subscriberInfo: Boolean
phoneOverride: String phoneOverride: String
} }

View file

@ -40,12 +40,7 @@ function sendMessage (account, rec) {
}) })
} }
function getLookup () {
throw new Error('inforu error: lookup not supported')
}
module.exports = { module.exports = {
NAME, NAME,
sendMessage, sendMessage
getLookup
} }

View file

@ -2,17 +2,6 @@ const _ = require('lodash/fp')
const NAME = 'MockSMS' const NAME = 'MockSMS'
function getLookup (account, number) {
console.log('Looking up number: %j', number)
return new Promise((resolve, reject) => {
if (_.endsWith('666', number)) {
reject (new Error(`${exports.NAME} mocked error!`))
} else {
setTimeout(resolve, 1)
}
})
}
function sendMessage (account, rec) { function sendMessage (account, rec) {
console.log('Sending SMS: %j', rec) console.log('Sending SMS: %j', rec)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -26,6 +15,5 @@ function sendMessage (account, rec) {
module.exports = { module.exports = {
NAME, NAME,
sendMessage, sendMessage
getLookup
} }

View file

@ -15,13 +15,7 @@ function sendMessage (account, rec) {
}) })
} }
function getLookup () {
throw new Error('Telnyx error: lookup not supported')
}
module.exports = { module.exports = {
NAME, NAME,
sendMessage, sendMessage
getLookup
} }

View file

@ -37,33 +37,7 @@ function sendMessage (account, rec) {
}) })
} }
function getLookup (account, number) {
return Promise.resolve()
.then(() => {
const client = twilio(account.accountSid, account.authToken)
return client.lookups.v1.phoneNumbers(number)
.fetch({ addOns: ['lamassu_ekata'] })
})
.then(info => info.addOns.results['lamassu_ekata'])
.then(info => {
if (info.status !== 'successful') {
throw new Error(`Twilio error: ${info.message}`)
}
return info
})
.catch(err => {
if (_.includes(err.code, BAD_NUMBER_CODES)) {
const badNumberError = new Error(err.message)
badNumberError.name = 'BadNumberError'
throw badNumberError
}
throw new Error(`Twilio error: ${err.message}`)
})
}
module.exports = { module.exports = {
NAME, NAME,
sendMessage, sendMessage
getLookup
} }

View file

@ -20,12 +20,7 @@ function sendMessage (account, rec) {
}) })
} }
function getLookup () {
throw new Error('Vonage error: lookup not supported')
}
module.exports = { module.exports = {
NAME, NAME,
sendMessage, sendMessage,
getLookup
} }

View file

@ -36,12 +36,7 @@ function sendMessage (account, rec) {
}) })
} }
function getLookup () {
throw new Error('Whatsapp error: lookup not supported')
}
module.exports = { module.exports = {
NAME, NAME,
sendMessage, sendMessage
getLookup
} }

View file

@ -37,13 +37,6 @@ function sendMessage (settings, rec) {
}) })
} }
function getLookup (settings, number) {
return Promise.resolve()
.then(() => {
const { plugin, account } = getPlugin(settings)
return plugin.getLookup(account, number)
})
}
const toCryptoUnits = (cryptoAtoms, cryptoCode) => { const toCryptoUnits = (cryptoAtoms, cryptoCode) => {
const unitScale = coinUtils.getCryptoCurrency(cryptoCode).unitScale const unitScale = coinUtils.getCryptoCurrency(cryptoCode).unitScale
return cryptoAtoms.shiftedBy(-unitScale) return cryptoAtoms.shiftedBy(-unitScale)
@ -117,7 +110,6 @@ function formatSmsReceipt (data, options) {
module.exports = { module.exports = {
getSms, getSms,
sendMessage, sendMessage,
getLookup,
formatSmsReceipt, formatSmsReceipt,
toCryptoUnits toCryptoUnits
} }

View file

@ -50,8 +50,6 @@ const CustomerData = ({
updateCustomRequest, updateCustomRequest,
authorizeCustomRequest, authorizeCustomRequest,
updateCustomEntry, updateCustomEntry,
retrieveAdditionalDataDialog,
setRetrieve,
checkAgainstSanctions checkAgainstSanctions
}) => { }) => {
const [previewPhoto, setPreviewPhoto] = useState(null) const [previewPhoto, setPreviewPhoto] = useState(null)
@ -176,7 +174,6 @@ const CustomerData = ({
}) })
}, },
validationSchema: smsDataSchema.smsData, validationSchema: smsDataSchema.smsData,
retrieveAdditionalData: () => setRetrieve(true),
initialValues: initialValues.smsData, initialValues: initialValues.smsData,
isAvailable: !R.isNil(phone), isAvailable: !R.isNil(phone),
hasAdditionalData: !R.isNil(smsData) && !R.isEmpty(smsData), hasAdditionalData: !R.isNil(smsData) && !R.isEmpty(smsData),
@ -440,7 +437,6 @@ const CustomerData = ({
save, save,
cancel, cancel,
deleteEditedData, deleteEditedData,
retrieveAdditionalData,
children, children,
validationSchema, validationSchema,
initialValues, initialValues,
@ -468,7 +464,6 @@ const CustomerData = ({
save={save} save={save}
cancel={cancel} cancel={cancel}
deleteEditedData={deleteEditedData} deleteEditedData={deleteEditedData}
retrieveAdditionalData={retrieveAdditionalData}
checkAgainstSanctions={checkAgainstSanctions} checkAgainstSanctions={checkAgainstSanctions}
editable={editable}> editable={editable}>
{children} {children}
@ -546,7 +541,6 @@ const CustomerData = ({
</div> </div>
)} )}
</div> </div>
{retrieveAdditionalDataDialog}
</div> </div>
) )
} }

View file

@ -1,18 +1,11 @@
import IconButton from '@mui/material/IconButton'
import SvgIcon from '@mui/material/SvgIcon'
import { useQuery, useMutation, useLazyQuery, gql } from '@apollo/client' import { useQuery, useMutation, useLazyQuery, gql } from '@apollo/client'
import Breadcrumbs from '@mui/material/Breadcrumbs' import Breadcrumbs from '@mui/material/Breadcrumbs'
import DialogActions from '@mui/material/DialogActions'
import DialogContent from '@mui/material/DialogContent'
import Dialog from '@mui/material/Dialog'
import Switch from '@mui/material/Switch' import Switch from '@mui/material/Switch'
import NavigateNextIcon from '@mui/icons-material/NavigateNext' import NavigateNextIcon from '@mui/icons-material/NavigateNext'
import * as R from 'ramda' import * as R from 'ramda'
import React, { memo, useState } from 'react' import React, { memo, useState } from 'react'
import { useHistory, useParams } from 'react-router-dom' import { useHistory, useParams } from 'react-router-dom'
import ErrorMessage from 'src/components/ErrorMessage' import { Label1, Label2 } from 'src/components/typography'
import { Label1, Label2, H2, Info3 } from 'src/components/typography'
import CloseIcon from 'src/styling/icons/action/close/zodiac.svg?react'
import AuthorizeReversedIcon from 'src/styling/icons/button/authorize/white.svg?react' import AuthorizeReversedIcon from 'src/styling/icons/button/authorize/white.svg?react'
import AuthorizeIcon from 'src/styling/icons/button/authorize/zodiac.svg?react' import AuthorizeIcon from 'src/styling/icons/button/authorize/zodiac.svg?react'
import BlockReversedIcon from 'src/styling/icons/button/block/white.svg?react' import BlockReversedIcon from 'src/styling/icons/button/block/white.svg?react'
@ -20,7 +13,7 @@ import BlockIcon from 'src/styling/icons/button/block/zodiac.svg?react'
import DataReversedIcon from 'src/styling/icons/button/data/white.svg?react' import DataReversedIcon from 'src/styling/icons/button/data/white.svg?react'
import DataIcon from 'src/styling/icons/button/data/zodiac.svg?react' import DataIcon from 'src/styling/icons/button/data/zodiac.svg?react'
import { Button, ActionButton } from 'src/components/buttons' import { ActionButton } from 'src/components/buttons'
import { import {
OVERRIDE_AUTHORIZED, OVERRIDE_AUTHORIZED,
OVERRIDE_REJECTED OVERRIDE_REJECTED
@ -147,7 +140,6 @@ const SET_CUSTOMER = gql`
lastTxFiat lastTxFiat
lastTxFiatCode lastTxFiatCode
lastTxClass lastTxClass
subscriberInfo
phoneOverride phoneOverride
externalCompliance externalCompliance
} }
@ -297,7 +289,6 @@ const CHECK_AGAINST_SANCTIONS = gql`
const CustomerProfile = memo(() => { const CustomerProfile = memo(() => {
const history = useHistory() const history = useHistory()
const [retrieve, setRetrieve] = useState(false)
const [showCompliance, setShowCompliance] = useState(false) const [showCompliance, setShowCompliance] = useState(false)
const [wizard, setWizard] = useState(false) const [wizard, setWizard] = useState(false)
const [error, setError] = useState(null) const [error, setError] = useState(null)
@ -343,7 +334,6 @@ const CustomerProfile = memo(() => {
const [setCustomer] = useMutation(SET_CUSTOMER, { const [setCustomer] = useMutation(SET_CUSTOMER, {
onCompleted: () => { onCompleted: () => {
getCustomer() getCustomer()
setRetrieve(false)
}, },
onError: error => setError(error) onError: error => setError(error)
}) })
@ -467,16 +457,6 @@ const CustomerProfile = memo(() => {
} }
}) })
const retrieveAdditionalData = () =>
setCustomer({
variables: {
customerId,
customerInput: {
subscriberInfo: true
}
}
})
const onClickSidebarItem = code => setClickedItem(code) const onClickSidebarItem = code => setClickedItem(code)
const configData = R.path(['config'])(customerResponse) ?? [] const configData = R.path(['config'])(customerResponse) ?? []
@ -664,21 +644,8 @@ const CustomerProfile = memo(() => {
updateCustomRequest={setCustomerCustomInfoRequest} updateCustomRequest={setCustomerCustomInfoRequest}
authorizeCustomRequest={authorizeCustomRequest} authorizeCustomRequest={authorizeCustomRequest}
updateCustomEntry={updateCustomEntry} updateCustomEntry={updateCustomEntry}
setRetrieve={setRetrieve}
checkAgainstSanctions={checkAgainstSanctions} checkAgainstSanctions={checkAgainstSanctions}
retrieveAdditionalDataDialog={ />
<RetrieveDataDialog
onDismissed={() => {
setError(null)
setRetrieve(false)
}}
onConfirmed={() => {
setError(null)
retrieveAdditionalData()
}}
error={error}
open={retrieve}></RetrieveDataDialog>
}></CustomerData>
</div> </div>
)} )}
{isNotes && ( {isNotes && (
@ -715,55 +682,4 @@ const CustomerProfile = memo(() => {
) )
}) })
const RetrieveDataDialog = ({
onConfirmed,
onDismissed,
open,
error,
props
}) => {
return (
<Dialog
open={open}
aria-labelledby="form-dialog-title"
PaperProps={{
style: {
borderRadius: 8,
minWidth: 656,
bottom: 125,
right: 7
}
}}
{...props}>
<div className="pt-4 pr-4 flex justify-end">
<IconButton aria-label="close" onClick={() => onDismissed(false)}>
<SvgIcon>
<CloseIcon />
</SvgIcon>
</IconButton>
</div>
<H2 className="mb-2 ml-10">{'Retrieve API data from Twilio'}</H2>
<DialogContent className="w-153 ml-4">
<Info3>{`With this action you'll be using Twilio's API to retrieve additional
data from this user. This includes name and address, if available.\n`}</Info3>
<Info3>{` There is a small cost from Twilio for each retrieval. Would you like
to proceed?`}</Info3>
</DialogContent>
{error && (
<ErrorMessage className="ml-10">
Failed to fetch additional data
</ErrorMessage>
)}
<DialogActions className="p-8 pt-4 gap-2">
<Button
onClick={() => {
onConfirmed()
}}>
Confirm
</Button>
</DialogActions>
</Dialog>
)
}
export default CustomerProfile export default CustomerProfile

View file

@ -74,8 +74,6 @@ const EditableCard = ({
validationSchema, validationSchema,
initialValues, initialValues,
deleteEditedData, deleteEditedData,
retrieveAdditionalData,
hasAdditionalData = true,
editable, editable,
checkAgainstSanctions checkAgainstSanctions
}) => { }) => {
@ -168,16 +166,6 @@ const EditableCard = ({
<div className="flex justify-end mt-5 gap-2"> <div className="flex justify-end mt-5 gap-2">
{!editing && ( {!editing && (
<> <>
{!hasAdditionalData && (
<ActionButton
color="primary"
type="button"
Icon={DataIcon}
InverseIcon={DataReversedIcon}
onClick={() => retrieveAdditionalData()}>
Retrieve API data
</ActionButton>
)}
{checkAgainstSanctions && ( {checkAgainstSanctions && (
<ActionButton <ActionButton
color="primary" color="primary"