Skip to content

Commit

Permalink
chore: rename export zip to {flow-slug}-{session-id}.zip (#2893)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Mar 15, 2024
1 parent 7c0602c commit c8acf02
Show file tree
Hide file tree
Showing 16 changed files with 972 additions and 762 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ describe("Create payment send events webhook", () => {
data: {
passport: { data: {} },
breadcrumbs: {},
id: "flow-123",
},
flow: {
id: "flow-123",
slug: "apply-for-something",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const createPaymentSendEvents = async (
});
}

const publishedFlowData = await getMostRecentPublishedFlow(session.flowId);
const publishedFlowData = await getMostRecentPublishedFlow(session.flow.id);
if (!publishedFlowData) {
return next({
status: 400,
Expand All @@ -55,7 +55,7 @@ const createPaymentSendEvents = async (
).find(([_nodeId, nodeData]) => nodeData.type === ComponentType.Send);
const destinations: Destination[] = sendNode?.[1]?.data?.destinations;

let teamSlug = await getTeamSlugByFlowId(session.flowId);
let teamSlug = await getTeamSlugByFlowId(session.flow.id);
const eventPayload = { sessionId: payload.sessionId };

if (destinations.includes(Destination.BOPS)) {
Expand Down
11 changes: 6 additions & 5 deletions api.planx.uk/modules/send/utils/exportZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export async function buildSubmissionExportZip({
includeOneAppXML?: boolean;
includeDigitalPlanningJSON?: boolean;
}): Promise<ExportZip> {
// create zip
const zip = new ExportZip(sessionId);

// fetch session data
const sessionData = await $api.session.find(sessionId);
if (!sessionData) {
Expand All @@ -37,6 +34,10 @@ export async function buildSubmissionExportZip({
);
}
const passport = sessionData.data?.passport as IPassport;
const flowSlug = sessionData?.flow.slug;

// create zip
const zip = new ExportZip(sessionId, flowSlug);

// add OneApp XML to the zip
if (includeOneAppXML) {
Expand Down Expand Up @@ -199,11 +200,11 @@ export class ExportZip {
filename: string;
private tmpDir: string;

constructor(sessionId: string) {
constructor(sessionId: string, flowSlug: string) {
this.zip = new AdmZip();
// make a tmp directory to avoid file name collisions if simultaneous applications
this.tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), sessionId));
this.filename = path.join(__dirname, `ripa-test-${sessionId}.zip`);
this.filename = path.join(__dirname, `${flowSlug}-${sessionId}.zip`);
}

addFile({ name, buffer }: { name: string; buffer: Buffer }) {
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@airbrake/node": "^2.1.8",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#dab9c39",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#eda1e67",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1467.0",
Expand Down
Loading

0 comments on commit c8acf02

Please sign in to comment.