Signed file follow up (#12347)
This commit is contained in:
@ -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 { 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 { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
|
||||||
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { NoteWorkspaceEntity } from 'src/modules/note/standard-objects/note.workspace-entity';
|
import { NoteWorkspaceEntity } from 'src/modules/note/standard-objects/note.workspace-entity';
|
||||||
import { TaskWorkspaceEntity } from 'src/modules/task/standard-objects/task.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
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
type RichTextBlock = Record<string, any>;
|
type RichTextBlock = Record<string, any>;
|
||||||
@ -57,19 +54,16 @@ export class ActivityQueryResultGetterHandler
|
|||||||
|
|
||||||
imageUrl.searchParams.delete('token');
|
imageUrl.searchParams.delete('token');
|
||||||
|
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
const signedPath = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(imageProps.url),
|
url: imageProps.url.toString(),
|
||||||
workspaceId: workspaceId,
|
workspaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...block,
|
...block,
|
||||||
props: {
|
props: {
|
||||||
...imageProps,
|
...imageProps,
|
||||||
url: buildSignedPath({
|
url: signedPath,
|
||||||
path: imageUrl.toString(),
|
|
||||||
token: signedPayload,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -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 { 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 { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
|
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
|
export class AttachmentQueryResultGetterHandler
|
||||||
implements QueryResultGetterHandlerInterface
|
implements QueryResultGetterHandlerInterface
|
||||||
@ -19,14 +16,9 @@ export class AttachmentQueryResultGetterHandler
|
|||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
const signedPath = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(attachment.fullPath),
|
url: attachment.fullPath,
|
||||||
workspaceId: workspaceId,
|
workspaceId,
|
||||||
});
|
|
||||||
|
|
||||||
const signedPath = buildSignedPath({
|
|
||||||
path: attachment.fullPath,
|
|
||||||
token: signedPayload,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const fullPath = `${process.env.SERVER_URL}/files/${signedPath}`;
|
const fullPath = `${process.env.SERVER_URL}/files/${signedPath}`;
|
||||||
|
|||||||
@ -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 { 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 { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { PersonWorkspaceEntity } from 'src/modules/person/standard-objects/person.workspace-entity';
|
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
|
export class PersonQueryResultGetterHandler
|
||||||
implements QueryResultGetterHandlerInterface
|
implements QueryResultGetterHandlerInterface
|
||||||
@ -19,17 +16,14 @@ export class PersonQueryResultGetterHandler
|
|||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
const signedPath = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(person.avatarUrl),
|
url: person.avatarUrl,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...person,
|
...person,
|
||||||
avatarUrl: buildSignedPath({
|
avatarUrl: signedPath,
|
||||||
path: person.avatarUrl,
|
|
||||||
token: signedPayload,
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 { 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 { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
|
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
|
export class WorkspaceMemberQueryResultGetterHandler
|
||||||
implements QueryResultGetterHandlerInterface
|
implements QueryResultGetterHandlerInterface
|
||||||
@ -19,17 +16,14 @@ export class WorkspaceMemberQueryResultGetterHandler
|
|||||||
return workspaceMember;
|
return workspaceMember;
|
||||||
}
|
}
|
||||||
|
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
const signedPath = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspaceMember.avatarUrl),
|
url: workspaceMember.avatarUrl,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...workspaceMember,
|
...workspaceMember,
|
||||||
avatarUrl: buildSignedPath({
|
avatarUrl: signedPath,
|
||||||
path: workspaceMember.avatarUrl,
|
|
||||||
token: signedPayload,
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,13 @@ import { basename, dirname, extname } from 'path';
|
|||||||
import { Stream } from 'stream';
|
import { Stream } from 'stream';
|
||||||
|
|
||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
|
import { buildSignedPath } from 'twenty-shared/utils';
|
||||||
|
import { isNonEmptyString } from '@sniptt/guards';
|
||||||
|
|
||||||
import { FileStorageService } from 'src/engine/core-modules/file-storage/file-storage.service';
|
import { FileStorageService } from 'src/engine/core-modules/file-storage/file-storage.service';
|
||||||
import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service';
|
import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service';
|
||||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||||
|
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
|
||||||
|
|
||||||
export type FilePayloadToEncode = {
|
export type FilePayloadToEncode = {
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
@ -35,6 +38,20 @@ export class FileService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signFileUrl({ url, workspaceId }: { url: string; workspaceId: string }) {
|
||||||
|
if (!isNonEmptyString(url)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildSignedPath({
|
||||||
|
path: url,
|
||||||
|
token: this.encodeFileToken({
|
||||||
|
filename: extractFilenameFromPath(url),
|
||||||
|
workspaceId,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
encodeFileToken(payloadToEncode: FilePayloadToEncode) {
|
encodeFileToken(payloadToEncode: FilePayloadToEncode) {
|
||||||
const fileTokenExpiresIn = this.twentyConfigService.get(
|
const fileTokenExpiresIn = this.twentyConfigService.get(
|
||||||
'FILE_TOKEN_EXPIRES_IN',
|
'FILE_TOKEN_EXPIRES_IN',
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
|||||||
|
|
||||||
import { isNonEmptyString } from '@sniptt/guards';
|
import { isNonEmptyString } from '@sniptt/guards';
|
||||||
import { FieldMetadataType } from 'twenty-shared/types';
|
import { FieldMetadataType } from 'twenty-shared/types';
|
||||||
import { buildSignedPath, getLogoUrlFromDomainName } from 'twenty-shared/utils';
|
import { getLogoUrlFromDomainName } from 'twenty-shared/utils';
|
||||||
import { Brackets, ObjectLiteral } from 'typeorm';
|
import { Brackets, ObjectLiteral } from 'typeorm';
|
||||||
import chunk from 'lodash.chunk';
|
import chunk from 'lodash.chunk';
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ import { formatSearchTerms } from 'src/engine/core-modules/search/utils/format-s
|
|||||||
import { SearchArgs } from 'src/engine/core-modules/search/dtos/search-args';
|
import { SearchArgs } from 'src/engine/core-modules/search/dtos/search-args';
|
||||||
import { SearchResultConnectionDTO } from 'src/engine/core-modules/search/dtos/search-result-connection.dto';
|
import { SearchResultConnectionDTO } from 'src/engine/core-modules/search/dtos/search-result-connection.dto';
|
||||||
import { SearchResultEdgeDTO } from 'src/engine/core-modules/search/dtos/search-result-edge.dto';
|
import { SearchResultEdgeDTO } from 'src/engine/core-modules/search/dtos/search-result-edge.dto';
|
||||||
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
|
|
||||||
import { SearchRecordDTO } from 'src/engine/core-modules/search/dtos/search-record.dto';
|
import { SearchRecordDTO } from 'src/engine/core-modules/search/dtos/search-record.dto';
|
||||||
|
|
||||||
type LastRanks = { tsRankCD: number; tsRank: number };
|
type LastRanks = { tsRankCD: number; tsRank: number };
|
||||||
@ -366,15 +365,10 @@ export class SearchService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getImageUrlWithToken(avatarUrl: string, workspaceId: string): string {
|
private getImageUrlWithToken(avatarUrl: string, workspaceId: string): string {
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
return this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(avatarUrl),
|
url: avatarUrl,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return buildSignedPath({
|
|
||||||
path: avatarUrl,
|
|
||||||
token: signedPayload,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getImageIdentifierValue(
|
getImageIdentifierValue(
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
import { buildSignedPath } from 'twenty-shared/utils';
|
|
||||||
|
|
||||||
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { DeletedWorkspaceMember } from 'src/engine/core-modules/user/dtos/deleted-workspace-member.dto';
|
import { DeletedWorkspaceMember } from 'src/engine/core-modules/user/dtos/deleted-workspace-member.dto';
|
||||||
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
|
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';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DeletedWorkspaceMemberTranspiler {
|
export class DeletedWorkspaceMemberTranspiler {
|
||||||
@ -18,15 +15,10 @@ export class DeletedWorkspaceMemberTranspiler {
|
|||||||
workspaceMember: Pick<WorkspaceMemberWorkspaceEntity, 'avatarUrl' | 'id'>;
|
workspaceMember: Pick<WorkspaceMemberWorkspaceEntity, 'avatarUrl' | 'id'>;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
}): string {
|
}): string {
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
return this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspaceMember.avatarUrl),
|
url: workspaceMember.avatarUrl,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return buildSignedPath({
|
|
||||||
path: workspaceMember.avatarUrl,
|
|
||||||
token: signedPayload,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toDeletedWorkspaceMemberDto(
|
toDeletedWorkspaceMemberDto(
|
||||||
@ -40,15 +32,16 @@ export class DeletedWorkspaceMemberTranspiler {
|
|||||||
userEmail,
|
userEmail,
|
||||||
} = workspaceMember;
|
} = workspaceMember;
|
||||||
|
|
||||||
const avatarUrl = userWorkspaceId
|
const avatarUrl =
|
||||||
? this.generateSignedAvatarUrl({
|
userWorkspaceId && avatarUrlFromEntity
|
||||||
workspaceId: userWorkspaceId,
|
? this.generateSignedAvatarUrl({
|
||||||
workspaceMember: {
|
workspaceId: userWorkspaceId,
|
||||||
avatarUrl: avatarUrlFromEntity,
|
workspaceMember: {
|
||||||
id,
|
avatarUrl: avatarUrlFromEntity,
|
||||||
},
|
id,
|
||||||
})
|
},
|
||||||
: null;
|
})
|
||||||
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
|
|||||||
@ -14,7 +14,6 @@ import crypto from 'crypto';
|
|||||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||||
import { FileUpload, GraphQLUpload } from 'graphql-upload';
|
import { FileUpload, GraphQLUpload } from 'graphql-upload';
|
||||||
import { PermissionsOnAllObjectRecords } from 'twenty-shared/constants';
|
import { PermissionsOnAllObjectRecords } from 'twenty-shared/constants';
|
||||||
import { buildSignedPath } from 'twenty-shared/utils';
|
|
||||||
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
|
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
|
||||||
import { In, Repository } from 'typeorm';
|
import { In, Repository } from 'typeorm';
|
||||||
|
|
||||||
@ -31,7 +30,6 @@ import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/service
|
|||||||
import { SignedFileDTO } from 'src/engine/core-modules/file/file-upload/dtos/signed-file.dto';
|
import { SignedFileDTO } from 'src/engine/core-modules/file/file-upload/dtos/signed-file.dto';
|
||||||
import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
|
import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
|
||||||
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
|
|
||||||
import { OnboardingStatus } from 'src/engine/core-modules/onboarding/enums/onboarding-status.enum';
|
import { OnboardingStatus } from 'src/engine/core-modules/onboarding/enums/onboarding-status.enum';
|
||||||
import {
|
import {
|
||||||
OnboardingService,
|
OnboardingService,
|
||||||
@ -220,15 +218,10 @@ export class UserResolver {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (workspaceMember && workspaceMember.avatarUrl) {
|
if (workspaceMember && workspaceMember.avatarUrl) {
|
||||||
const avatarUrlToken = this.fileService.encodeFileToken({
|
workspaceMember.avatarUrl = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspaceMember.avatarUrl),
|
url: workspaceMember.avatarUrl,
|
||||||
workspaceId: workspace.id,
|
workspaceId: workspace.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
workspaceMember.avatarUrl = buildSignedPath({
|
|
||||||
path: workspaceMember.avatarUrl,
|
|
||||||
token: avatarUrlToken,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Refactor to be transpiled to WorkspaceMember instead
|
// TODO Refactor to be transpiled to WorkspaceMember instead
|
||||||
@ -272,15 +265,10 @@ export class UserResolver {
|
|||||||
|
|
||||||
for (const workspaceMemberEntity of workspaceMemberEntities) {
|
for (const workspaceMemberEntity of workspaceMemberEntities) {
|
||||||
if (workspaceMemberEntity.avatarUrl) {
|
if (workspaceMemberEntity.avatarUrl) {
|
||||||
const avatarUrlToken = this.fileService.encodeFileToken({
|
workspaceMemberEntity.avatarUrl = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspaceMemberEntity.avatarUrl),
|
url: workspaceMemberEntity.avatarUrl,
|
||||||
workspaceId: workspace.id,
|
workspaceId: workspace.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
workspaceMemberEntity.avatarUrl = buildSignedPath({
|
|
||||||
path: workspaceMemberEntity.avatarUrl,
|
|
||||||
token: avatarUrlToken,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Refactor to be transpiled to WorkspaceMember instead
|
// TODO Refactor to be transpiled to WorkspaceMember instead
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
import { UseFilters, UseGuards } from '@nestjs/common';
|
import { UseFilters, UseGuards } from '@nestjs/common';
|
||||||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
||||||
|
|
||||||
import { buildSignedPath } from 'twenty-shared/utils';
|
|
||||||
|
|
||||||
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
import { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { User } from 'src/engine/core-modules/user/user.entity';
|
import { User } from 'src/engine/core-modules/user/user.entity';
|
||||||
import { SendInvitationsOutput } from 'src/engine/core-modules/workspace-invitation/dtos/send-invitations.output';
|
import { SendInvitationsOutput } from 'src/engine/core-modules/workspace-invitation/dtos/send-invitations.output';
|
||||||
@ -16,7 +14,6 @@ import { UserAuthGuard } from 'src/engine/guards/user-auth.guard';
|
|||||||
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
|
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
|
||||||
import { SettingPermissionType } from 'src/engine/metadata-modules/permissions/constants/setting-permission-type.constants';
|
import { SettingPermissionType } from 'src/engine/metadata-modules/permissions/constants/setting-permission-type.constants';
|
||||||
import { PermissionsGraphqlApiExceptionFilter } from 'src/engine/metadata-modules/permissions/utils/permissions-graphql-api-exception.filter';
|
import { PermissionsGraphqlApiExceptionFilter } from 'src/engine/metadata-modules/permissions/utils/permissions-graphql-api-exception.filter';
|
||||||
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
|
|
||||||
|
|
||||||
import { SendInvitationsInput } from './dtos/send-invitations.input';
|
import { SendInvitationsInput } from './dtos/send-invitations.input';
|
||||||
|
|
||||||
@ -72,15 +69,10 @@ export class WorkspaceInvitationResolver {
|
|||||||
let workspaceLogoWithToken = '';
|
let workspaceLogoWithToken = '';
|
||||||
|
|
||||||
if (workspace.logo) {
|
if (workspace.logo) {
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
workspaceLogoWithToken = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspace.logo),
|
url: workspace.logo,
|
||||||
workspaceId: workspace.id,
|
workspaceId: workspace.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
workspaceLogoWithToken = buildSignedPath({
|
|
||||||
path: workspace.logo,
|
|
||||||
token: signedPayload,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.workspaceInvitationService.sendInvitations(
|
return await this.workspaceInvitationService.sendInvitations(
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
|
||||||
import { FileUpload, GraphQLUpload } from 'graphql-upload';
|
import { FileUpload, GraphQLUpload } from 'graphql-upload';
|
||||||
import { buildSignedPath, isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface';
|
import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface';
|
||||||
@ -52,7 +52,6 @@ import { RoleDTO } from 'src/engine/metadata-modules/role/dtos/role.dto';
|
|||||||
import { RoleService } from 'src/engine/metadata-modules/role/role.service';
|
import { RoleService } from 'src/engine/metadata-modules/role/role.service';
|
||||||
import { GraphqlValidationExceptionFilter } from 'src/filters/graphql-validation-exception.filter';
|
import { GraphqlValidationExceptionFilter } from 'src/filters/graphql-validation-exception.filter';
|
||||||
import { streamToBuffer } from 'src/utils/stream-to-buffer';
|
import { streamToBuffer } from 'src/utils/stream-to-buffer';
|
||||||
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
|
|
||||||
import { SignedFileDTO } from 'src/engine/core-modules/file/file-upload/dtos/signed-file.dto';
|
import { SignedFileDTO } from 'src/engine/core-modules/file/file-upload/dtos/signed-file.dto';
|
||||||
|
|
||||||
import { Workspace } from './workspace.entity';
|
import { Workspace } from './workspace.entity';
|
||||||
@ -229,15 +228,10 @@ export class WorkspaceResolver {
|
|||||||
async logo(@Parent() workspace: Workspace): Promise<string> {
|
async logo(@Parent() workspace: Workspace): Promise<string> {
|
||||||
if (workspace.logo) {
|
if (workspace.logo) {
|
||||||
try {
|
try {
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
return this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspace.logo),
|
url: workspace.logo,
|
||||||
workspaceId: workspace.id,
|
workspaceId: workspace.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
return buildSignedPath({
|
|
||||||
path: workspace.logo,
|
|
||||||
token: signedPayload,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return workspace.logo;
|
return workspace.logo;
|
||||||
}
|
}
|
||||||
@ -304,15 +298,10 @@ export class WorkspaceResolver {
|
|||||||
|
|
||||||
if (workspace.logo) {
|
if (workspace.logo) {
|
||||||
try {
|
try {
|
||||||
const signedPayload = this.fileService.encodeFileToken({
|
workspaceLogoWithToken = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspace.logo),
|
url: workspace.logo,
|
||||||
workspaceId: workspace.id,
|
workspaceId: workspace.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
workspaceLogoWithToken = buildSignedPath({
|
|
||||||
path: workspace.logo,
|
|
||||||
token: signedPayload,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
workspaceLogoWithToken = workspace.logo;
|
workspaceLogoWithToken = workspace.logo;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,12 +8,9 @@ import {
|
|||||||
Resolver,
|
Resolver,
|
||||||
} from '@nestjs/graphql';
|
} from '@nestjs/graphql';
|
||||||
|
|
||||||
import { buildSignedPath } from 'twenty-shared/utils';
|
|
||||||
|
|
||||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||||
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
|
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 { FileService } from 'src/engine/core-modules/file/services/file.service';
|
||||||
import { extractFilenameFromPath } from 'src/engine/core-modules/file/utils/extract-file-id-from-path.utils';
|
|
||||||
import { UserWorkspaceService } from 'src/engine/core-modules/user-workspace/user-workspace.service';
|
import { UserWorkspaceService } from 'src/engine/core-modules/user-workspace/user-workspace.service';
|
||||||
import { WorkspaceMember } from 'src/engine/core-modules/user/dtos/workspace-member.dto';
|
import { WorkspaceMember } from 'src/engine/core-modules/user/dtos/workspace-member.dto';
|
||||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
@ -194,15 +191,10 @@ export class RoleResolver {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
workspaceMembers.map(async (workspaceMember) => {
|
workspaceMembers.map(async (workspaceMember) => {
|
||||||
if (workspaceMember && workspaceMember.avatarUrl) {
|
if (workspaceMember && workspaceMember.avatarUrl) {
|
||||||
const avatarUrlToken = this.fileService.encodeFileToken({
|
workspaceMember.avatarUrl = this.fileService.signFileUrl({
|
||||||
filename: extractFilenameFromPath(workspaceMember.avatarUrl),
|
url: workspaceMember.avatarUrl,
|
||||||
workspaceId: workspace.id,
|
workspaceId: workspace.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
workspaceMember.avatarUrl = buildSignedPath({
|
|
||||||
path: workspaceMember.avatarUrl,
|
|
||||||
token: avatarUrlToken,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user