Skip to content

Commit

Permalink
Merge pull request #160 from UKForeignOffice/feature/orbit-webhook
Browse files Browse the repository at this point in the history
Send case team emails as fallback for Orbit
  • Loading branch information
Paris authored Dec 20, 2024
2 parents 5efa567 + 1e177ff commit 60c006c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions api/src/middlewares/services/SubmitService/SubmitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class SubmitService {
const formFields = flattenQuestions(questions);
const answers = answersHashMap(formFields);
const { pay, type } = metadata;
const reference = metadata?.pay?.reference ?? this.generateId();
const reference = metadata?.externalReference ?? metadata?.internalReference ?? metadata?.pay?.reference ?? this.generateId();
const caseServiceName = getCaseServiceName(type);
if (pay) {
pay.total = fees?.total;
Expand All @@ -61,8 +61,12 @@ export class SubmitService {
type,
metadata,
});
const caseProcessJob = await caseService.sendToProcessQueue(processQueueData);
this.logger.info({ reference, caseProcessJob }, `SES_PROCESS job queued successfully for ${reference}`);

// only email case team when there is no external reference (i.e. from Orbit) indicating a submission failure there
if (!metadata?.externalReference) {
const caseProcessJob = await caseService.sendToProcessQueue(processQueueData);
this.logger.info({reference, caseProcessJob}, `SES_PROCESS job queued successfully for ${reference}`);
}

const userProcessJob = await this.userService.sendToProcessQueue(answers, { reference, payment: metadata.pay, type, postal: metadata.postal });

Expand Down
2 changes: 1 addition & 1 deletion api/src/middlewares/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const questionSchema = joi.object().keys({
const webhookOutputSchema = joi.object().keys({
name: joi.string().required(),
questions: joi.array().items(questionSchema).required(),
fees: joi.object().optional(),
fees: joi.object().optional().allow(null),
metadata: joi.object({
pay: joi
.object({
Expand Down

0 comments on commit 60c006c

Please sign in to comment.