Signed file follow up (#12347)

This commit is contained in:
martmull
2025-05-28 13:02:27 +02:00
committed by GitHub
parent d4fac6793a
commit 69831b17ff
11 changed files with 58 additions and 119 deletions

View File

@ -1,12 +1,9 @@
import { buildSignedPath } from 'twenty-shared/utils';
import { QueryResultGetterHandlerInterface } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-getter-handler.interface';
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
import { FileService } from 'src/engine/core-modules/file/services/file.service';
import { NoteWorkspaceEntity } from 'src/modules/note/standard-objects/note.workspace-entity';
import { TaskWorkspaceEntity } from 'src/modules/task/standard-objects/task.workspace-entity';
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type RichTextBlock = Record<string, any>;
@ -57,19 +54,16 @@ export class ActivityQueryResultGetterHandler
imageUrl.searchParams.delete('token');
const signedPayload = this.fileService.encodeFileToken({
filename: extractFilenameFromPath(imageProps.url),
workspaceId: workspaceId,
const signedPath = this.fileService.signFileUrl({
url: imageProps.url.toString(),
workspaceId,
});
return {
...block,
props: {
...imageProps,
url: buildSignedPath({
path: imageUrl.toString(),
token: signedPayload,
}),
url: signedPath,
},
};
}),

View File

@ -1,10 +1,7 @@
import { buildSignedPath } from 'twenty-shared/utils';
import { QueryResultGetterHandlerInterface } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-getter-handler.interface';
import { FileService } from 'src/engine/core-modules/file/services/file.service';
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
export class AttachmentQueryResultGetterHandler
implements QueryResultGetterHandlerInterface
@ -19,14 +16,9 @@ export class AttachmentQueryResultGetterHandler
return attachment;
}
const signedPayload = this.fileService.encodeFileToken({
filename: extractFilenameFromPath(attachment.fullPath),
workspaceId: workspaceId,
});
const signedPath = buildSignedPath({
path: attachment.fullPath,
token: signedPayload,
const signedPath = this.fileService.signFileUrl({
url: attachment.fullPath,
workspaceId,
});
const fullPath = `${process.env.SERVER_URL}/files/${signedPath}`;

View File

@ -1,10 +1,7 @@
import { buildSignedPath } from 'twenty-shared/utils';
import { QueryResultGetterHandlerInterface } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-getter-handler.interface';
import { FileService } from 'src/engine/core-modules/file/services/file.service';
import { PersonWorkspaceEntity } from 'src/modules/person/standard-objects/person.workspace-entity';
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
export class PersonQueryResultGetterHandler
implements QueryResultGetterHandlerInterface
@ -19,17 +16,14 @@ export class PersonQueryResultGetterHandler
return person;
}
const signedPayload = this.fileService.encodeFileToken({
filename: extractFilenameFromPath(person.avatarUrl),
const signedPath = this.fileService.signFileUrl({
url: person.avatarUrl,
workspaceId,
});
return {
...person,
avatarUrl: buildSignedPath({
path: person.avatarUrl,
token: signedPayload,
}),
avatarUrl: signedPath,
};
}
}

View File

@ -1,10 +1,7 @@
import { buildSignedPath } from 'twenty-shared/utils';
import { QueryResultGetterHandlerInterface } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/interfaces/query-result-getter-handler.interface';
import { FileService } from 'src/engine/core-modules/file/services/file.service';
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
export class WorkspaceMemberQueryResultGetterHandler
implements QueryResultGetterHandlerInterface
@ -19,17 +16,14 @@ export class WorkspaceMemberQueryResultGetterHandler
return workspaceMember;
}
const signedPayload = this.fileService.encodeFileToken({
filename: extractFilenameFromPath(workspaceMember.avatarUrl),
const signedPath = this.fileService.signFileUrl({
url: workspaceMember.avatarUrl,
workspaceId,
});
return {
...workspaceMember,
avatarUrl: buildSignedPath({
path: workspaceMember.avatarUrl,
token: signedPayload,
}),
avatarUrl: signedPath,
};
}
}