feat(gallery): publish notifies assigned customer accounts via the account email
Publishing a gallery with no inline customer_email but assigned customer account(s) previously sent nothing (the dialog said "no notification"). Now the publish route falls back to the existing customer_gallery_assigned "your galleries" email (sent per assigned active account in their preferred language) so registered customers learn the gallery is available. Inline-email path (gallery_created) is unchanged. The publish dialog now reflects this: with an inline email it notifies that address; with only assigned accounts it says the account(s) will be notified; with neither, the button is just "Publish" (no false notify promise). Exports notifyCustomerOfNewAssignments; EN/DE strings added.
This commit is contained in:
@@ -1189,6 +1189,22 @@ router.post('/:id/publish', adminAuth, requirePermission('events.edit'), require
|
||||
status: 'pending',
|
||||
created_at: new Date()
|
||||
});
|
||||
} else {
|
||||
// No inline email, but the gallery may be assigned to registered customer
|
||||
// account(s). Notify them via the account "your galleries" email
|
||||
// (customer_gallery_assigned, in the customer's own language) instead of
|
||||
// the gallery_created mail, which needs an inline recipient. Best-effort.
|
||||
try {
|
||||
const customerAccountsService = require('../services/customerAccountsService');
|
||||
const assigned = await customerAccountsService.getAssignmentsForEvent(parseInt(id, 10));
|
||||
for (const c of assigned.filter((a) => a.is_active !== false && a.is_active !== 0 && a.email)) {
|
||||
await customerAccountsService
|
||||
.notifyCustomerOfNewAssignments(c.id, [parseInt(id, 10)])
|
||||
.catch((err) => logger.warn('Publish: customer gallery notice failed', { customerId: c.id, error: err.message }));
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn('Publish: assigned-customer notification skipped', { eventId: id, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// WhatsApp gallery_ready on publish-from-draft (#640D). The PublishGallery
|
||||
|
||||
@@ -1456,6 +1456,7 @@ module.exports = {
|
||||
setAssignmentsForEvent,
|
||||
setAssignmentsForCustomer,
|
||||
getAssignmentsForEvent,
|
||||
notifyCustomerOfNewAssignments,
|
||||
listEventsForCustomer,
|
||||
customerHasAccessToEvent,
|
||||
getPendingInvitations,
|
||||
|
||||
Reference in New Issue
Block a user