fixed create form
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Controller, UseGuards, Get, Post, Body, Req } from '@nestjs/common';
|
||||
import { Controller, UseGuards, HttpException, HttpStatus, Get, Post, Body, Req, Res } from '@nestjs/common';
|
||||
import { AuthenticateGuard, TwoFactorGuard } from 'src/auth/42/guards/42guards';
|
||||
import { ChatService } from './chat.service';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
|
||||
@Controller('chat')
|
||||
export class ChatController {
|
||||
@@ -20,22 +21,21 @@ export class ChatController {
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Post('join')
|
||||
async join_room(@Body() body) {
|
||||
|
||||
async join_room(@Body() body, @Req() req, @Res() res) {
|
||||
console.log("------ create :");
|
||||
console.log(typeof body);
|
||||
console.log(body);
|
||||
console.log(body.room_name);
|
||||
const { room_name } = body;
|
||||
console.log("room_name:");
|
||||
console.log(room_name);
|
||||
//const { room_name } = body;
|
||||
|
||||
const { room_id } = body;
|
||||
// get user
|
||||
let user;
|
||||
await this.chatService.addUserToRoom(user, room_id);
|
||||
//const user: User = req.user;
|
||||
//const { user } = requete;
|
||||
// let user;
|
||||
//let room_name;
|
||||
//await this.chatService.addUserToRoom(user, room_name);
|
||||
|
||||
//return { message: 'Successfully joined room.' };
|
||||
//return res.status(HttpStatus.BAD_REQUEST).json({message : 'You can\'t grant a ticket to another user'});
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ import { UsersModule } from 'src/users/users.module';
|
||||
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Chatroom } from './entities/chat.entity';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([Chatroom]),
|
||||
TypeOrmModule.forFeature([Chatroom, User]),
|
||||
UsersModule,
|
||||
],
|
||||
controllers: [
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
|
||||
//import { InjectRepository } from '@nestjs/typeorm';
|
||||
//import { Repository } from 'typeorm';
|
||||
import { Chatroom } from './entities/chat.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class ChatService {
|
||||
|
||||
constructor(
|
||||
// @InjectRepository(User)
|
||||
// private readonly userRepository: Repository<User>,
|
||||
@InjectRepository(User)
|
||||
private readonly userRepository: Repository<User>,
|
||||
@InjectRepository(Chatroom)
|
||||
private readonly chatroomRepository: Repository<Chatroom>,
|
||||
) { }
|
||||
|
||||
//async add_message(server, message) {
|
||||
@@ -22,7 +24,7 @@ export class ChatService {
|
||||
// return rooms;
|
||||
}
|
||||
|
||||
async addUserToRoom(user: User, room_id: string)
|
||||
async addUserToRoom(user: User, room_name: string)
|
||||
{
|
||||
// get room
|
||||
//if !room
|
||||
@@ -30,7 +32,7 @@ export class ChatService {
|
||||
// add user to room
|
||||
}
|
||||
|
||||
async removeUserFromRoom(user: User, room_id: string)
|
||||
async removeUserFromRoom(user: User, room_name: string)
|
||||
{
|
||||
// get room
|
||||
// remove user
|
||||
|
||||
Reference in New Issue
Block a user