Skip to content

Commit 3519889

Browse files
committed
feat: force fields check in public api
1 parent c6024e6 commit 3519889

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

apps/backend/src/public-api/routes/v1/public.integrations.controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export class PublicIntegrationsController {
6969
@GetOrgFromRequest() org: Organization,
7070
@Body() rawBody: any
7171
) {
72-
const body = await this._postsService.mapTypeToPost(rawBody, org.id);
72+
const body = await this._postsService.mapTypeToPost(rawBody, org.id, rawBody.type === 'draft');
73+
body.type = rawBody.type;
7374

7475
console.log(JSON.stringify(body, null, 2));
7576
return this._postsService.createPost(org.id, body);

libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ export class PostsService {
7474

7575
async mapTypeToPost(
7676
body: CreatePostDto,
77-
organization: string
77+
organization: string,
78+
replaceDraft: boolean = false
7879
): Promise<CreatePostDto> {
7980
if (!body?.posts?.every((p) => p?.integration?.id)) {
8081
throw new BadRequestException('All posts must have an integration id');
8182
}
8283

8384
const mappedValues = {
8485
...body,
86+
type: replaceDraft ? 'schedule': body.type,
8587
posts: await Promise.all(
8688
body.posts.map(async (post) => {
8789
const integration = await this._integrationService.getIntegrationById(

0 commit comments

Comments
 (0)