Skip to content

Commit

Permalink
feat: comments, preview, duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
nevo-david committed Jan 1, 2025
2 parents 357c942 + 396a55f commit 62da0cd
Show file tree
Hide file tree
Showing 23 changed files with 727 additions and 518 deletions.
2 changes: 0 additions & 2 deletions apps/backend/src/api/api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { SettingsController } from '@gitroom/backend/api/routes/settings.control
import { PostsController } from '@gitroom/backend/api/routes/posts.controller';
import { MediaController } from '@gitroom/backend/api/routes/media.controller';
import { UploadModule } from '@gitroom/nestjs-libraries/upload/upload.module';
import { CommentsController } from '@gitroom/backend/api/routes/comments.controller';
import { BillingController } from '@gitroom/backend/api/routes/billing.controller';
import { NotificationsController } from '@gitroom/backend/api/routes/notifications.controller';
import { MarketplaceController } from '@gitroom/backend/api/routes/marketplace.controller';
Expand All @@ -35,7 +34,6 @@ const authenticatedController = [
SettingsController,
PostsController,
MediaController,
CommentsController,
BillingController,
NotificationsController,
MarketplaceController,
Expand Down
82 changes: 0 additions & 82 deletions apps/backend/src/api/routes/comments.controller.ts

This file was deleted.

20 changes: 16 additions & 4 deletions apps/backend/src/api/routes/posts.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GeneratorDto } from '@gitroom/nestjs-libraries/dtos/generator/generator
import { CreateGeneratedPostsDto } from '@gitroom/nestjs-libraries/dtos/generator/create.generated.posts.dto';
import { AgentGraphService } from '@gitroom/nestjs-libraries/agent/agent.graph.service';
import { Response } from 'express';
import { GetUserFromRequest } from '@gitroom/nestjs-libraries/user/user.from.request';

@ApiTags('Posts')
@Controller('/posts')
Expand All @@ -45,10 +46,14 @@ export class PostsController {
return this._messagesService.getMarketplaceAvailableOffers(org.id, id);
}

@Post('/posts/generate-image')
@CheckPolicies([AuthorizationActions.Create, Sections.POSTS_PER_MONTH])
generateImage(@Body() body: { text: string; type: string }) {

@Post('/:id/comments')
async createComment(
@GetOrgFromRequest() org: Organization,
@GetUserFromRequest() user: User,
@Param('id') id: string,
@Body() body: { comment: string }
) {
return this._postsService.createComment(org.id, user.id, id, body.comment);
}

@Get('/')
Expand All @@ -71,6 +76,13 @@ export class PostsController {
};
}

@Get('/find-slot')
async findSlot(
@GetOrgFromRequest() org: Organization,
) {
return {date: await this._postsService.findFreeDateTime(org.id)}
}

@Get('/predict-trending')
predictTrending() {
return this._starsService.predictTrending();
Expand Down
32 changes: 28 additions & 4 deletions apps/backend/src/api/routes/public.controller.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Body, Controller, Get, Param, Post, Req, Res } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { AgenciesService } from '@gitroom/nestjs-libraries/database/prisma/agencies/agencies.service';
import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/posts.service';
import { TrackService } from '@gitroom/nestjs-libraries/track/track.service';
import { RealIP } from 'nestjs-real-ip';
import { UserAgent } from '@gitroom/nestjs-libraries/user/user.agent';
import { TrackEnum } from '@gitroom/nestjs-libraries/user/track.enum';
import { Request, Response } from 'express';
import { GetUserFromRequest } from '@gitroom/nestjs-libraries/user/user.from.request';
import { User } from '@prisma/client';
import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
import { getCookieUrlFromDomain } from '@gitroom/helpers/subdomain/subdomain.management';
import { AgentGraphService } from '@gitroom/nestjs-libraries/agent/agent.graph.service';
import { AgentGraphInsertService } from '@gitroom/nestjs-libraries/agent/agent.graph.insert.service';

@ApiTags('Public')
Expand All @@ -19,7 +17,8 @@ export class PublicController {
constructor(
private _agenciesService: AgenciesService,
private _trackService: TrackService,
private _agentGraphInsertService: AgentGraphInsertService
private _agentGraphInsertService: AgentGraphInsertService,
private _postsService: PostsService
) {}
@Post('/agent')
async createAgent(@Body() body: { text: string; apiKey: string }) {
Expand Down Expand Up @@ -53,6 +52,31 @@ export class PublicController {
return this._agenciesService.getCount();
}

@Get(`/posts/:id`)
async getPreview(@Param('id') id: string) {
return (await this._postsService.getPostsRecursively(id, true)).map(
({ childrenPost, ...p }) => ({
...p,
...(p.integration
? {
integration: {
id: p.integration.id,
name: p.integration.name,
picture: p.integration.picture,
providerIdentifier: p.integration.providerIdentifier,
profile: p.integration.profile,
},
}
: {}),
})
);
}

@Get(`/posts/:id/comments`)
async getComments(@Param('id') postId: string) {
return { comments: await this._postsService.getComments(postId) };
}

@Post('/t')
async trackEvent(
@Res() res: Response,
Expand Down
6 changes: 6 additions & 0 deletions apps/frontend/src/app/(preview)/p/[id]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ReactNode } from 'react';
import { PreviewWrapper } from '@gitroom/frontend/components/preview/preview.wrapper';

export default async function AppLayout({ children }: { children: ReactNode }) {
return <PreviewWrapper>{children}</PreviewWrapper>;
}
Loading

0 comments on commit 62da0cd

Please sign in to comment.