fix newsletter routing and service

This commit is contained in:
Julian Krauser 2024-12-26 13:57:31 +01:00
parent 6dcd650cad
commit dad54c97ed
4 changed files with 12 additions and 13 deletions

View file

@ -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);
}

View file

@ -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[];

View file

@ -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);

View file

@ -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);
});
}
}