Deprecate inject workspace repo (#6353)
This commit is contained in:
@ -2,8 +2,7 @@ import { WorkspaceQueryHookInstance } from 'src/engine/api/graphql/workspace-que
|
||||
import { DeleteOneResolverArgs } from 'src/engine/api/graphql/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface';
|
||||
|
||||
import { WorkspaceQueryHook } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-hook/decorators/workspace-query-hook.decorator';
|
||||
import { InjectWorkspaceRepository } from 'src/engine/twenty-orm/decorators/inject-workspace-repository.decorator';
|
||||
import { WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import { CommentWorkspaceEntity } from 'src/modules/activity/standard-objects/comment.workspace-entity';
|
||||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
|
||||
|
||||
@ -11,12 +10,7 @@ import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objec
|
||||
export class WorkspaceMemberDeleteOnePreQueryHook
|
||||
implements WorkspaceQueryHookInstance
|
||||
{
|
||||
constructor(
|
||||
@InjectWorkspaceRepository(AttachmentWorkspaceEntity)
|
||||
private readonly attachmentRepository: WorkspaceRepository<AttachmentWorkspaceEntity>,
|
||||
@InjectWorkspaceRepository(CommentWorkspaceEntity)
|
||||
private readonly commentRepository: WorkspaceRepository<CommentWorkspaceEntity>,
|
||||
) {}
|
||||
constructor(private readonly twentyORMManager: TwentyORMManager) {}
|
||||
|
||||
// There is no need to validate the user's access to the workspace member since we don't have permission yet.
|
||||
async execute(
|
||||
@ -24,13 +18,23 @@ export class WorkspaceMemberDeleteOnePreQueryHook
|
||||
workspaceId: string,
|
||||
payload: DeleteOneResolverArgs,
|
||||
): Promise<void> {
|
||||
const attachmentRepository =
|
||||
await this.twentyORMManager.getRepository<AttachmentWorkspaceEntity>(
|
||||
'attachment',
|
||||
);
|
||||
|
||||
const commentRepository =
|
||||
await this.twentyORMManager.getRepository<CommentWorkspaceEntity>(
|
||||
'comment',
|
||||
);
|
||||
|
||||
const authorId = payload.id;
|
||||
|
||||
await this.attachmentRepository.delete({
|
||||
await attachmentRepository.delete({
|
||||
authorId,
|
||||
});
|
||||
|
||||
await this.commentRepository.delete({
|
||||
await commentRepository.delete({
|
||||
authorId,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user