hof 19.14.13 → 19.14.16
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
const NotifyClient = require('notifications-node-client').NotifyClient;
|
3
|
-
const
|
3
|
+
const { v4: uuidv4 } = require('uuid');
|
4
4
|
|
5
5
|
module.exports = class Notify {
|
6
6
|
constructor(opts) {
|
@@ -11,7 +11,7 @@ module.exports = class Notify {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
send(email) {
|
14
|
-
const reference =
|
14
|
+
const reference = uuidv4();
|
15
15
|
|
16
16
|
return this.notifyClient.sendEmail(this.notifyTemplate, email.recipient, {
|
17
17
|
personalisation: {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "hof",
|
3
3
|
"description": "A bootstrap for HOF projects",
|
4
|
-
"version": "19.14.
|
4
|
+
"version": "19.14.16",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "index.js",
|
7
7
|
"author": "HomeOffice",
|
@@ -88,6 +88,7 @@
|
|
88
88
|
"uglify-js": "^3.14.3",
|
89
89
|
"underscore": "^1.12.1",
|
90
90
|
"urijs": "^1.19.11",
|
91
|
+
"uuid": "^8.3.2",
|
91
92
|
"winston": "^3.7.2"
|
92
93
|
},
|
93
94
|
"devDependencies": {
|
@@ -28,6 +28,41 @@ module.exports = (route, controller, steps, begin) => {
|
|
28
28
|
return _.uniq(allSteps);
|
29
29
|
};
|
30
30
|
|
31
|
+
// Gets all the possible routes
|
32
|
+
const walkAllPossibleSteps = (stepName, allStepsInService, allVisitedSteps) => {
|
33
|
+
const stepIncludingFieldsAndForks = allStepsInService[stepName];
|
34
|
+
if (!stepIncludingFieldsAndForks) { return; }
|
35
|
+
|
36
|
+
const forkTargets = _.map(stepIncludingFieldsAndForks.forks, 'target') || [];
|
37
|
+
const nextStep = stepIncludingFieldsAndForks.next || '';
|
38
|
+
|
39
|
+
// If there is no next step or fork, then we have reached the end of the journey
|
40
|
+
if (!forkTargets.length && !nextStep) {
|
41
|
+
allVisitedSteps.push(stepName);
|
42
|
+
// eslint-disable-next-line consistent-return
|
43
|
+
return _.uniq(allVisitedSteps);
|
44
|
+
}
|
45
|
+
|
46
|
+
const nextStepsAndForks = _.uniq(forkTargets.concat(nextStep));
|
47
|
+
|
48
|
+
// We need to transverse through all 'Next' and 'Forks' for this route
|
49
|
+
nextStepsAndForks.map(each => {
|
50
|
+
if (!allVisitedSteps.includes(each)) {
|
51
|
+
allVisitedSteps.push(each);
|
52
|
+
walkAllPossibleSteps(each, allStepsInService, allVisitedSteps);
|
53
|
+
}
|
54
|
+
});
|
55
|
+
};
|
56
|
+
|
57
|
+
// Create a list of all visited steps
|
58
|
+
const createAllVisitedSteps = (stepName, allStepsInService) => {
|
59
|
+
const allVisitedSteps = [stepName];
|
60
|
+
if (allStepsInService[stepName]) {
|
61
|
+
walkAllPossibleSteps(stepName, allStepsInService, allVisitedSteps);
|
62
|
+
}
|
63
|
+
return _.uniq(allVisitedSteps);
|
64
|
+
};
|
65
|
+
|
31
66
|
const invalidateStep = (stepName, scopedSteps, sessionModel) => {
|
32
67
|
debug('Invalidating', stepName);
|
33
68
|
const step = scopedSteps[stepName] || {};
|
@@ -55,7 +90,7 @@ module.exports = (route, controller, steps, begin) => {
|
|
55
90
|
debug('next', nextStep);
|
56
91
|
debug('potential paths', potentialPaths);
|
57
92
|
// if we're following a loop then allow the loop to be invalidated
|
58
|
-
const whitelist = isLoop(nextStep, req.path) ? [route] :
|
93
|
+
const whitelist = isLoop(nextStep, req.path) ? [route] : createAllVisitedSteps(nextStep, steps);
|
59
94
|
// aggregate all potential journeys from the invalidating step
|
60
95
|
const invalidateSteps = potentialPaths.reduce((arr, step) => arr.concat(getAllPossibleSteps(step, steps)), []);
|
61
96
|
|