Skip to content

Commit

Permalink
feat: show user mailing-lists
Browse files Browse the repository at this point in the history
  • Loading branch information
moroine committed Jul 22, 2024
1 parent ef4e81d commit d9ad829
Show file tree
Hide file tree
Showing 39 changed files with 555 additions and 606 deletions.
15 changes: 15 additions & 0 deletions server/src/modules/server/admin/upload.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
updateDocument,
uploadFile,
} from "../../actions/documents.actions";
import { findMailingListWithDocument } from "../../actions/mailingLists.actions";
import { Server } from "../server";

const validateFile = (file: MultipartFile) => {
Expand Down Expand Up @@ -130,6 +131,20 @@ export const uploadAdminRoutes = ({ server }: { server: Server }) => {
return response.status(200).send(documents.map(toPublicDocument));
}
);
server.get(
"/admin/mailing-list/:user_id",
{
schema: zRoutes.get["/admin/mailing-list/:user_id"],
onRequest: [server.auth(zRoutes.get["/admin/mailing-list/:user_id"])],
},
async (request, response) => {
const mailingLists = await findMailingListWithDocument({
added_by: request.params.user_id.toString(),
});

return response.status(200).send(mailingLists);
}
);

server.delete(
"/admin/document/:id",
Expand Down
18 changes: 0 additions & 18 deletions shared/helpers/openapi/__snapshots__/generateOpenapi.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
},
"schemas": {
"Error": {
"additionalProperties": false,
"properties": {
"code": {
"type": [
Expand Down Expand Up @@ -158,11 +157,9 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"schema": {
"anyOf": [
{
"additionalProperties": false,
"description": "Organisation deca Response body",
"properties": {
"contrats": {
"additionalProperties": false,
"properties": {
"appr": {
"type": "number",
Expand All @@ -182,7 +179,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"type": "object",
},
"dernier_contrat": {
"additionalProperties": false,
"properties": {
"date_debut_contrat": {
"type": "string",
Expand All @@ -197,7 +193,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
],
},
"premier_contrat": {
"additionalProperties": false,
"properties": {
"date_debut_contrat": {
"type": "string",
Expand All @@ -218,7 +213,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"type": "object",
},
{
"additionalProperties": false,
"properties": {
"code": {
"type": [
Expand Down Expand Up @@ -324,7 +318,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"description": "Organisation deca Request body",
"properties": {
"siret": {
Expand All @@ -350,11 +343,9 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"schema": {
"anyOf": [
{
"additionalProperties": false,
"description": "Organisation deca Response body",
"properties": {
"contrats": {
"additionalProperties": false,
"properties": {
"appr": {
"type": "number",
Expand All @@ -374,7 +365,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"type": "object",
},
"dernier_contrat": {
"additionalProperties": false,
"properties": {
"date_debut_contrat": {
"type": "string",
Expand All @@ -389,7 +379,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
],
},
"premier_contrat": {
"additionalProperties": false,
"properties": {
"date_debut_contrat": {
"type": "string",
Expand All @@ -410,7 +399,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"type": "object",
},
{
"additionalProperties": false,
"properties": {
"code": {
"type": [
Expand Down Expand Up @@ -520,7 +508,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"description": "Organisation validation Request body",
"properties": {
"email": {
Expand Down Expand Up @@ -551,11 +538,9 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"schema": {
"anyOf": [
{
"additionalProperties": false,
"description": "Organisation deca Response body",
"properties": {
"contrats": {
"additionalProperties": false,
"properties": {
"appr": {
"type": "number",
Expand All @@ -575,7 +560,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"type": "object",
},
"dernier_contrat": {
"additionalProperties": false,
"properties": {
"date_debut_contrat": {
"type": "string",
Expand All @@ -590,7 +574,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
],
},
"premier_contrat": {
"additionalProperties": false,
"properties": {
"date_debut_contrat": {
"type": "string",
Expand All @@ -611,7 +594,6 @@ exports[`generateOpenApiSchema > should generate proper schema 1`] = `
"type": "object",
},
{
"additionalProperties": false,
"properties": {
"code": {
"type": [
Expand Down
17 changes: 8 additions & 9 deletions shared/models/bouncer.domain.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ const collectionName = "bouncer.domain" as const;

const indexes: IModelDescriptor["indexes"] = [[{ domain: 1, smtp: 1 }, { unique: true }]];

export const zBouncerDomain = z
.object({
_id: zObjectId,
domain: z.string(),
smtp: z.string(),
ping: zBouncerPingResult.nullable(),
updated_at: z.date(),
created_at: z.date(),
})
export const zBouncerDomain = z.object({
_id: zObjectId,
domain: z.string(),
smtp: z.string(),
ping: zBouncerPingResult.nullable(),
updated_at: z.date(),
created_at: z.date(),
});

export type BouncerDomain = z.output<typeof zBouncerDomain>;

Expand Down
32 changes: 14 additions & 18 deletions shared/models/bouncer.email.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,23 @@ const zEmailStatus = z.enum(["valid", "invalid", "not_supported", "error"]);

export type EmailStatus = z.output<typeof zEmailStatus>;

export const zBouncerPingResult = z
.object({
status: zEmailStatus,
message: z.string(),
responseCode: z.string().nullable(),
responseMessage: z.string().nullable(),
})
;
export const zBouncerPingResult = z.object({
status: zEmailStatus,
message: z.string(),
responseCode: z.string().nullable(),
responseMessage: z.string().nullable(),
});

export type BouncerPingResult = z.output<typeof zBouncerPingResult>;

export const zBouncerEmail = z
.object({
_id: zObjectId,
email: z.string(),
domain: z.string().nullable(),
smtp: z.string().nullable(),
ping: zBouncerPingResult,
created_at: z.date(),
})
;
export const zBouncerEmail = z.object({
_id: zObjectId,
email: z.string(),
domain: z.string().nullable(),
smtp: z.string().nullable(),
ping: zBouncerPingResult,
created_at: z.date(),
});

export type BouncerEmail = z.output<typeof zBouncerEmail>;

Expand Down
141 changes: 66 additions & 75 deletions shared/models/catalogue.api.model.ts
Original file line number Diff line number Diff line change
@@ -1,79 +1,70 @@
import { z } from "zod";

const etablissementFormateurSchema = z
.object({
etablissement_formateur_id: z.string().nullish(),
etablissement_formateur_siret: z.string().nullish(),
etablissement_formateur_enseigne: z.string().nullish(),
etablissement_formateur_uai: z.string().nullish(),
etablissement_formateur_type: z.string().nullish(),
etablissement_formateur_conventionne: z.string().nullish(),
etablissement_formateur_declare_prefecture: z.string().nullish(),
etablissement_formateur_datadock: z.string().nullish(),
etablissement_formateur_adresse: z.string().nullish(),
etablissement_formateur_code_postal: z.string().nullish(),
etablissement_formateur_code_commune_insee: z.string().nullish(),
etablissement_formateur_localite: z.string().nullish(),
etablissement_formateur_complement_adresse: z.string().nullish(),
etablissement_formateur_cedex: z.string().nullish(),
etablissement_formateur_entreprise_raison_sociale: z.string().nullish(),
geo_coordonnees_etablissement_formateur: z.string().nullish(),
etablissement_formateur_region: z.string().nullish(),
etablissement_formateur_num_departement: z.string().nullish(),
etablissement_formateur_nom_departement: z.string().nullish(),
etablissement_formateur_nom_academie: z.string().nullish(),
etablissement_formateur_num_academie: z.string().nullish(),
etablissement_formateur_siren: z.string().nullish(),
etablissement_formateur_courriel: z.string().nullish(),
etablissement_formateur_published: z.boolean().nullish(),
etablissement_formateur_catalogue_published: z.boolean().nullish(),
rncp_etablissement_formateur_habilite: z.boolean().nullish(),
etablissement_formateur_date_creation: z.string().nullish(),
})
;

const etablissementGestionnaireSchema = z
.object({
etablissement_gestionnaire_id: z.string().nullish(),
etablissement_gestionnaire_siret: z.string().nullish(),
etablissement_gestionnaire_enseigne: z.string().nullish(),
etablissement_gestionnaire_uai: z.string().nullish(),
etablissement_gestionnaire_type: z.string().nullish(),
etablissement_gestionnaire_conventionne: z.string().nullish(),
etablissement_gestionnaire_declare_prefecture: z.string().nullish(),
etablissement_gestionnaire_datadock: z.string().nullish(),
etablissement_gestionnaire_adresse: z.string().nullish(),
etablissement_gestionnaire_code_postal: z.string().nullish(),
etablissement_gestionnaire_code_commune_insee: z.string().nullish(),
etablissement_gestionnaire_localite: z.string().nullish(),
etablissement_gestionnaire_complement_adresse: z.string().nullish(),
etablissement_gestionnaire_cedex: z.string().nullish(),
etablissement_gestionnaire_entreprise_raison_sociale: z.string().nullish(),
geo_coordonnees_etablissement_gestionnaire: z.string().nullish(),
etablissement_gestionnaire_region: z.string().nullish(),
etablissement_gestionnaire_num_departement: z.string().nullish(),
etablissement_gestionnaire_nom_departement: z.string().nullish(),
etablissement_gestionnaire_nom_academie: z.string().nullish(),
etablissement_gestionnaire_num_academie: z.string().nullish(),
etablissement_gestionnaire_siren: z.string().nullish(),
etablissement_gestionnaire_courriel: z.string().nullish(),
etablissement_gestionnaire_published: z.boolean().nullish(),
etablissement_gestionnaire_catalogue_published: z.boolean().nullish(),
rncp_etablissement_gestionnaire_habilite: z.boolean().nullish(),
etablissement_gestionnaire_date_creation: z.string().nullish(),
})
;

const etablissementReferenceSchema = z
.object({
etablissement_reference: z.string().nullish(),
etablissement_reference_published: z.boolean().nullish(),
etablissement_reference_habilite_rncp: z.boolean().nullish(),
etablissement_reference_certifie_qualite: z.boolean().nullish(),
etablissement_reference_date_creation: z.string().nullish(),
})
;

const etablissementFormateurSchema = z.object({
etablissement_formateur_id: z.string().nullish(),
etablissement_formateur_siret: z.string().nullish(),
etablissement_formateur_enseigne: z.string().nullish(),
etablissement_formateur_uai: z.string().nullish(),
etablissement_formateur_type: z.string().nullish(),
etablissement_formateur_conventionne: z.string().nullish(),
etablissement_formateur_declare_prefecture: z.string().nullish(),
etablissement_formateur_datadock: z.string().nullish(),
etablissement_formateur_adresse: z.string().nullish(),
etablissement_formateur_code_postal: z.string().nullish(),
etablissement_formateur_code_commune_insee: z.string().nullish(),
etablissement_formateur_localite: z.string().nullish(),
etablissement_formateur_complement_adresse: z.string().nullish(),
etablissement_formateur_cedex: z.string().nullish(),
etablissement_formateur_entreprise_raison_sociale: z.string().nullish(),
geo_coordonnees_etablissement_formateur: z.string().nullish(),
etablissement_formateur_region: z.string().nullish(),
etablissement_formateur_num_departement: z.string().nullish(),
etablissement_formateur_nom_departement: z.string().nullish(),
etablissement_formateur_nom_academie: z.string().nullish(),
etablissement_formateur_num_academie: z.string().nullish(),
etablissement_formateur_siren: z.string().nullish(),
etablissement_formateur_courriel: z.string().nullish(),
etablissement_formateur_published: z.boolean().nullish(),
etablissement_formateur_catalogue_published: z.boolean().nullish(),
rncp_etablissement_formateur_habilite: z.boolean().nullish(),
etablissement_formateur_date_creation: z.string().nullish(),
});
const etablissementGestionnaireSchema = z.object({
etablissement_gestionnaire_id: z.string().nullish(),
etablissement_gestionnaire_siret: z.string().nullish(),
etablissement_gestionnaire_enseigne: z.string().nullish(),
etablissement_gestionnaire_uai: z.string().nullish(),
etablissement_gestionnaire_type: z.string().nullish(),
etablissement_gestionnaire_conventionne: z.string().nullish(),
etablissement_gestionnaire_declare_prefecture: z.string().nullish(),
etablissement_gestionnaire_datadock: z.string().nullish(),
etablissement_gestionnaire_adresse: z.string().nullish(),
etablissement_gestionnaire_code_postal: z.string().nullish(),
etablissement_gestionnaire_code_commune_insee: z.string().nullish(),
etablissement_gestionnaire_localite: z.string().nullish(),
etablissement_gestionnaire_complement_adresse: z.string().nullish(),
etablissement_gestionnaire_cedex: z.string().nullish(),
etablissement_gestionnaire_entreprise_raison_sociale: z.string().nullish(),
geo_coordonnees_etablissement_gestionnaire: z.string().nullish(),
etablissement_gestionnaire_region: z.string().nullish(),
etablissement_gestionnaire_num_departement: z.string().nullish(),
etablissement_gestionnaire_nom_departement: z.string().nullish(),
etablissement_gestionnaire_nom_academie: z.string().nullish(),
etablissement_gestionnaire_num_academie: z.string().nullish(),
etablissement_gestionnaire_siren: z.string().nullish(),
etablissement_gestionnaire_courriel: z.string().nullish(),
etablissement_gestionnaire_published: z.boolean().nullish(),
etablissement_gestionnaire_catalogue_published: z.boolean().nullish(),
rncp_etablissement_gestionnaire_habilite: z.boolean().nullish(),
etablissement_gestionnaire_date_creation: z.string().nullish(),
});
const etablissementReferenceSchema = z.object({
etablissement_reference: z.string().nullish(),
etablissement_reference_published: z.boolean().nullish(),
etablissement_reference_habilite_rncp: z.boolean().nullish(),
etablissement_reference_certifie_qualite: z.boolean().nullish(),
etablissement_reference_date_creation: z.string().nullish(),
});
const stringOrArraySchema = z.union([z.string(), z.array(z.string())]);

export const zFormationCatalogue = z
Expand Down Expand Up @@ -172,7 +163,7 @@ export const zFormationCatalogue = z
num_tel: z.string().nullish().describe("Numéro de téléphone de contact"),
distance: z.number().nullish(),
})

.merge(etablissementFormateurSchema)
.merge(etablissementGestionnaireSchema)
.merge(etablissementReferenceSchema);
Loading

0 comments on commit d9ad829

Please sign in to comment.