generated from gitea_admin/default
API Microsoft
This commit is contained in:
@@ -185,9 +185,9 @@ export default defineEventHandler(async (event) => {
|
||||
instrument,
|
||||
deja_participe_academie,
|
||||
nombre_participations_academie,
|
||||
niveau_cycle_2026_2027,
|
||||
niveau_cycle_actuel,
|
||||
autre_formation,
|
||||
conservatoire_2026_2027,
|
||||
conservatoire_actuel,
|
||||
autre_conservatoire,
|
||||
professeur_instrument,
|
||||
diplome_1_type,
|
||||
|
||||
4
server/database/2026-06-15_academie_excel_export.sql
Normal file
4
server/database/2026-06-15_academie_excel_export.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE academie_orchestre_candidatures
|
||||
ADD COLUMN exported_to_excel TINYINT(1) NOT NULL DEFAULT 0,
|
||||
ADD COLUMN exported_to_excel_at DATETIME NULL,
|
||||
ADD COLUMN export_error TEXT NULL;
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE academie_orchestre_candidatures
|
||||
CHANGE COLUMN niveau_cycle_2026_2027 niveau_cycle_actuel VARCHAR(255) NOT NULL,
|
||||
CHANGE COLUMN conservatoire_2026_2027 conservatoire_actuel VARCHAR(500) NOT NULL;
|
||||
@@ -15,9 +15,9 @@ CREATE TABLE academie_orchestre_candidatures (
|
||||
instrument VARCHAR(255) NOT NULL,
|
||||
deja_participe_academie VARCHAR(10) NOT NULL,
|
||||
nombre_participations_academie INT UNSIGNED NULL,
|
||||
niveau_cycle_2026_2027 VARCHAR(255) NOT NULL,
|
||||
niveau_cycle_actuel VARCHAR(255) NOT NULL,
|
||||
autre_formation VARCHAR(255) NULL,
|
||||
conservatoire_2026_2027 VARCHAR(500) NOT NULL,
|
||||
conservatoire_actuel VARCHAR(500) NOT NULL,
|
||||
autre_conservatoire VARCHAR(500) NULL,
|
||||
professeur_instrument VARCHAR(255) NOT NULL,
|
||||
diplome_1_type VARCHAR(255) NULL,
|
||||
@@ -41,6 +41,9 @@ CREATE TABLE academie_orchestre_candidatures (
|
||||
contact_urgence_telephone VARCHAR(100) NOT NULL,
|
||||
contact_urgence_email VARCHAR(255) NOT NULL,
|
||||
reglement_accepte TINYINT(1) NOT NULL DEFAULT 0,
|
||||
exported_to_excel TINYINT(1) NOT NULL DEFAULT 0,
|
||||
exported_to_excel_at DATETIME NULL,
|
||||
export_error TEXT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
@@ -1,42 +1,62 @@
|
||||
import nodemailer from "nodemailer"
|
||||
|
||||
let transporter
|
||||
const transporters = {}
|
||||
|
||||
function isSmtpConfigured(config) {
|
||||
return Boolean(
|
||||
config.smtpHost &&
|
||||
config.smtpPort &&
|
||||
config.smtpUser &&
|
||||
config.smtpPassword &&
|
||||
config.smtpFromEmail
|
||||
config.host &&
|
||||
config.port &&
|
||||
config.user &&
|
||||
config.password &&
|
||||
config.fromEmail
|
||||
)
|
||||
}
|
||||
|
||||
function getTransporter() {
|
||||
if (transporter) {
|
||||
return transporter
|
||||
function getSmtpConfig(config, suffix) {
|
||||
const key = suffix.charAt(0).toUpperCase() + suffix.slice(1)
|
||||
|
||||
return {
|
||||
host: config[`smtpHost${key}`],
|
||||
port: config[`smtpPort${key}`],
|
||||
secure: config[`smtpSecure${key}`],
|
||||
user: config[`smtpUser${key}`],
|
||||
password: config[`smtpPassword${key}`],
|
||||
fromEmail: config[`smtpFromEmail${key}`],
|
||||
fromName: config[`smtpFromName${key}`],
|
||||
}
|
||||
}
|
||||
|
||||
function getFrom(config) {
|
||||
return config.fromName
|
||||
? `"${config.fromName}" <${config.fromEmail}>`
|
||||
: config.fromEmail
|
||||
}
|
||||
|
||||
function getTransporter(suffix) {
|
||||
if (transporters[suffix]) {
|
||||
return transporters[suffix]
|
||||
}
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const config = getSmtpConfig(useRuntimeConfig(), suffix)
|
||||
|
||||
if (!isSmtpConfigured(config)) {
|
||||
return null
|
||||
}
|
||||
|
||||
transporter = nodemailer.createTransport({
|
||||
host: config.smtpHost,
|
||||
port: Number(config.smtpPort),
|
||||
secure: String(config.smtpSecure).toLowerCase() === "true",
|
||||
transporters[suffix] = nodemailer.createTransport({
|
||||
host: config.host,
|
||||
port: Number(config.port),
|
||||
secure: String(config.secure).toLowerCase() === "true",
|
||||
connectionTimeout: 10000,
|
||||
greetingTimeout: 10000,
|
||||
socketTimeout: 15000,
|
||||
auth: {
|
||||
user: config.smtpUser,
|
||||
pass: config.smtpPassword,
|
||||
user: config.user,
|
||||
pass: config.password,
|
||||
},
|
||||
})
|
||||
|
||||
return transporter
|
||||
return transporters[suffix]
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
@@ -50,15 +70,14 @@ function escapeHtml(value) {
|
||||
|
||||
export async function sendParcDemandEmails(payload) {
|
||||
const config = useRuntimeConfig()
|
||||
const mailer = getTransporter()
|
||||
const smtpConfig = getSmtpConfig(config, "parc")
|
||||
const mailer = getTransporter("parc")
|
||||
|
||||
if (!mailer || !config.parcRequestRecipientEmail) {
|
||||
return false
|
||||
}
|
||||
|
||||
const from = config.smtpFromName
|
||||
? `"${config.smtpFromName}" <${config.smtpFromEmail}>`
|
||||
: config.smtpFromEmail
|
||||
const from = getFrom(smtpConfig)
|
||||
|
||||
const adminSubject = `WONDIF - Formulaire de demande Parc instrumental - ${payload.name}`
|
||||
const adminText = [
|
||||
@@ -144,7 +163,8 @@ function getProjetLyceeSummary(payload) {
|
||||
|
||||
export async function sendProjetLyceeEmails(payload) {
|
||||
const config = useRuntimeConfig()
|
||||
const mailer = getTransporter()
|
||||
const smtpConfig = getSmtpConfig(config, "aec")
|
||||
const mailer = getTransporter("aec")
|
||||
|
||||
if (!mailer) {
|
||||
console.warn("Email projet lycée non envoyé: configuration SMTP incomplète.")
|
||||
@@ -156,9 +176,7 @@ export async function sendProjetLyceeEmails(payload) {
|
||||
return false
|
||||
}
|
||||
|
||||
const from = config.smtpFromName
|
||||
? `"${config.smtpFromName}" <${config.smtpFromEmail}>`
|
||||
: config.smtpFromEmail
|
||||
const from = getFrom(smtpConfig)
|
||||
|
||||
const summary = getProjetLyceeSummary(payload)
|
||||
|
||||
@@ -262,7 +280,8 @@ function getProjetAcademieSummary(payload) {
|
||||
|
||||
export async function sendProjetAcademieEmails(payload) {
|
||||
const config = useRuntimeConfig()
|
||||
const mailer = getTransporter()
|
||||
const smtpConfig = getSmtpConfig(config, "aec")
|
||||
const mailer = getTransporter("aec")
|
||||
|
||||
if (!mailer) {
|
||||
console.warn("Email projet académie non envoyé: configuration SMTP incomplète.")
|
||||
@@ -274,9 +293,7 @@ export async function sendProjetAcademieEmails(payload) {
|
||||
return false
|
||||
}
|
||||
|
||||
const from = config.smtpFromName
|
||||
? `"${config.smtpFromName}" <${config.smtpFromEmail}>`
|
||||
: config.smtpFromEmail
|
||||
const from = getFrom(smtpConfig)
|
||||
|
||||
const summary = getProjetAcademieSummary(payload)
|
||||
const fullName = `${payload.lastName} ${payload.firstName}`
|
||||
|
||||
Reference in New Issue
Block a user