wip unblock socket
This commit is contained in:
@@ -532,10 +532,25 @@ export class ChatController {
|
|||||||
{
|
{
|
||||||
printCaller("- in ");
|
printCaller("- in ");
|
||||||
|
|
||||||
|
await this.chatService.setBlockUser(req.user.username, username);
|
||||||
let user_socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
let user_socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||||
user_socket.join(`${username}_not_emit`);
|
user_socket.join(`${username}_not_emit`);
|
||||||
|
|
||||||
res.status(HttpStatus.OK).json({ message: "successfull unmute" });
|
res.status(HttpStatus.OK).json({ message: "successfull block" });
|
||||||
|
printCaller("- out ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthenticateGuard)
|
||||||
|
@UseGuards(TwoFactorGuard)
|
||||||
|
@Post('unblock')
|
||||||
|
async unBlockUser(@Body('username') username: string, @Req() req, @Res() res): Promise<void>
|
||||||
|
{
|
||||||
|
printCaller("- in ");
|
||||||
|
|
||||||
|
let user_socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||||
|
user_socket.leave(`${username}_not_emit`);
|
||||||
|
|
||||||
|
res.status(HttpStatus.OK).json({ message: "successfull unblock" });
|
||||||
printCaller("- out ");
|
printCaller("- out ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,6 +298,14 @@ export class ChatService {
|
|||||||
printCaller("-- out ");
|
printCaller("-- out ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setBlockUser(username: string, to_block_username: string): Promise<void>
|
||||||
|
{
|
||||||
|
printCaller("-- in ");
|
||||||
|
|
||||||
|
|
||||||
|
printCaller("-- out ");
|
||||||
|
}
|
||||||
|
|
||||||
/* ADDERS *************************************************
|
/* ADDERS *************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export class User {
|
|||||||
email: string;
|
email: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
image_url : string;
|
image_url: string;
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
phone: string;
|
phone: string;
|
||||||
@@ -57,4 +57,7 @@ export class User {
|
|||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
currentRoom: string; // chatroom name
|
currentRoom: string; // chatroom name
|
||||||
|
|
||||||
|
@Column("simple-array", { nullable: true })
|
||||||
|
blockedUsers: string[]; // usernames
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import { layout, current_room, settings_user } from './Store_chat';
|
import { layout, current_room, settings_user } from './Store_chat';
|
||||||
import { get_is_admin, make_admin, set_block_user } from './Request_rooms';
|
import { get_is_admin, make_admin, set_block_user, remove_block_user } from './Request_rooms';
|
||||||
import type { FetchResponse } from './Types_chat';
|
import type { FetchResponse } from './Types_chat';
|
||||||
import { to_print } from './Utils_chat';
|
import { to_print } from './Utils_chat';
|
||||||
import Button from './Element_button.svelte';
|
import Button from './Element_button.svelte';
|
||||||
@@ -37,6 +37,12 @@
|
|||||||
await set_block_user($settings_user);
|
await set_block_user($settings_user);
|
||||||
layout.set("room");
|
layout.set("room");
|
||||||
}
|
}
|
||||||
|
async function unblock_user()
|
||||||
|
{
|
||||||
|
to_print("in unblock_user");
|
||||||
|
await remove_block_user($settings_user);
|
||||||
|
layout.set("room");
|
||||||
|
}
|
||||||
async function make_user_admin()
|
async function make_user_admin()
|
||||||
{
|
{
|
||||||
to_print("in make_user_admin");
|
to_print("in make_user_admin");
|
||||||
@@ -88,6 +94,9 @@
|
|||||||
<Button on:click={block_user}>
|
<Button on:click={block_user}>
|
||||||
block
|
block
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button on:click={unblock_user}>
|
||||||
|
unblock
|
||||||
|
</Button>
|
||||||
|
|
||||||
{#if is_admin && back === "room_set" && $current_room.type !== "direct"}
|
{#if is_admin && back === "room_set" && $current_room.type !== "direct"}
|
||||||
<Button on:click={make_user_admin}>
|
<Button on:click={make_user_admin}>
|
||||||
|
|||||||
@@ -231,3 +231,10 @@ export async function set_block_user(username: string): Promise<void>
|
|||||||
await fetch_chat_request('block', FetchMethod.POST, {username: username} );
|
await fetch_chat_request('block', FetchMethod.POST, {username: username} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function remove_block_user(username: string): Promise<void>
|
||||||
|
{
|
||||||
|
to_print("in set_block_user");
|
||||||
|
|
||||||
|
await fetch_chat_request('unblock', FetchMethod.POST, {username: username} );
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user