diff --git a/src/admin/admin.controller.ts b/src/admin/admin.controller.ts index f99afe5d6062b040432b6650d9f0acaf7063f7b5..01397a99dad657e1ab94bc9fc37260e0f3990aeb 100644 --- a/src/admin/admin.controller.ts +++ b/src/admin/admin.controller.ts @@ -38,6 +38,7 @@ type PendingStructure = { updatedAt: string; permalink: string; lastUpdateMail: Date; + comment: string; }; @ApiTags('admin') @@ -89,6 +90,7 @@ export class AdminController { updatedAt: structure.updatedAt ? structure.updatedAt : structure.createdAt, isOutdated: this.adminService.isDateOutdated(lastUpdateDate, 6), lastUpdateMail: structure.lastUpdateMail, + comment: structure.comment, }; }) ); @@ -104,6 +106,7 @@ export class AdminController { updatedAt: lastUpdateDate, isOutdated: this.adminService.isDateOutdated(lastUpdateDate, 6), lastUpdateMail: structure.lastUpdateMail, + comment: structure.comment, }; }); const allStructures = await this.structuresService.findAll(); @@ -122,6 +125,7 @@ export class AdminController { updatedAt: lastUpdateDate, isOutdated: this.adminService.isDateOutdated(lastUpdateDate, 6), lastUpdateMail: structure.lastUpdateMail, + comment: structure.comment, }; }); structuresList.incomplete = await Promise.all( @@ -139,6 +143,7 @@ export class AdminController { updatedAt: lastUpdateDate, isOutdated: this.adminService.isDateOutdated(lastUpdateDate, 6), lastUpdateMail: struct.lastUpdateMail, + comment: struct.comment, }; } else { return null; diff --git a/src/structures/schemas/structure.schema.ts b/src/structures/schemas/structure.schema.ts index cf36070a92aec86a356f8472da52b3b35709c0d9..7c11fbbbffeb18d4cfc44c5582e740d3f3ba90ae 100644 --- a/src/structures/schemas/structure.schema.ts +++ b/src/structures/schemas/structure.schema.ts @@ -155,6 +155,9 @@ export class Structure { @Prop() lastUpdateMail: Date; + + @Prop() + comment: string; } export const StructureSchema = SchemaFactory.createForClass(Structure); diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index 6192cf5f757d164100717a98820a3178399a8ea1..e459e4535767bc792b46b4068e6f2194b68c675c 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -434,12 +434,14 @@ export class StructuresService { const responseStructure = await this.findOne(idStructure); await this.structuresSearchService.update(responseStructure, idStructure); - this.sendAdminStructureNotification( - result, - this.mailerService.config.templates.structureModificationNotification.ejs, - this.mailerService.config.templates.structureModificationNotification.json - ); - this.userService.removeOutdatedStructureFromArray(idStructure); + if (!hasAdminRole(user)) { + this.sendAdminStructureNotification( + result, + this.mailerService.config.templates.structureModificationNotification.ejs, + this.mailerService.config.templates.structureModificationNotification.json + ); + this.userService.removeOutdatedStructureFromArray(idStructure); + } return responseStructure; } diff --git a/test/mock/data/structures.mock.data.ts b/test/mock/data/structures.mock.data.ts index 93727ef2ee3e4faef750fd49afe32c3dd732f67a..cd0dd5326d6e4e1cff64961c27d921e8cecb3512 100644 --- a/test/mock/data/structures.mock.data.ts +++ b/test/mock/data/structures.mock.data.ts @@ -427,6 +427,7 @@ export const mockStructure: Structure = { categoriesWithPersonalOffers: {}, lastUpdateMail: new Date('2020-11-16T09:30:00.000Z'), permalink: 'a', + comment: 'nouveau', }; export const mockDeletedStructure: Structure = { @@ -534,4 +535,5 @@ export const mockDeletedStructure: Structure = { deletedAt: new Date('2020-11-16T09:30:00.000Z'), lastUpdateMail: new Date('2020-11-16T09:30:00.000Z'), permalink: 'latelier-numerique', + comment: 'ancienne structure', }; diff --git a/test/mock/services/structures.mock.service.ts b/test/mock/services/structures.mock.service.ts index 7ba08bd936877194a8e6c73f417847491126fadb..5f0c7a1f19a2173c520100583b5db8c8115159a8 100644 --- a/test/mock/services/structures.mock.service.ts +++ b/test/mock/services/structures.mock.service.ts @@ -1458,6 +1458,7 @@ export const mockResinStructures: Array<Structure> = [ categoriesWithPersonalOffers: null, lastUpdateMail: new Date('2021-05-06T09:42:38.000Z'), permalink: 'a', + comment: 'petit commentaire', }, { contactMail: 'matchin@email.com', @@ -1562,6 +1563,7 @@ export const mockResinStructures: Array<Structure> = [ categoriesWithPersonalOffers: null, lastUpdateMail: new Date('2021-05-06T09:42:38.000Z'), permalink: 'a-1', + comment: 'petit commentaire', }, { contactMail: 'nomatch@email.com', @@ -1666,5 +1668,6 @@ export const mockResinStructures: Array<Structure> = [ categoriesWithPersonalOffers: null, lastUpdateMail: new Date('2021-05-06T09:42:38.000Z'), permalink: 'a-2', + comment: 'petit commentaire', }, ];