feat: enhance contact addition with bulk email lookup and subscription options

This commit is contained in:
Dries Augustyns
2026-05-01 19:44:48 +02:00
parent 9fafeb7d4b
commit bb72911fa2
8 changed files with 334 additions and 125 deletions
+2 -2
View File
@@ -155,7 +155,7 @@ export class Segments {
public async addMembers(req: Request, res: Response, _next: NextFunction) {
const auth = res.locals.auth;
const segmentId = req.params.id;
const {emails} = req.body;
const {emails, createMissing, subscribed} = req.body as {emails: string[]; createMissing?: boolean; subscribed?: boolean};
if (!segmentId) {
return res.status(400).json({error: 'Segment ID is required'});
@@ -165,7 +165,7 @@ export class Segments {
return res.status(400).json({error: 'emails must be a non-empty array'});
}
const result = await SegmentService.addContacts(auth.projectId!, segmentId, emails);
const result = await SegmentService.addContacts(auth.projectId!, segmentId, emails, createMissing ?? false, subscribed ?? true);
return res.status(200).json(result);
}