mirror of
https://github.com/docmost/docmost.git
synced 2026-05-17 06:44:05 +08:00
@@ -4,6 +4,7 @@ import {
|
||||
ForbiddenException,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
NotFoundException,
|
||||
Post,
|
||||
Res,
|
||||
@@ -24,8 +25,13 @@ import {
|
||||
import { FastifyReply } from 'fastify';
|
||||
import { sanitize } from 'sanitize-filename-ts';
|
||||
import { getExportExtension } from './utils';
|
||||
import { getMimeType } from '../../common/helpers';
|
||||
import { getMimeType, getPageTitle } from '../../common/helpers';
|
||||
import * as path from 'path';
|
||||
import { AuditEvent, AuditResource } from '../../common/events/audit-events';
|
||||
import {
|
||||
AUDIT_SERVICE,
|
||||
IAuditService,
|
||||
} from '../../integrations/audit/audit.service';
|
||||
|
||||
@Controller()
|
||||
export class ExportController {
|
||||
@@ -34,6 +40,7 @@ export class ExportController {
|
||||
private readonly pageRepo: PageRepo,
|
||||
private readonly spaceAbility: SpaceAbilityFactory,
|
||||
private readonly pageAccessService: PageAccessService,
|
||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||
) {}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@@ -62,6 +69,20 @@ export class ExportController {
|
||||
user.id,
|
||||
);
|
||||
|
||||
this.auditService.log({
|
||||
event: AuditEvent.PAGE_EXPORTED,
|
||||
resourceType: AuditResource.PAGE,
|
||||
resourceId: page.id,
|
||||
spaceId: page.spaceId,
|
||||
metadata: {
|
||||
title: getPageTitle(page.title),
|
||||
format: dto.format,
|
||||
includeChildren: dto.includeChildren,
|
||||
includeAttachments: dto.includeAttachments,
|
||||
spaceId: page.spaceId,
|
||||
},
|
||||
});
|
||||
|
||||
const fileName = sanitize(page.title || 'untitled') + '.zip';
|
||||
|
||||
res.headers({
|
||||
@@ -93,6 +114,18 @@ export class ExportController {
|
||||
user.id,
|
||||
);
|
||||
|
||||
this.auditService.log({
|
||||
event: AuditEvent.SPACE_EXPORTED,
|
||||
resourceType: AuditResource.SPACE,
|
||||
resourceId: dto.spaceId,
|
||||
spaceId: dto.spaceId,
|
||||
metadata: {
|
||||
format: dto.format,
|
||||
includeAttachments: dto.includeAttachments ?? false,
|
||||
spaceName: exportFile.spaceName,
|
||||
},
|
||||
});
|
||||
|
||||
res.headers({
|
||||
'Content-Type': 'application/zip',
|
||||
'Content-Disposition':
|
||||
|
||||
Reference in New Issue
Block a user