feat: CalDAV-Integration für Admin-Kalender
- Neue CalDAV-Route mit PROPFIND und GET-Endpoints - ICS-Format-Generator für Buchungsdaten - Token-basierte Authentifizierung für CalDAV-Zugriff - Admin-Interface mit CalDAV-Link-Generator - Schritt-für-Schritt-Anleitung für Kalender-Apps - 24h-Token-Ablaufzeit für Sicherheit - Unterstützung für Outlook, Google Calendar, Apple Calendar, Thunderbird Fixes: Admin kann jetzt Terminkalender in externen Apps abonnieren
This commit is contained in:
88
server-dist/lib/email-validator.js
Normal file
88
server-dist/lib/email-validator.js
Normal file
@@ -0,0 +1,88 @@
|
||||
// Email validation using Rapid Email Validator API
|
||||
// API: https://rapid-email-verifier.fly.dev/
|
||||
// Privacy-focused, no data storage, completely free
|
||||
/**
|
||||
* Validate email address using Rapid Email Validator API
|
||||
* Returns true if email is valid, false otherwise
|
||||
*/
|
||||
export async function validateEmail(email) {
|
||||
try {
|
||||
// Call Rapid Email Validator API
|
||||
const response = await fetch(`https://rapid-email-verifier.fly.dev/api/validate?email=${encodeURIComponent(email)}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
});
|
||||
if (!response.ok) {
|
||||
console.error(`Email validation API error: ${response.status}`);
|
||||
// If API is down, reject the email with error message
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'E-Mail-Validierung ist derzeit nicht verfügbar. Bitte überprüfe deine E-Mail-Adresse und versuche es erneut.'
|
||||
};
|
||||
}
|
||||
const data = await response.json();
|
||||
// Check if email is disposable/temporary
|
||||
if (data.validations.is_disposable) {
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Temporäre oder Wegwerf-E-Mail-Adressen sind nicht erlaubt. Bitte verwende eine echte E-Mail-Adresse.',
|
||||
};
|
||||
}
|
||||
// Check if MX records exist (deliverable)
|
||||
if (!data.validations.mx_records) {
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Diese E-Mail-Adresse kann keine E-Mails empfangen. Bitte überprüfe deine E-Mail-Adresse.',
|
||||
};
|
||||
}
|
||||
// Check if domain exists
|
||||
if (!data.validations.domain_exists) {
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Die E-Mail-Domain existiert nicht. Bitte überprüfe deine E-Mail-Adresse.',
|
||||
};
|
||||
}
|
||||
// Check if email syntax is valid
|
||||
if (!data.validations.syntax) {
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Ungültige E-Mail-Adresse. Bitte überprüfe die Schreibweise.',
|
||||
};
|
||||
}
|
||||
// Email is valid
|
||||
return { valid: true };
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Email validation error:', error);
|
||||
// If validation fails, reject the email with error message
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'E-Mail-Validierung ist derzeit nicht verfügbar. Bitte überprüfe deine E-Mail-Adresse und versuche es erneut.'
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Batch validate multiple emails
|
||||
* @param emails Array of email addresses to validate
|
||||
* @returns Array of validation results
|
||||
*/
|
||||
export async function validateEmailBatch(emails) {
|
||||
const results = new Map();
|
||||
// Validate up to 100 emails at once (API limit)
|
||||
const batchSize = 100;
|
||||
for (let i = 0; i < emails.length; i += batchSize) {
|
||||
const batch = emails.slice(i, i + batchSize);
|
||||
// Call each validation in parallel for better performance
|
||||
const validations = await Promise.all(batch.map(async (email) => {
|
||||
const result = await validateEmail(email);
|
||||
return { email, result };
|
||||
}));
|
||||
// Store results
|
||||
validations.forEach(({ email, result }) => {
|
||||
results.set(email, result);
|
||||
});
|
||||
}
|
||||
return results;
|
||||
}
|
Reference in New Issue
Block a user