fix chan invite

This commit is contained in:
Alexandre POMMIER 2023-06-26 04:06:09 +02:00
parent 152d0541d4
commit cd6de16511
4 changed files with 18 additions and 11 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)
}

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View File

@ -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);
}

View File

@ -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