Skip to content

Commit 2dcf733

Browse files
authored
fix: use yazl for member export data (#1911)
* fix: use yazl for member export data * refactor: apply PR requested changes
1 parent 3e29d47 commit 2dcf733

7 files changed

Lines changed: 200 additions & 484 deletions

File tree

src/plugins/swagger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default async function (instance: FastifyInstance): Promise<void> {
2424
{ name: 'current', description: 'Endpoints related to current user' },
2525
{ name: 'email', description: 'Endpoints related to management of emails' },
2626
{ name: 'etherpad', description: 'Endpoints related to etherpad' },
27-
{ name: 'export', description: 'Endpoints related to exporting and downloading items' },
27+
{ name: 'export', description: 'Endpoints related to exporting and downloading data' },
2828
{ name: 'favorite', description: 'Endpoints related to bookmarked items' },
2929
{ name: 'file', description: 'Endpoints related to file management' },
3030
{

src/services/member/plugins/export-data/memberExportData.controller.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ const plugin: FastifyPluginAsync = async (fastify) => {
3131
assertIsMember(authedUser);
3232
// get member info such as email and lang
3333
const member = await memberRepository.get(db, authedUser.id);
34-
db.transaction(async (tx) => {
35-
await exportMemberDataService.requestDataExport(tx, member.toMemberInfo());
36-
});
3734

3835
// reply no content and let the server create the archive and send the mail
3936
reply.status(StatusCodes.NO_CONTENT);
37+
38+
// TODO: add in queue
39+
await db.transaction(async (tx) => {
40+
await exportMemberDataService.createArchiveAndSendByEmail(tx, member.toMemberInfo());
41+
});
4042
},
4143
);
4244
},

src/services/member/plugins/export-data/memberExportData.schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import {
1616

1717
export const exportMemberData = {
1818
operationId: 'exportMemberData',
19-
tags: ['member'],
19+
tags: ['member', 'export'],
2020
summary: 'Request all related data of authenticated member',
2121
description:
2222
'Request a download link to have access to all data related to the authenticated user. The link is valid for one week.',
2323

2424
response: {
25-
[StatusCodes.NO_CONTENT]: Type.Null(),
25+
[StatusCodes.NO_CONTENT]: Type.Null({ description: 'Successful Response' }),
2626
'4xx': errorSchemaRef,
2727
},
2828
};

src/services/member/plugins/export-data/memberExportData.service.test.ts

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)