fix: remove logs and change route

This commit is contained in:
José Oliveira 2021-06-29 09:31:20 +01:00 committed by Josh Harvey
parent c7d56c8110
commit 2f0ca0ab26
2 changed files with 3 additions and 8 deletions

View file

@ -584,19 +584,14 @@ function updatePhotos (imagesData, id, dir) {
} }
const newPatch = {} const newPatch = {}
// i.e. ../<lamassu-server-home>/<operatorid>/<customerid>/idcarddata // i.e. ../<lamassu-server-home>/<operatorid>/<customerid>/idcarddata
console.log(dir, 'directoryyyy')
const dirname = path.join(dir) const dirname = path.join(dir)
console.log(dirname, 'dirnaaaaaaaaaaaaaaame')
// create the directory tree if needed // create the directory tree if needed
_.attempt(() => makeDir.sync(dirname)) _.attempt(() => makeDir.sync(dirname))
const promises = imagesData.map((imageData, index) => { const promises = imagesData.map((imageData, index) => {
console.log(index)
// decode the base64 string to binary data // decode the base64 string to binary data
const decodedImageData = Buffer.from(imageData, 'base64') const decodedImageData = Buffer.from(imageData, 'base64')
// i.e. ../<lamassu-server-home>/<operatorid>/<customerid>/idcarddata/1.jpg // i.e. ../<lamassu-server-home>/<operatorid>/<customerid>/idcarddata/1.jpg
const filename = path.join(dirname, index + '.jpg') const filename = path.join(dirname, index + '.jpg')
return writeFile(filename, decodedImageData) return writeFile(filename, decodedImageData)
}) })
@ -617,8 +612,8 @@ function updatePhotos (imagesData, id, dir) {
function updateIdCardData (patch, id) { function updateIdCardData (patch, id) {
/* TODO: fetch operator id */ /* TODO: fetch operator id */
const operatorId = 'id-operator' const operatorId = 'id-operator'
const directory = operatorDataDir + '/' + operatorId + '/' + id + '/' const directory = `${operatorDataDir}/${operatorId}/${id}/`
console.log(directory)
return Promise.resolve(patch) return Promise.resolve(patch)
.then(patch => { .then(patch => {
const imagesData = _.get('photos', patch) const imagesData = _.get('photos', patch)

View file

@ -103,6 +103,6 @@ router.patch('/:id', updateCustomer)
router.patch('/:id/sanctions', triggerSanctions) router.patch('/:id/sanctions', triggerSanctions)
router.patch('/:id/block', triggerBlock) router.patch('/:id/block', triggerBlock)
router.patch('/:id/suspend', triggerSuspend) router.patch('/:id/suspend', triggerSuspend)
router.patch('/:id/dataphotos', updateIdCardData) router.patch('/:id/photos/idcarddata', updateIdCardData)
module.exports = router module.exports = router