Skip to content

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

feat: return post list + delete post for public api

Nevo Davida801b59610e0
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 74185e593..05dd16cc8 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
@@ -1,12 +1,5 @@
import {
- Body,
- Controller,
- Get,
- HttpException,
- Post,
- Query,
- UploadedFile,
- UseInterceptors,
+ Body, Controller, Delete, Get, HttpException, Param, Post, Query, UploadedFile, UseInterceptors
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { GetOrgFromRequest } from '@gitroom/nestjs-libraries/user/org.from.request';
@@ -76,6 +69,15 @@ export class PublicIntegrationsController {
return this._postsService.createPost(org.id, body);
}
+ @Delete('/posts/:id')
+ async deletePost(
+ @GetOrgFromRequest() org: Organization,
+ @Param() body: { id: string }
+ ) {
+ const getPostById = await this._postsService.getPost(org.id, body.id);
+ return this._postsService.deletePost(org.id, getPostById.group);
+ }
+
@Get('/integrations')
async listIntegration(@GetOrgFromRequest() org: Organization) {
return (await this._integrationService.getIntegrationsList(org.id)).map(
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 d6d2155e0..38a1cf687 100644
--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
@@ -549,6 +549,7 @@ export class PostsService {
}
async createPost(orgId: string, body: CreatePostDto) {
+ const postList = [];
for (const post of body.posts) {
const { previousPost, posts } =
await this._postRepository.createOrUpdatePost(
@@ -596,7 +597,14 @@ export class PostsService {
},
});
}
+
+ postList.push({
+ postId: posts[0].id,
+ integration: post.integration.id,
+ })
}
+
+ return postList;
}
async changeDate(orgId: string, id: string, date: string) {