π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat: fixed refresh vulnerabilities and menu opening
Nevo Davidc0140614fc29
diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.tsindex f7c4ad74a..a394fe514 100644--- a/apps/backend/src/api/routes/integrations.controller.ts+++ b/apps/backend/src/api/routes/integrations.controller.ts@@ -1,12 +1,5 @@import {- Body,- Controller,- Delete,- Get,- Param,- Post,- Query,- UseFilters,+ Body, Controller, Delete, Get, Param, Post, Query, UseFilters} from '@nestjs/common';import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';import { ConnectIntegrationDto } from '@gitroom/nestjs-libraries/dtos/integrations/connect.integration.dto';@@ -29,6 +22,7 @@ import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/poimport { IntegrationTimeDto } from '@gitroom/nestjs-libraries/dtos/integrations/integration.time.dto';import { AuthService } from '@gitroom/helpers/auth/auth.service';import { AuthTokenDetails } from '@gitroom/nestjs-libraries/integrations/social/social.integrations.interface';+import { NotEnoughScopes } from '@gitroom/nestjs-libraries/integrations/social.abstract';@ApiTags('Integrations')@Controller('/integrations')@@ -354,7 +348,11 @@ export class IntegrationsController {});if (!id) {- throw new Error('Invalid api key');+ throw new NotEnoughScopes('Invalid API key');+ }++ if (refresh && id !== refresh) {+ throw new NotEnoughScopes('Please refresh the channel that needs to be refreshed');}return this._integrationService.createOrUpdateIntegration(diff --git a/apps/frontend/src/app/(site)/integrations/social/[provider]/continue/page.tsx b/apps/frontend/src/app/(site)/integrations/social/[provider]/continue/page.tsxindex 8a06e5424..97244c007 100644--- a/apps/frontend/src/app/(site)/integrations/social/[provider]/continue/page.tsx+++ b/apps/frontend/src/app/(site)/integrations/social/[provider]/continue/page.tsx@@ -28,7 +28,8 @@ export default async function Page({});if (data.status === HttpStatusCode.NotAcceptable) {- return redirect(`/launches?scope=missing`);+ const { msg } = await data.json();+ return redirect(`/launches?msg=${msg}`);}if (@@ -50,8 +51,8 @@ export default async function Page({const { inBetweenSteps, id } = await data.json();if (inBetweenSteps && !searchParams.refresh) {- return redirect(`/launches?added=${provider}&continue=${id}`);+ return redirect(`/launches?msg=Channel Refreshed&added=${provider}&continue=${id}`);}- return redirect(`/launches?added=${provider}`);+ return redirect(`/launches?added=${provider}&msg=Channel Added`);}diff --git a/apps/frontend/src/components/launches/launches.component.tsx b/apps/frontend/src/components/launches/launches.component.tsxindex 8134d4e6b..29666236f 100644--- a/apps/frontend/src/components/launches/launches.component.tsx+++ b/apps/frontend/src/components/launches/launches.component.tsx@@ -96,8 +96,8 @@ export const LaunchesComponent = () => {if (typeof window === 'undefined') {return;}- if (search.get('scope') === 'missing') {- toast.show('You have to approve all the channel permissions', 'warning');+ if (search.get('msg')) {+ toast.show(search.get('msg')!, 'warning');}if (search.get('added')) {fireEvents('channel_added');diff --git a/apps/frontend/src/components/launches/menu/menu.tsx b/apps/frontend/src/components/launches/menu/menu.tsxindex c31930ec2..d6f6b2276 100644--- a/apps/frontend/src/components/launches/menu/menu.tsx+++ b/apps/frontend/src/components/launches/menu/menu.tsx@@ -1,4 +1,4 @@-import { FC, useCallback, useState } from 'react';+import { FC, MouseEventHandler, useCallback, useState } from 'react';import { useClickOutside } from '@mantine/hooks';import { useFetch } from '@gitroom/helpers/utils/custom.fetch';import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';@@ -36,7 +36,8 @@ export const Menu: FC<{setShow(false);});- const changeShow = useCallback(() => {+ const changeShow: MouseEventHandler<HTMLDivElement> = useCallback((e) => {+ e.stopPropagation();setShow(!show);}, [show]);diff --git a/libraries/nestjs-libraries/src/integrations/integration.missing.scopes.ts b/libraries/nestjs-libraries/src/integrations/integration.missing.scopes.tsindex f3c55ec1c..998aba86b 100644--- a/libraries/nestjs-libraries/src/integrations/integration.missing.scopes.ts+++ b/libraries/nestjs-libraries/src/integrations/integration.missing.scopes.ts@@ -9,6 +9,6 @@ export class NotEnoughScopesFilter implements ExceptionFilter {const ctx = host.switchToHttp();const response = ctx.getResponse<Response>();- response.status(HttpStatusCode.NotAcceptable).json({ invalid: true });+ response.status(HttpStatusCode.NotAcceptable).json({ msg: exception.message });}}diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.tsindex cc3002720..b30497f69 100644--- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts+++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts@@ -13,7 +13,9 @@ export class BadBody {) {}}-export class NotEnoughScopes {}+export class NotEnoughScopes {+ constructor(public message = 'Not enough scopes') {}+}export abstract class SocialAbstract {async fetch(url: string, options: RequestInit = {}, identifier = '') {