Skip to content

Commit 526b761

Browse files
authored
Merge pull request #407 from gitroomhq/feat/refresh-v
Refresh changes
2 parents b09cd71 + c3e7377 commit 526b761

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

apps/backend/src/api/routes/integrations.controller.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import {
2-
Body,
3-
Controller,
4-
Delete,
5-
Get,
6-
Param,
7-
Post,
8-
Query,
9-
UseFilters,
2+
Body, Controller, Delete, Get, Param, Post, Query, UseFilters
103
} from '@nestjs/common';
114
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
125
import { ConnectIntegrationDto } from '@gitroom/nestjs-libraries/dtos/integrations/connect.integration.dto';
@@ -29,6 +22,7 @@ import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/po
2922
import { IntegrationTimeDto } from '@gitroom/nestjs-libraries/dtos/integrations/integration.time.dto';
3023
import { AuthService } from '@gitroom/helpers/auth/auth.service';
3124
import { AuthTokenDetails } from '@gitroom/nestjs-libraries/integrations/social/social.integrations.interface';
25+
import { NotEnoughScopes } from '@gitroom/nestjs-libraries/integrations/social.abstract';
3226

3327
@ApiTags('Integrations')
3428
@Controller('/integrations')
@@ -354,7 +348,11 @@ export class IntegrationsController {
354348
});
355349

356350
if (!id) {
357-
throw new Error('Invalid api key');
351+
throw new NotEnoughScopes('Invalid API key');
352+
}
353+
354+
if (refresh && id !== refresh) {
355+
throw new NotEnoughScopes('Please refresh the channel that needs to be refreshed');
358356
}
359357

360358
return this._integrationService.createOrUpdateIntegration(

apps/frontend/src/app/(site)/integrations/social/[provider]/continue/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export default async function Page({
2828
});
2929

3030
if (data.status === HttpStatusCode.NotAcceptable) {
31-
return redirect(`/launches?scope=missing`);
31+
const { msg } = await data.json();
32+
return redirect(`/launches?msg=${msg}`);
3233
}
3334

3435
if (
@@ -50,8 +51,8 @@ export default async function Page({
5051
const { inBetweenSteps, id } = await data.json();
5152

5253
if (inBetweenSteps && !searchParams.refresh) {
53-
return redirect(`/launches?added=${provider}&continue=${id}`);
54+
return redirect(`/launches?msg=Channel Refreshed&added=${provider}&continue=${id}`);
5455
}
5556

56-
return redirect(`/launches?added=${provider}`);
57+
return redirect(`/launches?added=${provider}&msg=Channel Added`);
5758
}

apps/frontend/src/components/launches/launches.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export const LaunchesComponent = () => {
9696
if (typeof window === 'undefined') {
9797
return;
9898
}
99-
if (search.get('scope') === 'missing') {
100-
toast.show('You have to approve all the channel permissions', 'warning');
99+
if (search.get('msg')) {
100+
toast.show(search.get('msg')!, 'warning');
101101
}
102102
if (search.get('added')) {
103103
fireEvents('channel_added');

apps/frontend/src/components/launches/menu/menu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useCallback, useState } from 'react';
1+
import { FC, MouseEventHandler, useCallback, useState } from 'react';
22
import { useClickOutside } from '@mantine/hooks';
33
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
44
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
@@ -36,7 +36,8 @@ export const Menu: FC<{
3636
setShow(false);
3737
});
3838

39-
const changeShow = useCallback(() => {
39+
const changeShow: MouseEventHandler<HTMLDivElement> = useCallback((e) => {
40+
e.stopPropagation();
4041
setShow(!show);
4142
}, [show]);
4243

libraries/nestjs-libraries/src/integrations/integration.missing.scopes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export class NotEnoughScopesFilter implements ExceptionFilter {
99
const ctx = host.switchToHttp();
1010
const response = ctx.getResponse<Response>();
1111

12-
response.status(HttpStatusCode.NotAcceptable).json({ invalid: true });
12+
response.status(HttpStatusCode.NotAcceptable).json({ msg: exception.message });
1313
}
1414
}

libraries/nestjs-libraries/src/integrations/social.abstract.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export class BadBody {
1313
) {}
1414
}
1515

16-
export class NotEnoughScopes {}
16+
export class NotEnoughScopes {
17+
constructor(public message = 'Not enough scopes') {}
18+
}
1719

1820
export abstract class SocialAbstract {
1921
async fetch(url: string, options: RequestInit = {}, identifier = '') {

0 commit comments

Comments
 (0)