'use server'; import { sendEmail } from '@/lib/mail/mailer'; import { getServerAppServices } from '@/lib/services/create-services.server'; export async function submitAnnotations(annotations: any[]) { const services = getServerAppServices(); const logger = services.logger.child({ action: 'submitAnnotations' }); if (!annotations || annotations.length === 0) { return { success: false, error: 'Keine Korrekturen vorhanden.' }; } try { const jsonContent = JSON.stringify(annotations, null, 2); const htmlContent = `

Neue Website-Korrekturen (${annotations.length})

Es wurden neue Korrekturen über den Annotator eingereicht.

Die genauen Daten (inkl. Scroll-Positionen, Viewport und Zeitstempel) befinden sich hier:

${jsonContent}
      
`; const notificationResult = await sendEmail({ replyTo: 'info@e-tib.com', // Falls Rückfragen nötig subject: `[Korrekturen] ${annotations.length} neue Anmerkungen für E-TIB`, html: htmlContent }); if (!notificationResult.success) { logger.error('Annotation email FAILED', { error: notificationResult.error }); return { success: false, error: notificationResult.error }; } logger.info('Annotation email sent successfully', { count: annotations.length }); return { success: true }; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); logger.error('Failed to send annotations', { error: errorMsg }); return { success: false, error: errorMsg }; } }