From b65c7cddb92a1ab55e00c9a51912c49205f310f7 Mon Sep 17 00:00:00 2001 From: Ralitsa Ilieva Date: Mon, 12 Feb 2024 12:53:33 +0100 Subject: [PATCH] more campaign info added in campaign-news service --- .../campaign-news/campaign-news.service.ts | 24 ++++++++++++++++++- apps/api/src/campaign/campaign.controller.ts | 10 +++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/apps/api/src/campaign-news/campaign-news.service.ts b/apps/api/src/campaign-news/campaign-news.service.ts index a48d7a51b..02b6f6234 100644 --- a/apps/api/src/campaign-news/campaign-news.service.ts +++ b/apps/api/src/campaign-news/campaign-news.service.ts @@ -150,8 +150,14 @@ export class CampaignNewsService { newsFiles: true, campaign: { select: { + id: true, title: true, state: true, + campaignType: { + select: { + category: true, + }, + }, }, }, }, @@ -234,7 +240,23 @@ export class CampaignNewsService { async findArticleBySlug(slug: string) { return await this.prisma.campaignNews - .findFirst({ where: { slug: slug }, include: { newsFiles: true } }) + .findFirst({ + where: { slug: slug }, + include: { + newsFiles: true, + campaign: { + select: { + title: true, + state: true, + campaignType: { + select: { + category: true, + }, + }, + }, + }, + }, + }) .catch((error) => Logger.warn(error)) } diff --git a/apps/api/src/campaign/campaign.controller.ts b/apps/api/src/campaign/campaign.controller.ts index 8aa4909d1..7db219f01 100644 --- a/apps/api/src/campaign/campaign.controller.ts +++ b/apps/api/src/campaign/campaign.controller.ts @@ -128,12 +128,9 @@ export class CampaignController { } @Get('byId/:id') - @Roles({ - roles: [RealmViewSupporters.role, ViewSupporters.role], - mode: RoleMatchingMode.ANY, - }) + @Public() async findOne(@Param('id') id: string) { - return this.campaignService.getCampaignById(id) + return await this.campaignService.getCampaignById(id) } @Get('donations/:id') @@ -176,10 +173,9 @@ export class CampaignController { ) { if (data.consent === false) throw new BadRequestException('Notification consent should be provided') - // Subscribe to campaign notifications list await this.campaignService.subscribeToCampaignNotification(id, data) - + return { message: 'Success' } }