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> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/17 01:00:00 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) const user = await this.userService.findOne(data.username)
if (!user) if (!user)
return (0); return (0);
console.log(`CALL IT!!!!!`)
return await this.userService.newInvite(user, req.user.username); return await this.userService.newInvite(user, req.user.username);
} }
@ -451,7 +452,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/quit') @Post('/quit')
async setOffline(@Request() req) { async setOffline(@Request() req) {
console.log("cc quit here");
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
user.status = 0; user.status = 0;
@ -567,7 +568,7 @@ export class AppController {
} }
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/invite') @Post('/inviteConv')
async inviteUser(@Body() data: any) { async inviteUser(@Body() data: any) {
return await this.chatService.inviteUser(data.convId, data.username) return await this.chatService.inviteUser(data.convId, data.username)
} }

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/17 01:00:25 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) { async inviteUser(convId: number, username: string) {
// const conv = await this.findConv(convId); const conv = await this.findConv(convId);
// this.save(conv);
//find user if (conv.members.find(item => item === username))
//add in chanInvite chanID return (1);
//save user conv.members.push(username);
this.save(conv);
} }

View File

@ -207,7 +207,8 @@ const ModalSetting = ({handleClose, convId, socket }: ModalSettingProps) => {
const handleInvite = async () => { const handleInvite = async () => {
try{ try{
await api.post("/invite", {convId: convId, username: selectedUser}) console.log("post invite bitch")
await api.post("/inviteConv", {convId: convId, username: selectedUser})
} catch(err) { } catch(err) {
console.log(err); console.log(err);
} }

View File

@ -3,6 +3,7 @@ version: "3.3"
services: services:
nginx: nginx:
restart: unless-stopped
image: nginx:alpine image: nginx:alpine
container_name: nginx container_name: nginx
env_file: .env env_file: .env
@ -18,6 +19,7 @@ services:
- pongNetwork - pongNetwork
react_app: react_app:
restart: unless-stopped
image: node:latest image: node:latest
container_name: react_app container_name: react_app
working_dir: /app working_dir: /app
@ -34,6 +36,7 @@ services:
api: api:
restart: unless-stopped
image: node:latest image: node:latest
container_name: api container_name: api
working_dir: /app working_dir: /app
@ -49,9 +52,9 @@ services:
entrypoint: ["sh", "-c" , "npm install && npm run start:dev"] entrypoint: ["sh", "-c" , "npm install && npm run start:dev"]
postgresql: postgresql:
restart: unless-stopped
env_file: .env env_file: .env
image: postgres:14.1-alpine image: postgres:14.1-alpine
restart: unless-stopped
container_name: postgresql container_name: postgresql
environment: environment:
- POSTGRES_USER=postgres - POSTGRES_USER=postgres
@ -65,6 +68,7 @@ services:
- pongNetwork - pongNetwork
pong: pong:
restart: unless-stopped
image: node:latest image: node:latest
container_name: pong container_name: pong
working_dir: /app working_dir: /app
@ -78,6 +82,7 @@ services:
entrypoint: ["sh", "-c" , "npm install && npm run start:dev"] entrypoint: ["sh", "-c" , "npm install && npm run start:dev"]
chat: chat:
restart: unless-stopped
image: node:latest image: node:latest
container_name: chat container_name: chat
working_dir: /app working_dir: /app