commit
526b761405
|
|
@ -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/po
|
|||
import { 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(
|
||||
|
|
|
|||
|
|
@ -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`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = '') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue