join room dto

This commit is contained in:
simplonco
2023-01-05 19:48:38 +01:00
parent 26150f6761
commit d201060dcf
5 changed files with 54 additions and 37 deletions

View File

@@ -2,6 +2,7 @@ import { Controller, UseGuards, HttpException, HttpStatus, Get, Post, Body, Req,
import { AuthenticateGuard, TwoFactorGuard } from 'src/auth/42/guards/42guards';
import { ChatService } from './chat.service';
import { User } from 'src/users/entities/user.entity';
import { joinRoomDto } from './dto/joinRoom.dto';
@Controller('chat')
export class ChatController {
@@ -13,7 +14,7 @@ export class ChatController {
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Get('rooms')
async get_rooms() {
async getRooms() {
const rooms = await this.chatService.getRooms();
return { rooms };
}
@@ -21,11 +22,11 @@ export class ChatController {
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Post('join')
async join_room(@Body() body, @Req() req, @Res() res) {
async joinRoom(@Body() joinRoomDto: joinRoomDto, @Req() req, @Res() res) {
console.log("------ create :");
console.log(typeof body);
console.log(body);
console.log(body.room_name);
console.log(typeof joinRoomDto);
console.log(joinRoomDto);
console.log(joinRoomDto.room_name);
//const { room_name } = body;
//const user: User = req.user;
@@ -36,7 +37,7 @@ export class ChatController {
//return { message: 'Successfully joined room.' };
//return res.status(HttpStatus.BAD_REQUEST).json({message : 'You can\'t grant a ticket to another user'});
return body;
return joinRoomDto;
}
@UseGuards(AuthenticateGuard)

View File

@@ -0,0 +1,14 @@
import { IsBoolean, IsEmpty, IsInt, IsNotEmpty, IsNumber, IsString } from "class-validator";
import { IsNull } from "typeorm";
export class joinRoomDto {
@IsString()
@IsNotEmpty()
room_name : string
@IsString()
@IsNotEmpty()
room_type : string
@IsString()
room_password : string
}

View File

@@ -10348,7 +10348,7 @@ var app = (function () {
const { console: console_1$8 } = globals;
const file$h = "src/pieces/chat/Layout_create.svelte";
// (39:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
// (40:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
function create_default_slot_2$3(ctx) {
let t;
@@ -10368,14 +10368,14 @@ var app = (function () {
block,
id: create_default_slot_2$3.name,
type: "slot",
source: "(39:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
source: "(40:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
ctx
});
return block;
}
// (44:1) <Button my_class="create deactivate">
// (45:1) <Button my_class="create deactivate">
function create_default_slot_1$3(ctx) {
let t;
@@ -10395,14 +10395,14 @@ var app = (function () {
block,
id: create_default_slot_1$3.name,
type: "slot",
source: "(44:1) <Button my_class=\\\"create deactivate\\\">",
source: "(45:1) <Button my_class=\\\"create deactivate\\\">",
ctx
});
return block;
}
// (49:1) <Button bind:layout new_layout="close" my_class="close icon">
// (50:1) <Button bind:layout new_layout="close" my_class="close icon">
function create_default_slot$5(ctx) {
let t;
@@ -10422,14 +10422,14 @@ var app = (function () {
block,
id: create_default_slot$5.name,
type: "slot",
source: "(49:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
source: "(50:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
ctx
});
return block;
}
// (75:3) {#if room_type === 'protected'}
// (76:3) {#if room_type === 'protected'}
function create_if_block$b(ctx) {
let div;
let label;
@@ -10448,10 +10448,10 @@ var app = (function () {
t1 = space();
input = element("input");
attr_dev(p, "class", "svelte-1b1eu8h");
add_location(p, file$h, 76, 28, 2038);
add_location(p, file$h, 77, 28, 2094);
attr_dev(label, "for", "chat_pswd");
attr_dev(label, "class", "svelte-1b1eu8h");
add_location(label, file$h, 76, 5, 2015);
add_location(label, file$h, 77, 5, 2071);
attr_dev(input, "id", "chat_pswd");
attr_dev(input, "type", "password");
attr_dev(input, "placeholder", "minimum 8 characters");
@@ -10459,9 +10459,9 @@ var app = (function () {
attr_dev(input, "name", "password");
input.required = true;
attr_dev(input, "class", "svelte-1b1eu8h");
add_location(input, file$h, 77, 5, 2078);
add_location(input, file$h, 78, 5, 2134);
attr_dev(div, "class", "svelte-1b1eu8h");
add_location(div, file$h, 75, 4, 2004);
add_location(div, file$h, 76, 4, 2060);
},
m: function mount(target, anchor) {
insert_dev(target, div, anchor);
@@ -10492,7 +10492,7 @@ var app = (function () {
block,
id: create_if_block$b.name,
type: "if",
source: "(75:3) {#if room_type === 'protected'}",
source: "(76:3) {#if room_type === 'protected'}",
ctx
});
@@ -10623,17 +10623,17 @@ var app = (function () {
t15 = space();
input4 = element("input");
attr_dev(p0, "class", "svelte-1b1eu8h");
add_location(p0, file$h, 56, 26, 1201);
add_location(p0, file$h, 57, 26, 1257);
attr_dev(label0, "for", "chat_name");
attr_dev(label0, "class", "svelte-1b1eu8h");
add_location(label0, file$h, 56, 3, 1178);
add_location(label0, file$h, 57, 3, 1234);
attr_dev(input0, "id", "chat_name");
attr_dev(input0, "name", "room_name");
input0.required = true;
attr_dev(input0, "class", "svelte-1b1eu8h");
add_location(input0, file$h, 57, 3, 1235);
add_location(input0, file$h, 58, 3, 1291);
attr_dev(p1, "class", "svelte-1b1eu8h");
add_location(p1, file$h, 60, 4, 1378);
add_location(p1, file$h, 61, 4, 1434);
attr_dev(input1, "id", "chat_public");
attr_dev(input1, "type", "radio");
attr_dev(input1, "name", "room_type");
@@ -10642,12 +10642,12 @@ var app = (function () {
input1.required = true;
attr_dev(input1, "class", "svelte-1b1eu8h");
/*$$binding_groups*/ ctx[10][0].push(input1);
add_location(input1, file$h, 61, 4, 1396);
add_location(input1, file$h, 62, 4, 1452);
attr_dev(label1, "for", "chat_public");
attr_dev(label1, "class", "_radio svelte-1b1eu8h");
add_location(label1, file$h, 59, 3, 1333);
add_location(label1, file$h, 60, 3, 1389);
attr_dev(p2, "class", "svelte-1b1eu8h");
add_location(p2, file$h, 65, 4, 1584);
add_location(p2, file$h, 66, 4, 1640);
attr_dev(input2, "id", "chat_private");
attr_dev(input2, "type", "radio");
attr_dev(input2, "name", "room_type");
@@ -10656,12 +10656,12 @@ var app = (function () {
input2.required = true;
attr_dev(input2, "class", "svelte-1b1eu8h");
/*$$binding_groups*/ ctx[10][0].push(input2);
add_location(input2, file$h, 66, 4, 1603);
add_location(input2, file$h, 67, 4, 1659);
attr_dev(label2, "for", "chat_private");
attr_dev(label2, "class", "_radio svelte-1b1eu8h");
add_location(label2, file$h, 64, 3, 1538);
add_location(label2, file$h, 65, 3, 1594);
attr_dev(p3, "class", "svelte-1b1eu8h");
add_location(p3, file$h, 70, 4, 1797);
add_location(p3, file$h, 71, 4, 1853);
attr_dev(input3, "id", "chat_protected");
attr_dev(input3, "type", "radio");
attr_dev(input3, "name", "room_type");
@@ -10670,20 +10670,20 @@ var app = (function () {
input3.required = true;
attr_dev(input3, "class", "svelte-1b1eu8h");
/*$$binding_groups*/ ctx[10][0].push(input3);
add_location(input3, file$h, 71, 4, 1818);
add_location(input3, file$h, 72, 4, 1874);
attr_dev(label3, "for", "chat_protected");
attr_dev(label3, "class", "_radio svelte-1b1eu8h");
add_location(label3, file$h, 69, 3, 1749);
add_location(label3, file$h, 70, 3, 1805);
attr_dev(input4, "type", "submit");
input4.value = "⮡";
attr_dev(input4, "class", "svelte-1b1eu8h");
add_location(input4, file$h, 80, 3, 2242);
add_location(input4, file$h, 81, 3, 2298);
attr_dev(form, "class", "svelte-1b1eu8h");
add_location(form, file$h, 54, 2, 1110);
add_location(form, file$h, 55, 2, 1166);
attr_dev(div0, "class", "panel panel_create __border_top svelte-1b1eu8h");
add_location(div0, file$h, 53, 1, 1062);
add_location(div0, file$h, 54, 1, 1118);
attr_dev(div1, "class", "grid_box svelte-1b1eu8h");
add_location(div1, file$h, 35, 0, 717);
add_location(div1, file$h, 36, 0, 773);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -10858,7 +10858,8 @@ var app = (function () {
let formData = { room_name, room_type, room_password };
console.log("formData:", formData);
const response = await fetch(`http://${'transcendance'}:${'8080'}/api/v2/chat/join`, {
//const response = await fetch(`http://${'transcendance'}:${'8080'}/api/v2/chat/join`, {
const response = await fetch('/api/v2/chat/join', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData)

File diff suppressed because one or more lines are too long

View File

@@ -23,7 +23,8 @@
};
console.log("formData:", formData);
const response = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/chat/join`, {
//const response = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/chat/join`, {
const response = await fetch('/api/v2/chat/join', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData),