feat: force fields check in public api
This commit is contained in:
parent
c6024e61d7
commit
3519889bc1
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue