gdpr audit implemented, email log, vollmachten, pdf delete cancel data privacy and vollmachten, removed message no id card in engergy car, and other contracts that are not telecom contracts, added insert counter for engery
This commit is contained in:
@@ -42,11 +42,19 @@ export interface SendEmailResult {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// Optionaler Logging-Kontext
|
||||
export interface EmailLogContext {
|
||||
context: string; // z.B. "consent-link", "authorization-request", "customer-email"
|
||||
customerId?: number;
|
||||
triggeredBy?: string; // User-Email
|
||||
}
|
||||
|
||||
// E-Mail senden
|
||||
export async function sendEmail(
|
||||
credentials: SmtpCredentials,
|
||||
fromAddress: string,
|
||||
params: SendEmailParams
|
||||
params: SendEmailParams,
|
||||
logContext?: EmailLogContext
|
||||
): Promise<SendEmailResult> {
|
||||
// Verschlüsselungs-Einstellungen basierend auf Modus
|
||||
const encryption = credentials.encryption ?? 'SSL';
|
||||
@@ -155,6 +163,27 @@ export async function sendEmail(
|
||||
// Nicht kritisch - E-Mail wurde trotzdem gesendet
|
||||
}
|
||||
|
||||
// E-Mail-Log erstellen (async, nicht blockierend)
|
||||
if (logContext) {
|
||||
import('./emailLog.service.js').then(({ createEmailLog }) => {
|
||||
createEmailLog({
|
||||
fromAddress,
|
||||
toAddress: Array.isArray(params.to) ? params.to.join(', ') : params.to,
|
||||
subject: params.subject,
|
||||
context: logContext.context,
|
||||
customerId: logContext.customerId,
|
||||
triggeredBy: logContext.triggeredBy,
|
||||
smtpServer: credentials.host,
|
||||
smtpPort: credentials.port,
|
||||
smtpEncryption: credentials.encryption ?? 'SSL',
|
||||
smtpUser: credentials.user,
|
||||
success: true,
|
||||
messageId: result.messageId,
|
||||
smtpResponse: result.response,
|
||||
}).catch((err) => console.error('EmailLog write error:', err));
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
messageId: result.messageId,
|
||||
@@ -203,6 +232,26 @@ export async function sendEmail(
|
||||
}
|
||||
}
|
||||
|
||||
// E-Mail-Log erstellen (Fehler)
|
||||
if (logContext) {
|
||||
import('./emailLog.service.js').then(({ createEmailLog }) => {
|
||||
createEmailLog({
|
||||
fromAddress,
|
||||
toAddress: Array.isArray(params.to) ? params.to.join(', ') : params.to,
|
||||
subject: params.subject,
|
||||
context: logContext.context,
|
||||
customerId: logContext.customerId,
|
||||
triggeredBy: logContext.triggeredBy,
|
||||
smtpServer: credentials.host,
|
||||
smtpPort: credentials.port,
|
||||
smtpEncryption: credentials.encryption ?? 'SSL',
|
||||
smtpUser: credentials.user,
|
||||
success: false,
|
||||
errorMessage,
|
||||
}).catch((err) => console.error('EmailLog write error:', err));
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: errorMessage,
|
||||
|
||||
Reference in New Issue
Block a user