diff --git a/back/volume/src/auth/auth.controller.ts b/back/volume/src/auth/auth.controller.ts index a380cad..318ac34 100644 --- a/back/volume/src/auth/auth.controller.ts +++ b/back/volume/src/auth/auth.controller.ts @@ -6,7 +6,8 @@ import { Res, Req, Post, - Body + Body, + BadRequestException } from '@nestjs/common' import { Response, Request } from 'express' @@ -54,7 +55,7 @@ export class AuthController { async VerifyEmail (@Profile42() profile: Profile): Promise { const ftId: number = profile.id const user = await this.usersService.findUser(ftId) - if (user == null) throw new Error('User not found') + if (user == null) throw new BadRequestException('User not found') await this.authService.sendConfirmationEmail(user) } diff --git a/back/volume/src/auth/mails/confirm.hbs b/back/volume/src/auth/mails/confirm.hbs index fbcb9c5..24c45c2 100644 --- a/back/volume/src/auth/mails/confirm.hbs +++ b/back/volume/src/auth/mails/confirm.hbs @@ -8,7 +8,7 @@

Hello {{username}}!

Once you clicked on the next verify button, you will have access to the app

-
+
diff --git a/back/volume/src/chat/chat.controller.ts b/back/volume/src/chat/chat.controller.ts index c70efd6..a8e760b 100644 --- a/back/volume/src/chat/chat.controller.ts +++ b/back/volume/src/chat/chat.controller.ts @@ -35,11 +35,11 @@ export class ChatController { @Profile42() profile: Profile, @Param('otherName') otherName: string ): Promise { - const user = await this.usersService.findUser(profile.fdId) + const user = await this.usersService.findUser(+profile.id) const other = await this.usersService.findUserByName(otherName) const channels = await this.channelService.getChannelsForUser(+profile.id) - if (user === null) { + if (user === null || other === null) { throw new BadRequestException('User not found') } const dms = channels.filter((channel: Channel) => { @@ -50,10 +50,19 @@ export class ChatController { (channel.password === undefined || channel.password === '') ) }) - dms.forEach((c) => { - c.users.forEach((u) => (u.socketKey = '')) - c.admins.forEach((u) => (u.socketKey = '')) - c.owner.socketKey = '' + if (dms && dms.length === 0) { + throw new BadRequestException('No DMS found') + } + dms.forEach((c) => { + if (c.users) { + c.users.forEach((u) => (u.socketKey = '')) + } + if (c.admins) { + c.admins.forEach((u) => (u.socketKey = '')) + } + if (c.owner) { + c.owner.socketKey = '' + } }) return dms } @@ -65,7 +74,7 @@ export class ChatController { @Profile42() profile: Profile ): Promise { const channel = await this.channelService.getFullChannel(id) - const user: User | null = await this.usersService.findUser(target.id) + const user: User | null = await this.usersService.getFullUser(target.id) if (user == null) { throw new NotFoundException(`User #${target.id} not found`) } diff --git a/back/volume/src/chat/entity/channel.entity.ts b/back/volume/src/chat/entity/channel.entity.ts index 94e9d30..da82f44 100644 --- a/back/volume/src/chat/entity/channel.entity.ts +++ b/back/volume/src/chat/entity/channel.entity.ts @@ -40,7 +40,7 @@ export default class Channel { @JoinTable() users: User[] - @OneToMany(() => Message, (message: Message) => message.channel) + @OneToMany(() => Message, (message: Message) => message.channel, {onDelete:'CASCADE'}) messages: Message[] @ManyToOne(() => User) diff --git a/back/volume/src/chat/entity/message.entity.ts b/back/volume/src/chat/entity/message.entity.ts index e44b4a3..f338f12 100644 --- a/back/volume/src/chat/entity/message.entity.ts +++ b/back/volume/src/chat/entity/message.entity.ts @@ -22,7 +22,7 @@ export default class Message { @JoinColumn() author: User - @ManyToOne(() => Channel, (channel) => channel.messages, { cascade: true }) + @ManyToOne(() => Channel, (channel) => channel.messages, {onDelete:'CASCADE'} ) @JoinTable() channel: Channel diff --git a/back/volume/src/pong/game/constants.ts b/back/volume/src/pong/game/constants.ts index 4516899..49eafb2 100644 --- a/back/volume/src/pong/game/constants.ts +++ b/back/volume/src/pong/game/constants.ts @@ -16,7 +16,7 @@ export const DEFAULT_MAP_SIZE = new Point(500, 400) export const DEFAULT_PADDLE_SIZE = new Point(30, 50) export const DEFAULT_BALL_SIZE = new Point(10, 10) export const DEFAULT_BALL_INITIAL_SPEED = new Point(10, 2) -export const DEFAULT_MAX_BALL_SPEED = new Point(30, 20) +export const DEFAULT_MAX_BALL_SPEED = new Point(20, 20) export const DEFAULT_BALL_SPEED_INCREMENT = new Point(0.05, 0) export const DEFAULT_WIN_SCORE = 5 export const GAME_TICKS = 30 diff --git a/docker-compose.yml b/docker-compose.yml index d6b48eb..501063f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.8' +version: "3.8" networks: transcendence: @@ -31,26 +31,7 @@ services: image: postgres ports: [5432:5432] volumes: - - ./postgres:/var/lib/postgresql/data + - ./postgres:/var/lib/postgresql/data networks: [transcendence] restart: always env_file: .env - pgadmin: - links: - - postgres:postgres - container_name: pgadmin - image: dpage/pgadmin4 - ports: - - "8081:80" - volumes: - - /data/pgadmin:/root/.pgadmin - environment: - PGADMIN_DEFAULT_EMAIL: 'usr@usr.com' - PGADMIN_DEFAULT_PASSWORD: 'pw' - GUNICORN_ACCESS_LOGFILE: '/dev/null' - PGADMIN_CONFIG_UPGRADE_CHECK_ENABLED: 'False' - depends_on: - - postgres - networks: [transcendence] - logging: - driver: none diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 31e7c93..8b970b9 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -93,25 +93,27 @@ setAppState(APPSTATE.PROFILE_ID); } - async function getDMs(username: string): Promise { - const response = await fetch(API_URL + "/channels/dms/" + username, { - credentials: "include", - mode: "cors", - }); - return response; + async function getDMs(username: string): Promise { + const res = await fetch(API_URL + "/channels/dms/" + username, { + credentials: "include", + mode: "cors", + }) + if (res.ok) + return res; + else + return null; } let chan: Channels; async function openDirectChat(event: CustomEvent) { - const DMUsername = "test"; - // const DMUsername = event.detail; + const DMUsername = event.detail; let DMChannel: Array = []; - const res = await getDMs($store.username) - if (res.ok) { + const res = await getDMs(DMUsername) + if (res && res.ok) { DMChannel = await res.json(); - if (DMChannel.length != 0) { + if (DMChannel.length != 0) chan.selectChat(DMChannel[0].id); - } else { + } else { console.log("Creating DMChannel: " + $store.username + "&" + DMUsername) fetch(API_URL + "/channels", { credentials: "include", @@ -129,8 +131,8 @@ otherDMedUsername: DMUsername }), }).then(async () => { - const response = await getDMs($store.username) - if (response.ok) { + const response = await getDMs(DMUsername) + if (response && response.ok) { DMChannel = await response.json(); if (DMChannel.length != 0) { chan.selectChat(DMChannel[0].id); @@ -141,13 +143,10 @@ alert("Error creating DM"); } }).catch((error) => { - alert(error.message); + alert("Error creating DM"); }) } - } else { - alert("Error creating DM"); } - } async function clickHistory() { setAppState(APPSTATE.HISTORY); diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte index 1753a91..e584a1f 100644 --- a/front/volume/src/components/Channels.svelte +++ b/front/volume/src/components/Channels.svelte @@ -54,7 +54,7 @@