Skip to content

Commit c1af809

Browse files
authored
Merge pull request #3328 from SeedCompany/0286-growth-plan-upload-failure
2 parents 42bae6f + 7d9d7db commit c1af809

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

src/components/engagement/engagement.repository.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,20 @@ export class EngagementRepository extends CommonRepository {
380380

381381
if (pnp) {
382382
const engagement = await this.readOne(id, session);
383-
if (engagement.pnp) {
384-
await this.files.createFileVersion(
385-
{
386-
...pnp,
387-
parentId: engagement.pnp.id,
388-
},
389-
session,
383+
384+
if (!engagement.pnp) {
385+
throw new ServerException(
386+
'Expected PnP file to be created with the engagement',
390387
);
391388
}
389+
390+
await this.files.createFileVersion(
391+
{
392+
...pnp,
393+
parentId: engagement.pnp.id,
394+
},
395+
session,
396+
);
392397
}
393398

394399
if (changes.firstScripture) {
@@ -417,15 +422,20 @@ export class EngagementRepository extends CommonRepository {
417422

418423
if (growthPlan) {
419424
const engagement = await this.readOne(id, session);
420-
if (engagement.growthPlan) {
421-
await this.files.createFileVersion(
422-
{
423-
...growthPlan,
424-
parentId: engagement.growthPlan.id,
425-
},
426-
session,
425+
426+
if (!engagement.growthPlan) {
427+
throw new ServerException(
428+
'Expected Growth Plan file to be created with the engagement',
427429
);
428430
}
431+
432+
await this.files.createFileVersion(
433+
{
434+
...growthPlan,
435+
parentId: engagement.growthPlan.id,
436+
},
437+
session,
438+
);
429439
}
430440

431441
if (mentorId !== undefined) {

src/components/engagement/engagement.service.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
} from '~/core';
1919
import { Privileges } from '../authorization';
2020
import { CeremonyService } from '../ceremony';
21-
import { FileService } from '../file';
2221
import { ProductService } from '../product';
2322
import { ProductListInput, SecuredProductList } from '../product/dto';
2423
import { ProjectService } from '../project';
@@ -52,7 +51,6 @@ export class EngagementService {
5251
@Inject(forwardRef(() => ProductService))
5352
private readonly products: ProductService & {},
5453
private readonly config: ConfigService,
55-
private readonly files: FileService,
5654
private readonly engagementRules: EngagementRules,
5755
private readonly privileges: Privileges,
5856
@Inject(forwardRef(() => ProjectService))
@@ -210,13 +208,6 @@ export class EngagementService {
210208
.for(session, InternshipEngagement, object)
211209
.verifyChanges(changes, { pathPrefix: 'engagement' });
212210

213-
await this.files.updateDefinedFile(
214-
object.growthPlan,
215-
'engagement.growthPlan',
216-
changes.growthPlan,
217-
session,
218-
);
219-
220211
const updated = await this.repo.updateInternship(
221212
{ id: object.id, ...changes },
222213
session,

0 commit comments

Comments
 (0)