diff --git a/apps/backend/src/api/api.module.ts b/apps/backend/src/api/api.module.ts
index 5e0ecc97..133758d0 100644
--- a/apps/backend/src/api/api.module.ts
+++ b/apps/backend/src/api/api.module.ts
@@ -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';
@@ -35,7 +34,6 @@ const authenticatedController = [
SettingsController,
PostsController,
MediaController,
- CommentsController,
BillingController,
NotificationsController,
MarketplaceController,
diff --git a/apps/backend/src/api/routes/comments.controller.ts b/apps/backend/src/api/routes/comments.controller.ts
deleted file mode 100644
index 8669a688..00000000
--- a/apps/backend/src/api/routes/comments.controller.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-import {Body, Controller, Delete, Get, Param, Post, Put} from '@nestjs/common';
-import { CommentsService } from '@gitroom/nestjs-libraries/database/prisma/comments/comments.service';
-import { GetOrgFromRequest } from '@gitroom/nestjs-libraries/user/org.from.request';
-import { Organization, User } from '@prisma/client';
-import { GetUserFromRequest } from '@gitroom/nestjs-libraries/user/user.from.request';
-import { AddCommentDto } from '@gitroom/nestjs-libraries/dtos/comments/add.comment.dto';
-import {ApiTags} from "@nestjs/swagger";
-
-@ApiTags('Comments')
-@Controller('/comments')
-export class CommentsController {
- constructor(private _commentsService: CommentsService) {}
-
- @Post('/')
- addComment(
- @GetOrgFromRequest() org: Organization,
- @GetUserFromRequest() user: User,
- @Body() addCommentDto: AddCommentDto
- ) {
- return this._commentsService.addAComment(
- org.id,
- user.id,
- addCommentDto.content,
- addCommentDto.date
- );
- }
-
- @Post('/:id')
- addCommentTocComment(
- @GetOrgFromRequest() org: Organization,
- @GetUserFromRequest() user: User,
- @Body() addCommentDto: AddCommentDto,
- @Param('id') id: string
- ) {
- return this._commentsService.addACommentToComment(
- org.id,
- user.id,
- id,
- addCommentDto.content,
- addCommentDto.date
- );
- }
-
- @Put('/:id')
- editComment(
- @GetOrgFromRequest() org: Organization,
- @GetUserFromRequest() user: User,
- @Body() addCommentDto: AddCommentDto,
- @Param('id') id: string
- ) {
- return this._commentsService.updateAComment(
- org.id,
- user.id,
- id,
- addCommentDto.content
- );
- }
-
- @Delete('/:id')
- deleteComment(
- @GetOrgFromRequest() org: Organization,
- @GetUserFromRequest() user: User,
- @Param('id') id: string
- ) {
- return this._commentsService.deleteAComment(
- org.id,
- user.id,
- id,
- );
- }
-
- @Get('/:date')
- loadAllCommentsAndSubCommentsForADate(
- @GetOrgFromRequest() org: Organization,
- @Param('date') date: string
- ) {
- return this._commentsService.loadAllCommentsAndSubCommentsForADate(
- org.id,
- date
- );
- }
-}
diff --git a/apps/backend/src/api/routes/posts.controller.ts b/apps/backend/src/api/routes/posts.controller.ts
index 1aea47c7..314ad5c6 100644
--- a/apps/backend/src/api/routes/posts.controller.ts
+++ b/apps/backend/src/api/routes/posts.controller.ts
@@ -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')
@@ -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('/')
@@ -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();
diff --git a/apps/backend/src/api/routes/public.controller.ts b/apps/backend/src/api/routes/public.controller.ts
index 44ff199f..604178fb 100644
--- a/apps/backend/src/api/routes/public.controller.ts
+++ b/apps/backend/src/api/routes/public.controller.ts
@@ -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')
@@ -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 }) {
@@ -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,
diff --git a/apps/frontend/src/app/(preview)/p/[id]/layout.tsx b/apps/frontend/src/app/(preview)/p/[id]/layout.tsx
new file mode 100644
index 00000000..6a60756a
--- /dev/null
+++ b/apps/frontend/src/app/(preview)/p/[id]/layout.tsx
@@ -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 {children};
+}
diff --git a/apps/frontend/src/app/(preview)/p/[id]/page.tsx b/apps/frontend/src/app/(preview)/p/[id]/page.tsx
new file mode 100644
index 00000000..c31686cc
--- /dev/null
+++ b/apps/frontend/src/app/(preview)/p/[id]/page.tsx
@@ -0,0 +1,170 @@
+import { internalFetch } from '@gitroom/helpers/utils/internal.fetch';
+
+export const dynamic = 'force-dynamic';
+
+import { Metadata } from 'next';
+import { isGeneralServerSide } from '@gitroom/helpers/utils/is.general.server.side';
+import Image from 'next/image';
+import Link from 'next/link';
+import { CommentsComponents } from '@gitroom/frontend/components/preview/comments.components';
+import dayjs from 'dayjs';
+import utc from 'dayjs/plugin/utc';
+import { VideoOrImage } from '@gitroom/react/helpers/video.or.image';
+import { CopyClient } from '@gitroom/frontend/components/preview/copy.client';
+
+dayjs.extend(utc);
+export const metadata: Metadata = {
+ title: `${isGeneralServerSide() ? 'Postiz' : 'Gitroom'} Preview`,
+ description: '',
+};
+
+export default async function Auth({
+ params: { id },
+ searchParams,
+}: {
+ params: { id: string };
+ searchParams?: { share?: string };
+}) {
+ const post = await (await internalFetch(`/public/posts/${id}`)).json();
+
+ if (!post.length) {
+ return (
+
+ Post not found
+
+ );
+ }
+
+ return (
+
+
+
+
+
+ {!!searchParams?.share && (
+
+
+
+ )}
+
+ Publication Date:{' '}
+ {dayjs
+ .utc(post[0].createdAt)
+ .local()
+ .format('MMMM D, YYYY h:mm A')}
+
+
+
+
+
+
+
+
+ {post.map((p: any, index: number) => (
+
+
+
+
+
+
![{post[0].integration.name}]({post[0].integration.picture})
+
+
+
![{post[0].integration.providerIdentifier}]({`/icons/platforms/${post[0].integration.providerIdentifier}.png`})
+
+
+
+
+
+
+ {post[0].integration.name}
+
+
+ @{post[0].integration.profile}
+
+
+
+
+
+ {JSON.parse(p?.image || '[]').map((p: any) => (
+
+
+
+ ))}
+
+
+
+
+
+ ))}
+
+
+
+
+
+ );
+}
diff --git a/apps/frontend/src/components/launches/add.provider.component.tsx b/apps/frontend/src/components/launches/add.provider.component.tsx
index f7e58044..2cdbcb30 100644
--- a/apps/frontend/src/components/launches/add.provider.component.tsx
+++ b/apps/frontend/src/components/launches/add.provider.component.tsx
@@ -38,8 +38,25 @@ export const AddProviderButton: FC<{ update?: () => void }> = (props) => {
const { update } = props;
const add = useAddProvider(update);
return (
-