interaction blocked users and view profile ok, still block message todo
This commit is contained in:
@@ -116,7 +116,7 @@ export class ChatController {
|
||||
const room_db = await this.chatService.getRoomByName(room_name, fields);
|
||||
const is_admin = room_db.admins.includes(req.user.username);
|
||||
|
||||
res.status(HttpStatus.OK).json({ is_admin: is_admin });
|
||||
res.status(HttpStatus.OK).json({ condition: is_admin });
|
||||
printCaller("- out ");
|
||||
}
|
||||
|
||||
@@ -418,6 +418,7 @@ export class ChatController {
|
||||
const room = await this.chatService.getRoomByName(room_name);
|
||||
const users = room.users;
|
||||
const admins = room.admins;
|
||||
const blocked = await this.chatService.getListBlockUser(req.user.username);
|
||||
|
||||
let index = users.indexOf(req.user.username);
|
||||
if (index > -1)
|
||||
@@ -429,9 +430,13 @@ export class ChatController {
|
||||
{
|
||||
name: username,
|
||||
isadmin: false,
|
||||
isblocked: false,
|
||||
};
|
||||
if (admins.includes(username))
|
||||
new_user.isadmin = true;
|
||||
if (blocked.includes(username))
|
||||
new_user.isblocked = true;
|
||||
console.log("new_user:", new_user);
|
||||
|
||||
return new_user;
|
||||
});
|
||||
@@ -532,7 +537,8 @@ export class ChatController {
|
||||
{
|
||||
printCaller("- in ");
|
||||
|
||||
await this.chatService.setBlockUser(req.user.username, username);
|
||||
await this.chatService.addBlockUser(req.user.username, username);
|
||||
|
||||
let user_socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||
user_socket.join(`${username}_not_emit`);
|
||||
|
||||
@@ -547,6 +553,7 @@ export class ChatController {
|
||||
{
|
||||
printCaller("- in ");
|
||||
|
||||
await this.chatService.removeBlockUser(req.user.username, username);
|
||||
let user_socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||
user_socket.leave(`${username}_not_emit`);
|
||||
|
||||
@@ -554,5 +561,26 @@ export class ChatController {
|
||||
printCaller("- out ");
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('listblock')
|
||||
async listBlockUser(@Req() req, @Res() res): Promise<void>
|
||||
{
|
||||
printCaller("- in ");
|
||||
|
||||
let block_users = await this.chatService.getListBlockUser(req.user.username);
|
||||
let users = block_users.map(user =>
|
||||
{
|
||||
return {
|
||||
name: user,
|
||||
isadmin: false,
|
||||
isblocked: true,
|
||||
}
|
||||
});
|
||||
|
||||
res.status(HttpStatus.OK).json({ users: users });
|
||||
printCaller("- out ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,17 @@ import { ChatController } from './chat.controller';
|
||||
import { ChatService } from './chat.service';
|
||||
import { ChatGateway } from './chat.gateway';
|
||||
import { UsersModule } from 'src/users/users.module';
|
||||
import { FriendshipsModule } from 'src/friendship/friendships.module';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Chatroom } from './entities/chatroom.entity';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { Friendship } from 'src/friendship/entities/friendship.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([Chatroom, User]),
|
||||
TypeOrmModule.forFeature([Chatroom, User, Friendship]),
|
||||
UsersModule,
|
||||
FriendshipsModule,
|
||||
],
|
||||
controllers: [
|
||||
ChatController,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { HttpException, HttpStatus, Injectable, Res } from '@nestjs/common';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { Friendship, FriendshipStatus } from 'src/friendship/entities/friendship.entity';
|
||||
import { Chatroom } from './entities/chatroom.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { FriendshipService } from 'src/friendship/friendship.service';
|
||||
import { SendableFriendship } from 'src/friendship/sendableFriendship';
|
||||
import { Repository, Brackets } from 'typeorm';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { roomDto } from './dto/room.dto';
|
||||
import { messagesDto } from './dto/messages.dto';
|
||||
@@ -17,10 +20,13 @@ export class ChatService {
|
||||
|
||||
constructor(
|
||||
private usersService: UsersService,
|
||||
private friendshipService: FriendshipService,
|
||||
@InjectRepository(User)
|
||||
private readonly userRepository: Repository<User>,
|
||||
@InjectRepository(Chatroom)
|
||||
private readonly chatroomRepository: Repository<Chatroom>,
|
||||
@InjectRepository(Friendship)
|
||||
private readonly friendshipRepository: Repository<Friendship>,
|
||||
) {}
|
||||
|
||||
// temp for test
|
||||
@@ -298,14 +304,111 @@ export class ChatService {
|
||||
printCaller("-- out ");
|
||||
}
|
||||
|
||||
async setBlockUser(username: string, to_block_username: string): Promise<void>
|
||||
async findOneRelationshipByUsername(friendUsername : string, username : string)
|
||||
{
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.leftJoinAndSelect('friendship.sender', 'sender')
|
||||
.leftJoinAndSelect('friendship.receiver', 'receiver')
|
||||
.where
|
||||
(
|
||||
new Brackets((qb) =>
|
||||
{
|
||||
qb.where
|
||||
(
|
||||
new Brackets((subAQb) =>
|
||||
{
|
||||
subAQb.where('sender.username = :username', {username : username})
|
||||
.andWhere('receiver.username = :friendUsername', {friendUsername : friendUsername})
|
||||
})
|
||||
)
|
||||
.orWhere
|
||||
(
|
||||
new Brackets((subBQb) =>
|
||||
{
|
||||
subBQb.where('sender.username = :friendUsername2', {friendUsername2 : friendUsername})
|
||||
.andWhere('receiver.username = :username2', {username2 : username})
|
||||
.andWhere('friendship.status != :status', {status : FriendshipStatus.BLOCKED})
|
||||
})
|
||||
)
|
||||
}),
|
||||
)
|
||||
.getOne()
|
||||
|
||||
if (!friendship)
|
||||
return null;
|
||||
return new SendableFriendship(friendship);
|
||||
}
|
||||
|
||||
async addBlockUser(username: string, to_block_username: string): Promise<void>
|
||||
{
|
||||
printCaller("-- in ");
|
||||
|
||||
let user = await this.getUserByName(username);
|
||||
let relation = await this.findOneRelationshipByUsername(to_block_username, username);
|
||||
if (relation)
|
||||
{
|
||||
let blocked_friendship = await this.friendshipService.blockFriendship(relation.id, user);
|
||||
}
|
||||
else
|
||||
{
|
||||
const newFriendshipDto = {"receiverUsername": to_block_username, "status": FriendshipStatus.BLOCKED};
|
||||
await this.friendshipService.create(newFriendshipDto, user);
|
||||
}
|
||||
|
||||
printCaller("-- out ");
|
||||
}
|
||||
|
||||
async removeBlockUser(username: string, to_unblock_username: string): Promise<void>
|
||||
{
|
||||
printCaller("-- in ");
|
||||
|
||||
let user = await this.getUserByName(username);
|
||||
let relation = await this.findOneRelationshipByUsername(to_unblock_username, username);
|
||||
await this.friendshipService.removeFriendship(relation.id, user);
|
||||
|
||||
printCaller("-- out ");
|
||||
}
|
||||
|
||||
async getListBlockUser(username: string): Promise<string[]>
|
||||
{
|
||||
printCaller("-- in ");
|
||||
|
||||
let user = await this.getUserByName(username);
|
||||
let friends_users = await this.friendshipService.findAllBlockedFriends(user.id);
|
||||
let users = friends_users.map(user => user.receiverUsername);
|
||||
console.log(users);
|
||||
|
||||
printCaller("-- out ");
|
||||
return users;
|
||||
}
|
||||
|
||||
/*
|
||||
// find list blocked
|
||||
|
||||
findAllBlockedFriends
|
||||
extract the receiver_username (i am the sender)
|
||||
|
||||
|
||||
// bock a user
|
||||
|
||||
findfriendshipbyname
|
||||
return friendship
|
||||
blockfriendship
|
||||
return nothing
|
||||
createfriendship
|
||||
return friendship (it worked)
|
||||
return http exception (cannot create friendship)
|
||||
|
||||
|
||||
// unblock
|
||||
|
||||
findfriendshipbyname
|
||||
return friendship
|
||||
removefriendship
|
||||
return nothing
|
||||
*/
|
||||
|
||||
/* ADDERS *************************************************
|
||||
*/
|
||||
|
||||
|
||||
@@ -57,7 +57,4 @@ export class User {
|
||||
|
||||
@Column({ nullable: true })
|
||||
currentRoom: string; // chatroom name
|
||||
|
||||
@Column("simple-array", { nullable: true })
|
||||
blockedUsers: string[]; // usernames
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
lines_width: "1px",
|
||||
lines_color: "rgb(30, 30, 30)",
|
||||
lines_light_color: "rgb(70, 70, 70)",
|
||||
bg_color: "rgb(251, 156, 81)",
|
||||
bg_color: "rgb(251, 139, 36)",
|
||||
bg_light_color: "rgb(251, 156, 81)",
|
||||
|
||||
btn_color: "rgb(220, 220, 220)",
|
||||
@@ -28,6 +28,8 @@
|
||||
chat_other_color: "rgb(250, 250, 250)",
|
||||
chat_other_bg_color: "rgb(190, 130, 70)",
|
||||
chat_serveur_color: "rgb(110, 110, 110)",
|
||||
chat_msg_bg_color: "rgb(251, 163, 80)",
|
||||
chat_conv_bg_color: "rgb(251, 163, 80)",
|
||||
}
|
||||
let style_dark =
|
||||
{
|
||||
@@ -53,6 +55,8 @@
|
||||
chat_other_color: "rgb( 90, 90, 90)",
|
||||
chat_other_bg_color: "rgb(210, 210, 210)",
|
||||
chat_serveur_color: "rgb(190, 190, 190)",
|
||||
chat_msg_bg_color: "rgb( 82, 82, 82)",
|
||||
chat_conv_bg_color: "rgb( 82, 82, 82)",
|
||||
}
|
||||
|
||||
let style = style_light;
|
||||
@@ -102,6 +106,8 @@
|
||||
--chat_other_color={style.chat_other_color}
|
||||
--chat_other_bg_color={style.chat_other_bg_color}
|
||||
--chat_serveur_color={style.chat_serveur_color}
|
||||
--chat_msg_bg_color={style.chat_msg_bg_color}
|
||||
--chat_conv_bg_color={style.chat_conv_bg_color}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
background-color: var(--bg_color);
|
||||
background-color: var(--chat_msg_bg_color);
|
||||
border: var(--lines_width) solid var(--lines_color);
|
||||
}
|
||||
.grid_box .text_area {
|
||||
@@ -132,6 +132,7 @@
|
||||
.grid_box .panel_msg {
|
||||
flex-direction: column-reverse;
|
||||
border: var(--lines_width) solid var(--lines_color);
|
||||
background-color: var(--chat_conv_bg_color);
|
||||
}
|
||||
.grid_box .msg_thread {
|
||||
width: 100%;
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
export let back = "";
|
||||
|
||||
let users: User[] = get_room_users();
|
||||
|
||||
let is_admin = false;
|
||||
get_is_admin().then(response => is_admin = response);
|
||||
|
||||
to_print("current_room:", $current_room);
|
||||
|
||||
function user_profile(username: string)
|
||||
function user_profile(room_user: string)
|
||||
{
|
||||
to_print("in user_profile");
|
||||
settings_user.set(username);
|
||||
settings_user.set(room_user);
|
||||
layout.set("user");
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@
|
||||
<p>list of users is loading...</p>
|
||||
{:then users}
|
||||
{#each users as user}
|
||||
<Button my_class="list admin" on:click={function(){user_profile(user.name)}}>
|
||||
<Button my_class="list admin {user.isblocked ? 'blocked' : ''}" on:click={function(){user_profile(user)}}>
|
||||
{user.name}
|
||||
{#if user.isadmin }
|
||||
<span>admin</span>
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
|
||||
import { layout } from './Store_chat';
|
||||
import { layout, settings_user } from './Store_chat';
|
||||
import { list_block_user } from './Request_rooms';
|
||||
import { User } from './Types_chat';
|
||||
import { to_print } from './Utils_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
let users: User[] = list_block_user();
|
||||
|
||||
function user_profile(room_user: string)
|
||||
{
|
||||
to_print("in user_profile");
|
||||
settings_user.set(room_user);
|
||||
layout.set("user");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
@@ -31,21 +43,15 @@
|
||||
<div class="__show_if_only_child">
|
||||
<p class="__center">/ you have blocked no one /</p>
|
||||
</div>
|
||||
<!-- placeholders
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 1
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 2
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 3
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 4
|
||||
</Button>
|
||||
------------- -->
|
||||
<!-- END placeholders -->
|
||||
{#await users}
|
||||
<p>list of users is loading...</p>
|
||||
{:then users}
|
||||
{#each users as user}
|
||||
<Button my_class="list blocked" on:click={function(){user_profile(user)}}>
|
||||
{user.name}
|
||||
</Button>
|
||||
{/each}
|
||||
{/await}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
export let back = "";
|
||||
|
||||
let mute = "mute";
|
||||
let block = "block";
|
||||
|
||||
let is_admin = false;
|
||||
get_is_admin().then(response => is_admin = response);
|
||||
|
||||
@@ -23,30 +20,36 @@
|
||||
function game_invitation()
|
||||
{
|
||||
to_print("in game_invitation");
|
||||
const username = $settings_user;
|
||||
const username = $settings_user.name;
|
||||
invited_username.set(username);
|
||||
push("/game");
|
||||
}
|
||||
function view_profile()
|
||||
{
|
||||
to_print("in view_profile");
|
||||
push(`/profile/users/${$settings_user.name}`);
|
||||
}
|
||||
async function block_user()
|
||||
{
|
||||
to_print("in block_user");
|
||||
await set_block_user($settings_user);
|
||||
await set_block_user($settings_user.name);
|
||||
layout.set("room");
|
||||
}
|
||||
async function unblock_user()
|
||||
{
|
||||
to_print("in unblock_user");
|
||||
await remove_block_user($settings_user);
|
||||
await remove_block_user($settings_user.name);
|
||||
layout.set("room");
|
||||
}
|
||||
async function get_list_block_user()
|
||||
{
|
||||
to_print("in get_list_block_user");
|
||||
await list_block_user();
|
||||
}
|
||||
async function make_user_admin()
|
||||
{
|
||||
to_print("in make_user_admin");
|
||||
response = await make_admin($settings_user);
|
||||
response = await make_admin($settings_user.name);
|
||||
//show errors
|
||||
if (response.status >= 300 || response.error)
|
||||
show_error = response.error;
|
||||
@@ -64,7 +67,7 @@
|
||||
|
||||
<!-- user -->
|
||||
<Button my_class="user deactivate">
|
||||
{$settings_user}
|
||||
{$settings_user.name}
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
@@ -91,19 +94,22 @@
|
||||
<Button on:click={game_invitation}>
|
||||
game invitation
|
||||
</Button>
|
||||
<Button on:click={block_user}>
|
||||
block
|
||||
</Button>
|
||||
<Button on:click={unblock_user}>
|
||||
unblock
|
||||
</Button>
|
||||
{#if $settings_user.isblocked}
|
||||
<Button on:click={unblock_user}>
|
||||
unblock
|
||||
</Button>
|
||||
{:else}
|
||||
<Button on:click={block_user}>
|
||||
block
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
{#if is_admin && back === "room_set" && $current_room.type !== "direct"}
|
||||
<Button on:click={make_user_admin}>
|
||||
make admin
|
||||
</Button>
|
||||
<Button new_layout="mute">
|
||||
{mute}
|
||||
mute
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { msgs, user, layout, socket, current_room } from './Store_chat';
|
||||
import type { Room, FetchResponse } from './Types_chat';
|
||||
import { FetchMethod, Mute } from './Types_chat';
|
||||
import { FetchMethod, Mute, User } from './Types_chat';
|
||||
import { to_print } from './Utils_chat';
|
||||
import { fetch_chat_request, set_client_name_on_room, fill_fetch_response } from './Request_utils';
|
||||
|
||||
@@ -27,9 +27,9 @@ export async function create_room(room: Room)
|
||||
{
|
||||
to_print("in create_room");
|
||||
|
||||
to_print("room sent to create:", room);
|
||||
to_print("room sent to create:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('create', FetchMethod.POST, room);
|
||||
to_print("room returned from create:", response.room);
|
||||
to_print("room returned from create:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -38,9 +38,9 @@ export async function join_room(room: Room)
|
||||
{
|
||||
to_print("in join_room");
|
||||
|
||||
to_print("room sent to join:", room);
|
||||
to_print("room sent to join:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('join', FetchMethod.POST, room);
|
||||
to_print("room returned from join:", response.room);
|
||||
to_print("room returned from join:", response.room);
|
||||
|
||||
return response.room;
|
||||
}
|
||||
@@ -49,9 +49,9 @@ export async function change_room(room: Room)
|
||||
{
|
||||
to_print("in change_room");
|
||||
|
||||
to_print("room sent to change:", room);
|
||||
to_print("room sent to change:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('change', FetchMethod.POST, room);
|
||||
to_print("room returned from change:", response.room);
|
||||
to_print("room returned from change:", response.room);
|
||||
|
||||
await get_room_messages();
|
||||
|
||||
@@ -65,9 +65,9 @@ export async function validate_password(room: Room)
|
||||
{
|
||||
to_print("in validate_password");
|
||||
|
||||
to_print("room sent to validate password:", room);
|
||||
to_print("room sent to validate password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('passwordauth', FetchMethod.POST, room);
|
||||
to_print("room returned from validate password:", response.room);
|
||||
to_print("room returned from validate password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -76,9 +76,9 @@ export async function add_password(room: Room)
|
||||
{
|
||||
to_print("in add_password");
|
||||
|
||||
to_print("room sent to add password:", room);
|
||||
to_print("room sent to add password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('addpassword', FetchMethod.POST, room);
|
||||
to_print("room returned from add password:", response.room);
|
||||
to_print("room returned from add password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -93,9 +93,9 @@ export async function change_password(room: Room, old_password: string)
|
||||
old_password: old_password,
|
||||
}
|
||||
|
||||
to_print("room sent to change password:", room);
|
||||
to_print("room sent to change password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('changepassword', FetchMethod.POST, request_body);
|
||||
to_print("room returned from change password:", response.room);
|
||||
to_print("room returned from change password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -104,9 +104,9 @@ export async function remove_password(room: Room)
|
||||
{
|
||||
to_print("in send_password");
|
||||
|
||||
to_print("room sent to remove password:", room);
|
||||
to_print("room sent to remove password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('removepassword', FetchMethod.DELETE, room);
|
||||
to_print("room returned from remove password:", response.room);
|
||||
to_print("room returned from remove password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -140,11 +140,12 @@ export async function get_all_rooms()
|
||||
return response.rooms;
|
||||
}
|
||||
|
||||
export async function get_room_users()
|
||||
export async function get_room_users(): Promise<User[]>
|
||||
{
|
||||
to_print("in get_room_users");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('roomusers', FetchMethod.GET);
|
||||
to_print("response from get_room_users:", response);
|
||||
|
||||
return response.users;
|
||||
}
|
||||
@@ -169,9 +170,9 @@ export async function make_admin(username): Promise<FetchResponse>
|
||||
{
|
||||
to_print("in is_admin");
|
||||
|
||||
to_print("username sent to setadmin:", username);
|
||||
to_print("username sent to setadmin:", username);
|
||||
let response: FetchResponse = await fetch_chat_request('setadmin', FetchMethod.POST, {username: username} );
|
||||
to_print("response from setadmin:", response);
|
||||
to_print("response from setadmin:", response);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -181,9 +182,9 @@ export async function get_is_admin(): Promise<boolean>
|
||||
to_print("in is_admin");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('isadmin', FetchMethod.GET);
|
||||
to_print("is_admin return:", response.is_admin);
|
||||
to_print("is_admin return:", response.condition);
|
||||
|
||||
return response.is_admin;
|
||||
return response.condition;
|
||||
}
|
||||
|
||||
export async function set_mute(date_limit: Date, username: string, time: string): Promise<FetchResponse>
|
||||
@@ -200,9 +201,9 @@ export async function set_mute(date_limit: Date, username: string, time: string)
|
||||
time: time,
|
||||
}
|
||||
|
||||
to_print("setmute send body:", body);
|
||||
to_print("setmute send body:", body);
|
||||
let response: FetchResponse = await fetch_chat_request('setmute', FetchMethod.POST, body );
|
||||
to_print("setmute return:", response);
|
||||
to_print("setmute return:", response);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -212,7 +213,7 @@ export async function get_is_mute(username: string): Promise<Mute>
|
||||
to_print("in get_is_mute");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('ismute', FetchMethod.POST, {username: username} );
|
||||
to_print("ismute return:", response);
|
||||
to_print("ismute return:", response);
|
||||
|
||||
return response.mute;
|
||||
}
|
||||
@@ -238,3 +239,13 @@ export async function remove_block_user(username: string): Promise<void>
|
||||
await fetch_chat_request('unblock', FetchMethod.POST, {username: username} );
|
||||
}
|
||||
|
||||
export async function list_block_user(username: string): Promise<string>
|
||||
{
|
||||
to_print("in list_block_user");
|
||||
|
||||
let response = await fetch_chat_request('listblock', FetchMethod.GET);
|
||||
to_print("response.users:", response.users);
|
||||
|
||||
return response.users;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Room, Message } from './Types_chat';
|
||||
import type { Room, Message, User } from './Types_chat';
|
||||
|
||||
export let msgs = writable([]);
|
||||
export let my_rooms = writable([]);
|
||||
export let all_rooms = writable([]);
|
||||
export let msgs = writable<Message[]>();
|
||||
export let my_rooms = writable<Room[]>();
|
||||
export let all_rooms = writable<Room[]>();
|
||||
export let current_room = writable<Room>();
|
||||
export let settings_user = writable<User>();
|
||||
export let layout = writable("close");
|
||||
export let current_room = writable({
|
||||
name: "",
|
||||
type: "",
|
||||
protection: false,
|
||||
});
|
||||
export let settings_user = writable("");
|
||||
|
||||
export let user;
|
||||
export let socket;
|
||||
|
||||
@@ -17,13 +17,14 @@ export interface Mute
|
||||
export interface Message
|
||||
{
|
||||
name: string;
|
||||
type: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface User
|
||||
{
|
||||
name: string;
|
||||
isadmin: boolean;
|
||||
isblocked: boolean;
|
||||
}
|
||||
|
||||
export interface FetchResponse
|
||||
@@ -36,7 +37,7 @@ export interface FetchResponse
|
||||
users?: User[];
|
||||
room?: Room;
|
||||
rooms?: Room[];
|
||||
is_admin?: boolean;
|
||||
condition?: boolean;
|
||||
mute?: Mute;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user