feat: drop calendar repository (#5824)
This PR is replacing and removing all the raw queries and repositories with the new `TwentyORM` and injection system using `@InjectWorkspaceRepository`. Some logic that was contained inside repositories has been moved to the services. In this PR we're only replacing repositories for calendar feature. --------- Co-authored-by: Weiko <corentin@twenty.com> Co-authored-by: bosiraphael <raphael.bosi@gmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -3,10 +3,9 @@ import { Injectable } from '@nestjs/common';
|
||||
import { WorkspacePreQueryHook } from 'src/engine/api/graphql/workspace-query-runner/workspace-pre-query-hook/interfaces/workspace-pre-query-hook.interface';
|
||||
import { DeleteOneResolverArgs } from 'src/engine/api/graphql/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface';
|
||||
|
||||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
||||
import { CommentRepository } from 'src/modules/activity/repositories/comment.repository';
|
||||
import { InjectWorkspaceRepository } from 'src/engine/twenty-orm/decorators/inject-workspace-repository.decorator';
|
||||
import { WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
|
||||
import { CommentWorkspaceEntity } from 'src/modules/activity/standard-objects/comment.workspace-entity';
|
||||
import { AttachmentRepository } from 'src/modules/attachment/repositories/attachment.repository';
|
||||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
|
||||
|
||||
@Injectable()
|
||||
@ -14,10 +13,10 @@ export class WorkspaceMemberDeleteOnePreQueryHook
|
||||
implements WorkspacePreQueryHook
|
||||
{
|
||||
constructor(
|
||||
@InjectObjectMetadataRepository(AttachmentWorkspaceEntity)
|
||||
private readonly attachmentRepository: AttachmentRepository,
|
||||
@InjectObjectMetadataRepository(CommentWorkspaceEntity)
|
||||
private readonly commentRepository: CommentRepository,
|
||||
@InjectWorkspaceRepository(AttachmentWorkspaceEntity)
|
||||
private readonly attachmentRepository: WorkspaceRepository<AttachmentWorkspaceEntity>,
|
||||
@InjectWorkspaceRepository(CommentWorkspaceEntity)
|
||||
private readonly commentRepository: WorkspaceRepository<CommentWorkspaceEntity>,
|
||||
) {}
|
||||
|
||||
// There is no need to validate the user's access to the workspace member since we don't have permission yet.
|
||||
@ -26,16 +25,18 @@ export class WorkspaceMemberDeleteOnePreQueryHook
|
||||
workspaceId: string,
|
||||
payload: DeleteOneResolverArgs,
|
||||
): Promise<void> {
|
||||
const workspaceMemberId = payload.id;
|
||||
const authorId = payload.id;
|
||||
|
||||
await this.attachmentRepository.deleteByAuthorId(
|
||||
workspaceMemberId,
|
||||
workspaceId,
|
||||
);
|
||||
await this.attachmentRepository.delete({
|
||||
author: {
|
||||
id: authorId,
|
||||
},
|
||||
});
|
||||
|
||||
await this.commentRepository.deleteByAuthorId(
|
||||
workspaceMemberId,
|
||||
workspaceId,
|
||||
);
|
||||
await this.commentRepository.delete({
|
||||
author: {
|
||||
id: authorId,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
|
||||
import { TwentyORMModule } from 'src/engine/twenty-orm/twenty-orm.module';
|
||||
import { CommentWorkspaceEntity } from 'src/modules/activity/standard-objects/comment.workspace-entity';
|
||||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity';
|
||||
import { WorkspaceMemberDeleteManyPreQueryHook } from 'src/modules/workspace-member/query-hooks/workspace-member-delete-many.pre-query.hook';
|
||||
@ -8,7 +8,7 @@ import { WorkspaceMemberDeleteOnePreQueryHook } from 'src/modules/workspace-memb
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ObjectMetadataRepositoryModule.forFeature([
|
||||
TwentyORMModule.forFeature([
|
||||
AttachmentWorkspaceEntity,
|
||||
CommentWorkspaceEntity,
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user