feat: force fields check in public api

This commit is contained in:
Nevo David 2025-07-10 13:36:16 +07:00
parent c6024e61d7
commit 3519889bc1
2 changed files with 5 additions and 2 deletions

View File

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

View File

@ -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(