feat: Add manual event notification endpoint for admins
- POST /api/events/:eventId/notify - send notifications from admin's email - sendSingleEventNotification() uses admin's primary email account - getSenderAccountByUserId() to get admin's email credentials 🤖 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,4 +1,5 @@
|
||||
import * as eventService from '../services/event.service.js';
|
||||
import { triggerSingleEventNotification } from '../cron/index.js';
|
||||
|
||||
/**
|
||||
* Get calendar data (events + todos) by month
|
||||
@@ -106,3 +107,24 @@ export const deleteEvent = async (req, res, next) => {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Send notification for an event to all assigned users (admin only)
|
||||
* POST /api/events/:eventId/notify
|
||||
*/
|
||||
export const sendEventNotification = async (req, res, next) => {
|
||||
try {
|
||||
const { eventId } = req.params;
|
||||
const adminUserId = req.userId;
|
||||
|
||||
const stats = await triggerSingleEventNotification(eventId, adminUserId);
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: stats,
|
||||
message: `Notifikácie pre "${stats.eventTitle}" odoslané: ${stats.sent}, neúspešné: ${stats.failed}, preskočené: ${stats.skipped}`,
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user