feat: Add daily event notification emails via cron job
- Add node-cron for scheduled tasks - Create cron/calendar structure with: - email-template.js: HTML email template for event notifications - event-notifier.js: Logic to query tomorrow's events and send emails - index.js: Cron scheduler (runs daily at configurable time) - Send notifications via JMAP using sender email from database - Add admin endpoint POST /api/admin/trigger-notifications for testing - Add env variables: NOTIFICATION_TIME, NOTIFICATION_SENDER_EMAIL 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as adminService from '../services/admin.service.js';
|
||||
import * as statusService from '../services/status.service.js';
|
||||
import { logUserCreation, logRoleChange } from '../services/audit.service.js';
|
||||
import { triggerEventNotifications } from '../cron/index.js';
|
||||
|
||||
/**
|
||||
* Vytvorenie nového usera s automatic temporary password (admin only)
|
||||
@@ -160,3 +161,21 @@ export const getServerStatus = async (req, res, next) => {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Manually trigger event notifications (admin only, for testing)
|
||||
* POST /api/admin/trigger-notifications
|
||||
*/
|
||||
export const triggerNotifications = async (req, res, next) => {
|
||||
try {
|
||||
const stats = await triggerEventNotifications();
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: stats,
|
||||
message: `Notifikácie odoslané: ${stats.sent}, neúspešné: ${stats.failed}, preskočené: ${stats.skipped}`,
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user