Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: force fields check in public api

Nevo David3519889bc14d
diff --git a/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts b/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts
index 60c6befe2..bb5843008 100644
--- a/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts
+++ b/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts
@@ -69,7 +69,8 @@ export class PublicIntegrationsController {
@GetOrgFromRequest() org: Organization,
@Body() rawBody: any
) {
- const body = await this._postsService.mapTypeToPost(rawBody, org.id);
+ const body = await this._postsService.mapTypeToPost(rawBody, org.id, rawBody.type === 'draft');
+ body.type = rawBody.type;
console.log(JSON.stringify(body, null, 2));
return this._postsService.createPost(org.id, body);
diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
index 3bdc60d3a..1889280e7 100644
--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
@@ -74,7 +74,8 @@ export class PostsService {
async mapTypeToPost(
body: CreatePostDto,
- organization: string
+ organization: string,
+ replaceDraft: boolean = false
): Promise<CreatePostDto> {
if (!body?.posts?.every((p) => p?.integration?.id)) {
throw new BadRequestException('All posts must have an integration id');
@@ -82,6 +83,7 @@ export class PostsService {
const mappedValues = {
...body,
+ type: replaceDraft ? 'schedule': body.type,
posts: await Promise.all(
body.posts.map(async (post) => {
const integration = await this._integrationService.getIntegrationById(