From b5472528d337eecac4ec9fd929803726c357492f Mon Sep 17 00:00:00 2001 From: Andrew Lee <1517745+andrewrlee@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:46:39 +0000 Subject: [PATCH] CVSL-1606 Adding logging when prison staff modify conditions (#1522) --- server/routes/conditions.ts | 8 +++++++- server/services/licenceService.ts | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/routes/conditions.ts b/server/routes/conditions.ts index c23fb655d..08c1b3fad 100644 --- a/server/routes/conditions.ts +++ b/server/routes/conditions.ts @@ -107,12 +107,16 @@ export default ({ const additional = additionalConditions ? conditionsService.formatConditionInputs(req.body) : {} const newConditionsObject = conditionsService.createConditionsObjectForLicence(additional, bespoke) - await licenceService.updateLicenceConditions( + const updateOccurred = await licenceService.updateLicenceConditions( bookingId, res.locals.licence, newConditionsObject, res.locals.postRelease ) + if (updateOccurred) { + const { username, role } = req.user + logger.info(`conditions - updated conditions - ${username} - ${role} - ${bookingId}`) + } const newVersion = conditionsServiceFactory.getNewVersion(res.locals.licence) @@ -157,6 +161,8 @@ export default ({ const { action } = req.params if (conditionId) { + const { username, role } = req.user + logger.info(`conditions - delete condition - ${username} - ${role} - ${bookingId}`) await licenceService.deleteLicenceCondition(bookingId, res.locals.licence, conditionId) } diff --git a/server/services/licenceService.ts b/server/services/licenceService.ts index 85a088c8a..1795e57c4 100644 --- a/server/services/licenceService.ts +++ b/server/services/licenceService.ts @@ -167,12 +167,12 @@ export class LicenceService { const licenceConditions = { ...existingLicenceConditions, ...newConditionsObject } if (equals(existingLicenceConditions, licenceConditions)) { - return null + return false } - await this.updateModificationStage(bookingId, existingLicence.stage, { requiresApproval: true }) - return await this.licenceClient.updateSection('licenceConditions', bookingId, licenceConditions, postRelease) + await this.licenceClient.updateSection('licenceConditions', bookingId, licenceConditions, postRelease) + return true } catch (error) { logger.error('Error during updateAdditionalConditions', error.stack) throw error