Skip to content

Commit

Permalink
N21-1967 adjusts files storage param builder
Browse files Browse the repository at this point in the history
  • Loading branch information
arnegns committed Jun 17, 2024
1 parent 6e71036 commit aeef33e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CopyStatus } from '@modules/copy-helper';
import { FilesStorageClientAdapterService } from '@modules/files-storage-client';
import { StorageLocation } from '@modules/files-storage/entity';
import { UserService } from '@modules/user';
import { Injectable, InternalServerErrorException, NotImplementedException } from '@nestjs/common';
import { EntityId } from '@shared/domain/types';
Expand Down Expand Up @@ -39,6 +40,8 @@ export class ColumnBoardCopyService {
const copyContext = new BoardNodeCopyContext({
sourceStorageLocationId: course.school.id,
targetStorageLocationId: user.schoolId,
sourceStorageLocation: StorageLocation.SCHOOL,
targetStorageLocation: StorageLocation.SCHOOL,
userId: props.userId,
filesStorageClientAdapterService: this.filesStorageClientAdapterService,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FileRecordParentType } from '@infra/rabbitmq';
import { StorageLocation } from '@modules/files-storage/entity';
import { lessonFactory, setupEntities, taskFactory } from '@shared/testing';
import { FileParamBuilder } from './files-storage-param.builder';

Expand All @@ -24,9 +25,10 @@ describe('FileParamBuilder', () => {
const result = FileParamBuilder.build(schoolId, task);

const expectedResult = {
schoolId,
storageLocationId: schoolId,
parentType,
parentId: task.id,
storageLocation: StorageLocation.SCHOOL,
};

expect(result).toStrictEqual(expectedResult);
Expand All @@ -40,7 +42,8 @@ describe('FileParamBuilder', () => {
const result = FileParamBuilder.build(schoolId, lesson);

const expectedResult = {
schoolId,
storageLocationId: schoolId,
storageLocation: StorageLocation.SCHOOL,
parentType,
parentId: lesson.id,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { StorageLocation } from '@modules/files-storage/entity';
import { EntityId } from '@shared/domain/types';
import { EntitiesWithFiles, FileRequestInfo } from '../interfaces';
import { FilesStorageClientMapper } from './files-storage-client.mapper';

export class FileParamBuilder {
static build(schoolId: EntityId, parent: EntitiesWithFiles): FileRequestInfo {
static build(storageLocationId: EntityId, parent: EntitiesWithFiles): FileRequestInfo {
const parentType = FilesStorageClientMapper.mapEntityToParentType(parent);
const fileRequestInfo = {
parentType,
schoolId,
storageLocationId,
storageLocation: StorageLocation.SCHOOL,
parentId: parent.id,
};

Expand Down

0 comments on commit aeef33e

Please sign in to comment.