Add branded admin email creator
This commit is contained in:
1 parent
15bc6f063d
commit
6ebd701721
5 files changed
+281
No files matched your search
@@ -13,6 +13,7 @@ import {
|
||||
rencontrePasseeSchema,
|
||||
pastPhotoParam,
|
||||
emailComposeSchema,
|
||||
customEmailSchema,
|
||||
idParam,
|
||||
} from '../schemas.js';
|
||||
import { imageUpload, saveImage, deleteImage } from '../uploads.js';
|
||||
@@ -20,6 +21,7 @@ import { ensureMemberAccess } from '../memberAccess.js';
|
||||
import { createStaffUser, resetStaffAccess } from '../userAccess.js';
|
||||
import { AccessError } from '../errors.js';
|
||||
import { buildInvitationEmail } from '../emailTemplate.js';
|
||||
import { buildCustomEmail } from '../customEmailTemplate.js';
|
||||
|
||||
export const adminRouter = Router();
|
||||
|
||||
@@ -270,6 +272,21 @@ adminRouter.get('/rencontres/:id/inscriptions', validate(idParam, 'params'), asy
|
||||
}
|
||||
});
|
||||
|
||||
// General-purpose branded email composer, reserved to administrators.
|
||||
adminRouter.post('/emails/preview', adminOnly, validate(customEmailSchema), async (req, res, next) => {
|
||||
try {
|
||||
const { base, ...content } = req.data;
|
||||
let baseUrl = `${req.protocol}://${req.get('host')}`;
|
||||
if (base) {
|
||||
const parsed = new URL(base);
|
||||
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') baseUrl = parsed.origin;
|
||||
}
|
||||
res.json(buildCustomEmail({ content, baseUrl }));
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// ---------- Rencontres passées (admin + moderator manage; admin-only delete) ----------
|
||||
// Powers the "Rencontres passées" section on the home page and its dedicated
|
||||
// public page. Participant count is derived from the linked rencontre's
|
||||
|
||||
Reference in new issue
Block a user