diff --git a/src/api/auth/controllers/auth.controller.ts b/src/api/auth/controllers/auth.controller.ts index 7c10ff669..efaec0f0d 100644 --- a/src/api/auth/controllers/auth.controller.ts +++ b/src/api/auth/controllers/auth.controller.ts @@ -1,5 +1,4 @@ -import { Controller, Get, Post, Res, UseGuards } from '@nestjs/common'; -import { Response } from 'express'; +import { Controller, Get, Post, UseGuards } from '@nestjs/common'; import { ROUTES } from '../../utils/constants'; import { AuthUser } from '../../utils/decorators'; import { User } from "@prisma/client"; @@ -16,8 +15,8 @@ export class AuthController { @Get('redirect') @UseGuards(DiscordAuthGuard) - redirect(@AuthUser() user: User) { - return user; + redirect() { + return "Authenticated" } @Get('check') diff --git a/src/api/auth/utils/DiscordStrategy.ts b/src/api/auth/utils/DiscordStrategy.ts index f22815285..452c38caa 100644 --- a/src/api/auth/utils/DiscordStrategy.ts +++ b/src/api/auth/utils/DiscordStrategy.ts @@ -23,6 +23,7 @@ export class DiscordStrategy extends PassportStrategy(Strategy) { userId: profile.id, username: profile.username, discriminator: profile.discriminator, + avatar: `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.png`, accessToken, refreshToken, }); diff --git a/src/api/discord/controllers/discord.controller.ts b/src/api/discord/controllers/discord.controller.ts index 5a6531c3d..197e9867a 100644 --- a/src/api/discord/controllers/discord.controller.ts +++ b/src/api/discord/controllers/discord.controller.ts @@ -21,18 +21,9 @@ export class DiscordController { return data.filter((channel) => channel.type === 0); } - @Get('guilds/:guildId/bans') - async getGuildBans(@Param('guildId') guildId: string) { - const { data } = await this.discordService.getGuildBans(guildId); - return data; + @Get('user/:userId') + getUserDetails(@Param('userId') userId: string) { + return this.discordService.getUserDetails(userId); } - @Delete('guilds/:guildId/bans/:userId') - async deleteGuildBan( - @Param('guildId') guildId: string, - @Param('userId') userId: string, - ) { - const { data } = await this.discordService.deleteGuildBan(guildId, userId); - return data; - } } \ No newline at end of file diff --git a/src/api/discord/interfaces/discord-http.ts b/src/api/discord/interfaces/discord-http.ts index d5ffd41f0..e7ee5af3c 100644 --- a/src/api/discord/interfaces/discord-http.ts +++ b/src/api/discord/interfaces/discord-http.ts @@ -1,6 +1,5 @@ import { AxiosResponse } from 'axios'; import { - GuildBanType, PartialGuild, PartialGuildChannel, } from '../../utils/types'; @@ -11,7 +10,5 @@ export interface IDiscordHttpService { fetchGuildChannels( guildId: string, ): Promise>; - fetchGuildBans(guildId: string): Promise>; - deleteGuildBan(guildId: string, userId: string): Promise; - + fetchUserDetails(accessToken: string): Promise>; } \ No newline at end of file diff --git a/src/api/discord/interfaces/discord.ts b/src/api/discord/interfaces/discord.ts index df818d178..f5871eade 100644 --- a/src/api/discord/interfaces/discord.ts +++ b/src/api/discord/interfaces/discord.ts @@ -1,5 +1,5 @@ import { AxiosResponse } from 'axios'; -import { GuildBanType, PartialGuildChannel } from '../../utils/types'; +import { PartialGuildChannel } from '../../utils/types'; export interface IDiscordService { getBotGuilds(); @@ -8,6 +8,5 @@ export interface IDiscordService { getGuildChannels( guildId: string, ): Promise>; - getGuildBans(guildId: string): Promise>; - deleteGuildBan(guildId: string, userId: string): Promise; + getUserDetails(accessToken: string): Promise>; } \ No newline at end of file diff --git a/src/api/discord/services/discord-http.service.ts b/src/api/discord/services/discord-http.service.ts index 8ee74e2c4..53b584f2b 100644 --- a/src/api/discord/services/discord-http.service.ts +++ b/src/api/discord/services/discord-http.service.ts @@ -2,7 +2,6 @@ import { Injectable } from '@nestjs/common'; import { IDiscordHttpService } from '../interfaces/discord-http'; import axios, { AxiosResponse } from 'axios'; import { - GuildBanType, PartialGuild, PartialGuildChannel, } from '../../utils/types'; @@ -37,28 +36,6 @@ export class DiscordHttpService implements IDiscordHttpService { }, ); } - - fetchGuildBans(guildId: string) { - return axios.get( - `${DISCORD_BASE_URL}/guilds/${guildId}/bans`, - { - headers: { - Authorization: `Bot ${config.token}`, - }, - }, - ); - } - - deleteGuildBan(guildId: string, userId: string): Promise { - return axios.delete( - `${DISCORD_BASE_URL}/guilds/${guildId}/bans/${userId}`, - { - headers: { - Authorization: `Bot ${config.token}`, - }, - }, - ); - } fetchUserDetails(accessToken: string) { return axios.get(`${DISCORD_BASE_URL}/users/@me`, { headers: { diff --git a/src/api/discord/services/discord.service.ts b/src/api/discord/services/discord.service.ts index 5b6ba0c9e..7672a01da 100644 --- a/src/api/discord/services/discord.service.ts +++ b/src/api/discord/services/discord.service.ts @@ -34,11 +34,7 @@ export class DiscordService implements IDiscordService { return this.discordHttpService.fetchGuildChannels(guildId); } - getGuildBans(guildId: string) { - return this.discordHttpService.fetchGuildBans(guildId); - } - - deleteGuildBan(guildId: string, userId: string): Promise { - return this.discordHttpService.deleteGuildBan(guildId, userId); + getUserDetails(accessToken: string) { + return this.discordHttpService.fetchUserDetails(accessToken); } } \ No newline at end of file diff --git a/src/api/utils/types.ts b/src/api/utils/types.ts index 49130a3e5..453d0e1da 100644 --- a/src/api/utils/types.ts +++ b/src/api/utils/types.ts @@ -5,6 +5,7 @@ export type UserDetails = { accessToken: string; refreshToken: string; username: string; + avatar: string; discriminator: string; };