wip unblock socket
This commit is contained in:
@@ -532,10 +532,25 @@ export class ChatController {
|
||||
{
|
||||
printCaller("- in ");
|
||||
|
||||
await this.chatService.setBlockUser(req.user.username, username);
|
||||
let user_socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||
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 ");
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +298,14 @@ export class ChatService {
|
||||
printCaller("-- out ");
|
||||
}
|
||||
|
||||
async setBlockUser(username: string, to_block_username: string): Promise<void>
|
||||
{
|
||||
printCaller("-- in ");
|
||||
|
||||
|
||||
printCaller("-- out ");
|
||||
}
|
||||
|
||||
/* ADDERS *************************************************
|
||||
*/
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export class User {
|
||||
email: string;
|
||||
|
||||
@Column()
|
||||
image_url : string;
|
||||
image_url: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
phone: string;
|
||||
@@ -57,4 +57,7 @@ export class User {
|
||||
|
||||
@Column({ nullable: true })
|
||||
currentRoom: string; // chatroom name
|
||||
|
||||
@Column("simple-array", { nullable: true })
|
||||
blockedUsers: string[]; // usernames
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
|
||||
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 { to_print } from './Utils_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
@@ -37,6 +37,12 @@
|
||||
await set_block_user($settings_user);
|
||||
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()
|
||||
{
|
||||
to_print("in make_user_admin");
|
||||
@@ -88,6 +94,9 @@
|
||||
<Button on:click={block_user}>
|
||||
block
|
||||
</Button>
|
||||
<Button on:click={unblock_user}>
|
||||
unblock
|
||||
</Button>
|
||||
|
||||
{#if is_admin && back === "room_set" && $current_room.type !== "direct"}
|
||||
<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} );
|
||||
}
|
||||
|
||||
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