diff --git a/containers/api/src/app.controller.ts b/containers/api/src/app.controller.ts index b503c806..342c41f0 100644 --- a/containers/api/src/app.controller.ts +++ b/containers/api/src/app.controller.ts @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/17 01:00:00 by apommier #+# #+# */ -/* Updated: 2023/06/26 02:23:56 by apommier ### ########.fr */ +/* Updated: 2023/06/26 03:23:42 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -150,6 +150,7 @@ export class AppController { const user = await this.userService.findOne(data.username) if (!user) return (0); + console.log(`CALL IT!!!!!`) return await this.userService.newInvite(user, req.user.username); } @@ -451,7 +452,7 @@ export class AppController { @UseGuards(JwtAuthGuard) @Post('/quit') async setOffline(@Request() req) { - console.log("cc quit here"); + const user = await this.userService.findOne(req.user.username); user.status = 0; @@ -567,7 +568,7 @@ export class AppController { } @UseGuards(JwtAuthGuard) - @Post('/invite') + @Post('/inviteConv') async inviteUser(@Body() data: any) { return await this.chatService.inviteUser(data.convId, data.username) } diff --git a/containers/api/src/chat/chat.service.ts b/containers/api/src/chat/chat.service.ts index 3825f32f..56f5755b 100644 --- a/containers/api/src/chat/chat.service.ts +++ b/containers/api/src/chat/chat.service.ts @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/17 01:00:25 by apommier #+# #+# */ -/* Updated: 2023/06/26 02:07:45 by apommier ### ########.fr */ +/* Updated: 2023/06/26 04:02:50 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -91,12 +91,12 @@ async banUser(convId: number, username: string) { } async inviteUser(convId: number, username: string) { - // const conv = await this.findConv(convId); - // this.save(conv); + const conv = await this.findConv(convId); - //find user - //add in chanInvite chanID - //save user + if (conv.members.find(item => item === username)) + return (1); + conv.members.push(username); + this.save(conv); } diff --git a/containers/react/src/components/Messages/ModalSetting.tsx b/containers/react/src/components/Messages/ModalSetting.tsx index ec8a2500..5b24f87d 100644 --- a/containers/react/src/components/Messages/ModalSetting.tsx +++ b/containers/react/src/components/Messages/ModalSetting.tsx @@ -207,7 +207,8 @@ const ModalSetting = ({handleClose, convId, socket }: ModalSettingProps) => { const handleInvite = async () => { try{ - await api.post("/invite", {convId: convId, username: selectedUser}) + console.log("post invite bitch") + await api.post("/inviteConv", {convId: convId, username: selectedUser}) } catch(err) { console.log(err); } diff --git a/docker-compose.yml b/docker-compose.yml index d15b89f4..c22f5d90 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: "3.3" services: nginx: + restart: unless-stopped image: nginx:alpine container_name: nginx env_file: .env @@ -18,6 +19,7 @@ services: - pongNetwork react_app: + restart: unless-stopped image: node:latest container_name: react_app working_dir: /app @@ -34,6 +36,7 @@ services: api: + restart: unless-stopped image: node:latest container_name: api working_dir: /app @@ -49,9 +52,9 @@ services: entrypoint: ["sh", "-c" , "npm install && npm run start:dev"] postgresql: + restart: unless-stopped env_file: .env image: postgres:14.1-alpine - restart: unless-stopped container_name: postgresql environment: - POSTGRES_USER=postgres @@ -65,6 +68,7 @@ services: - pongNetwork pong: + restart: unless-stopped image: node:latest container_name: pong working_dir: /app @@ -78,6 +82,7 @@ services: entrypoint: ["sh", "-c" , "npm install && npm run start:dev"] chat: + restart: unless-stopped image: node:latest container_name: chat working_dir: /app