Skip to content
Snippets Groups Projects
Commit 759fcb53 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix: opendata endpoint data and email format

parent d6a08cb6
No related branches found
No related tags found
2 merge requests!96release V1.10.0,!83Dev
...@@ -5,7 +5,7 @@ import { Week } from './week.schema'; ...@@ -5,7 +5,7 @@ import { Week } from './week.schema';
export type StructureDocument = Structure & Document; export type StructureDocument = Structure & Document;
@Schema({ timestamps: { createdAt: 'createdAt', updatedAt: 'updatedAt' } }) @Schema({ timestamps: true })
export class Structure { export class Structure {
@Prop() @Prop()
numero: string; numero: string;
......
...@@ -182,11 +182,10 @@ export class StructuresService { ...@@ -182,11 +182,10 @@ export class StructuresService {
otherCategories: CategoriesOthers[] otherCategories: CategoriesOthers[]
): Promise<StructureDocument[]> { ): Promise<StructureDocument[]> {
const structures = await this.structureModel.find({ deletedAt: { $exists: false } }).exec(); const structures = await this.structureModel.find({ deletedAt: { $exists: false } }).exec();
// Update structures coord and address before sending them // Update structures coord and address before sending them
await Promise.all( await Promise.all(
structures.map((structure: StructureDocument) => { structures.map((structure: StructureDocument) => {
// If structre has no address, add it // If structure has no address, add it
if (!structure.address || structure.coord.length <= 0) { if (!structure.address || structure.coord.length <= 0) {
return this.getStructurePosition(structure).then((postition: StructureDocument) => { return this.getStructurePosition(structure).then((postition: StructureDocument) => {
this.structureModel this.structureModel
...@@ -205,6 +204,14 @@ export class StructuresService { ...@@ -205,6 +204,14 @@ export class StructuresService {
.select('-_id -accountVerified -otherDescription') .select('-_id -accountVerified -otherDescription')
.exec() .exec()
).map((structure) => { ).map((structure) => {
// If structure has temp email, hide it
if (this.hasTempMail(structure)) {
structure.contactMail = null;
}
// Format date
structure.createdAt = new Date(structure.createdAt).toISOString();
structure.updatedAt = new Date(structure.updatedAt).toISOString();
// Add referentiel
structure.proceduresAccompaniment = this.mapModules( structure.proceduresAccompaniment = this.mapModules(
structure.proceduresAccompaniment, structure.proceduresAccompaniment,
accompagnementCategories.find((category) => category.id === 'proceduresAccompaniment').modules accompagnementCategories.find((category) => category.id === 'proceduresAccompaniment').modules
...@@ -586,4 +593,8 @@ export class StructuresService { ...@@ -586,4 +593,8 @@ export class StructuresService {
}); });
this.mailerService.send(emailsObject, jsonConfig.subject, html); this.mailerService.send(emailsObject, jsonConfig.subject, html);
} }
private hasTempMail(structure: Structure): boolean {
return structure.contactMail === 'unknown@unknown.com';
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment