Fix scheduled WhatsApp messages sending as email; add 24h cleanup and recipient display
The scheduled-job store never persisted the channel field, so the send worker always fell through to its email branch regardless of what was requested. Also purges sent jobs 24h after sending instead of keeping them forever, and surfaces who each scheduled job will go to in the admin "manage scheduled" lists (now correctly filtered per channel too). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1569,6 +1569,15 @@ const whatsappEventAttendees = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Human-readable summary of who an attendees-scoped send will go to, for the scheduled-jobs admin UI
|
||||
function describeAttendeeFilter(filter) {
|
||||
if (Array.isArray(filter?.attendeeIds) && filter.attendeeIds.length > 0) {
|
||||
return `${filter.attendeeIds.length} selected attendee${filter.attendeeIds.length === 1 ? '' : 's'}`;
|
||||
}
|
||||
const labels = { paid: 'Paid attendees', unpaid: 'Unpaid attendees', partial_paid: 'Partially paid attendees', cancelled: 'Cancelled registrations' };
|
||||
return labels[filter?.status] || 'All attendees';
|
||||
}
|
||||
|
||||
// @desc Schedule email to attendees at a specific date/time
|
||||
// @route POST /api/events/:id/email-attendees/schedule
|
||||
// @access Private/Supervisor or Admin
|
||||
@@ -1600,6 +1609,7 @@ const scheduleEmailEventAttendees = async (req, res) => {
|
||||
eventId,
|
||||
createdById: req.user?.id || null,
|
||||
scheduledAt: when.toISOString(),
|
||||
recipientSummary: `${event.title} — ${describeAttendeeFilter(filter)}`,
|
||||
payload,
|
||||
});
|
||||
|
||||
@@ -1637,6 +1647,7 @@ const scheduleWhatsappEventAttendees = async (req, res) => {
|
||||
channel: 'whatsapp',
|
||||
createdById: req.user?.id || null,
|
||||
scheduledAt: when.toISOString(),
|
||||
recipientSummary: `${event.title} — ${describeAttendeeFilter(filter)}`,
|
||||
payload,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user