feat: return post list + delete post for public api

This commit is contained in:
Nevo David 2025-01-07 17:01:58 +07:00
parent 1969226022
commit a801b59610
2 changed files with 18 additions and 8 deletions

View File

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

View File

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