diff --git a/src/controller/admin/newsletterController.ts b/src/controller/admin/newsletterController.ts index fa9f481..620687f 100644 --- a/src/controller/admin/newsletterController.ts +++ b/src/controller/admin/newsletterController.ts @@ -177,10 +177,6 @@ export async function synchronizeNewsletterById(req: Request, res: Response): Pr }; await NewsletterCommandHandler.sync(syncNewsletter); - if (recipientsByQueryId) { - // TODO! set all recipients to query selection - } - res.sendStatus(204); } diff --git a/src/entity/newsletter.ts b/src/entity/newsletter.ts index 0694d88..9393e53 100644 --- a/src/entity/newsletter.ts +++ b/src/entity/newsletter.ts @@ -27,6 +27,9 @@ export class newsletter { @Column({ type: "boolean", default: false }) isSent: boolean; + @Column({ type: "int", nullable: true }) + recipientsByQueryId?: number; + @OneToMany(() => newsletterDates, (dates) => dates.newsletter) dates: newsletterDates[]; diff --git a/src/routes/admin/newsletter.ts b/src/routes/admin/newsletter.ts index c721810..93bde92 100644 --- a/src/routes/admin/newsletter.ts +++ b/src/routes/admin/newsletter.ts @@ -24,19 +24,19 @@ router.get("/:id", async (req: Request, res: Response) => { await getNewsletterById(req, res); }); -router.get("/:protocolId/dates", async (req: Request, res: Response) => { +router.get("/:newsletterId/dates", async (req: Request, res: Response) => { await getNewsletterDatesById(req, res); }); -router.get("/:protocolId/recipients", async (req: Request, res: Response) => { +router.get("/:newsletterId/recipients", async (req: Request, res: Response) => { await getNewsletterRecipientsById(req, res); }); -router.get("/:protocolId/printouts", async (req: Request, res: Response) => { +router.get("/:newsletterId/printouts", async (req: Request, res: Response) => { await getNewsletterPrintoutsById(req, res); }); -router.get("/:protocolId/printout/:filename", async (req: Request, res: Response) => { +router.get("/:newsletterId/printout/:filename", async (req: Request, res: Response) => { await getNewsletterPrintoutByIdAndPrint(req, res); }); @@ -49,7 +49,7 @@ router.post( ); router.post( - "/:protocolId/printout", + "/:newsletterId/printout", PermissionHelper.passCheckMiddleware("create", "club", "protocol"), async (req: Request, res: Response) => { await createNewsletterPrintoutById(req, res); @@ -65,7 +65,7 @@ router.patch( ); router.patch( - "/:protocolId/synchronize/dates", + "/:newsletterId/synchronize/dates", PermissionHelper.passCheckMiddleware("update", "club", "protocol"), async (req: Request, res: Response) => { await synchronizeNewsletterDatesById(req, res); @@ -73,7 +73,7 @@ router.patch( ); router.patch( - "/:protocolId/synchronize/recipients", + "/:newsletterId/synchronize/recipients", PermissionHelper.passCheckMiddleware("update", "club", "protocol"), async (req: Request, res: Response) => { await synchronizeNewsletterRecipientsById(req, res); diff --git a/src/service/newsletterRecipientsService.ts b/src/service/newsletterRecipientsService.ts index 923ad0d..8e0f9a5 100644 --- a/src/service/newsletterRecipientsService.ts +++ b/src/service/newsletterRecipientsService.ts @@ -16,13 +16,13 @@ export default abstract class NewsletterRecipientsService { .leftJoinAndSelect("member.sendNewsletter", "sendNewsletter") .leftJoinAndSelect("sendNewsletter.type", "communicationtype") .leftJoinAndSelect("newsletterRecipients.newsletter", "newsletter") - .where("newsletterDates.newsletterId = :id", { id: newsletterId }) + .where("newsletterRecipients.newsletterId = :id", { id: newsletterId }) .getMany() .then((res) => { return res; }) .catch((err) => { - throw new InternalException("newsletterRecipientss not found", err); + throw new InternalException("newsletterRecipients not found", err); }); } }