Skip to content

Commit a5033df

Browse files
tech(api): added multiple sending assessment by default when creating a campaign
1 parent b38c08a commit a5033df

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FeatureNotFound } from '../../../src/organizational-entities/domain/errors.js';
1+
import { ORGANIZATION_FEATURE } from '../../../src/shared/domain/constants.js';
22
import { Organization } from '../../../src/shared/domain/models/index.js';
33

44
const createOrganization = async function ({
@@ -8,14 +8,14 @@ const createOrganization = async function ({
88
organizationCreationValidator,
99
schoolRepository,
1010
codeGenerator,
11-
featureRepository,
12-
organizationFeatureRepository,
1311
}) {
1412
organizationCreationValidator.validate(organization);
13+
organization.features[ORGANIZATION_FEATURE.MULTIPLE_SENDING_ASSESSMENT.key] = {
14+
active: true,
15+
params: null,
16+
};
1517
const savedOrganization = await organizationForAdminRepository.save(organization);
1618

17-
await addMultipleSendingsFeatureByDefault({ featureRepository, organizationFeatureRepository });
18-
1919
await dataProtectionOfficerRepository.create({
2020
organizationId: savedOrganization.id,
2121
firstName: organization.dataProtectionOfficer.firstName,
@@ -30,19 +30,4 @@ const createOrganization = async function ({
3030
return await organizationForAdminRepository.get(savedOrganization.id);
3131
};
3232

33-
const addMultipleSendingsFeatureByDefault = async function ({
34-
featureRepository,
35-
organizationFeatureRepository,
36-
savedOrganization,
37-
}) {
38-
const featureId = await featureRepository.getIdByKey('MULTIPLE_SENDING_ASSESSMENT').id;
39-
if (featureId) {
40-
await organizationFeatureRepository.saveInBatch([
41-
{ featureId, organizationId: savedOrganization.id, params: null },
42-
]);
43-
} else {
44-
throw new FeatureNotFound();
45-
}
46-
};
47-
4833
export { createOrganization };

0 commit comments

Comments
 (0)