diff --git a/back/volume/src/users/users.controller.ts b/back/volume/src/users/users.controller.ts
index 3f4f62a..52040a8 100644
--- a/back/volume/src/users/users.controller.ts
+++ b/back/volume/src/users/users.controller.ts
@@ -55,6 +55,7 @@ export class UsersController {
if (user === null || target === null) {
throw new BadRequestException('User not found')
}
+ if (user.ftId === id) throw new BadRequestException('Cannot block yourself')
user.blocked.push(target)
console.log('user', JSON.stringify(user))
console.log('user', JSON.stringify(target))
@@ -69,9 +70,11 @@ export class UsersController {
): Promise {
const user = await this.usersService.getFullUser(+profile.id)
if (user === null) throw new BadRequestException('User not found')
+ const lenBefore = user.blocked.length
user.blocked = user.blocked.filter((usr: User) => {
- return usr.id !== id
+ return usr.ftId !== id
})
+ if (lenBefore === user.blocked.length) throw new BadRequestException('User not found')
await this.usersService.save(user)
}
diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte
index b2af0d3..c8f30ad 100644
--- a/front/volume/src/App.svelte
+++ b/front/volume/src/App.svelte
@@ -149,6 +149,7 @@
// GAME
let pong: Pong;
let gamePlaying: boolean = false;
+ let failedGameLogIn: boolean = false;
let resetGameConnection: () => void;
@@ -175,6 +176,7 @@
{clickFriends}
{clickChannels}
{clickLeaderboard}
+ {failedGameLogIn}
/>
{#if appState.includes(`${APPSTATE.CHANNELS}#`)}
{#key appState}
@@ -246,7 +248,7 @@
/>
{/if}
-
+
{/if}
diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte
index 56ad0dc..cc2ea40 100644
--- a/front/volume/src/components/Channels.svelte
+++ b/front/volume/src/components/Channels.svelte
@@ -224,20 +224,15 @@
{channel.name} : {channel.id}
-
-
-
- {#if channel.isPrivate == true && channel.password}
-
- {/if}
-
- {#if !(channel.isPrivate == true && !channel.password)}
+
+
+ {#if channel.isPrivate == true}
+
+ {/if}
- {/if}
-
{/each}
diff --git a/front/volume/src/components/Chat.svelte b/front/volume/src/components/Chat.svelte
index 17ed16f..2b72154 100644
--- a/front/volume/src/components/Chat.svelte
+++ b/front/volume/src/components/Chat.svelte
@@ -180,18 +180,14 @@
});
if (response.ok) {
const target = await response.json();
- response = await fetch(API_URL + "/users/" + target.ftId + "/block", {
+ response = await fetch(API_URL + "/users/block/" + target.ftId, {
credentials: "include",
method: "DELETE",
- mode: "cors",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ id: target.ftId }),
+ mode: "cors"
});
}
- if (response.ok) await show_popup("User blocked", false);
- else await show_popup("Failed to block user", false);
+ if (response.ok) await show_popup("User unblocked", false);
+ else await show_popup("Failed to unblock user", false);
};
//--------------------------------------------------------------------------------/
@@ -218,7 +214,7 @@
});
if (response.ok) {
socket.emit("kickUser", {chan: channel.id, from: $store.ftId, to: target.ftId});
- } else await show_popup(`Ban of ${username}: ${response.text}`, false);
+ } else await show_popup(`Ban of ${username}: ${await response.text()}`, false);
}
};
@@ -260,14 +256,14 @@
to: target.ftId,
});
} else {
- await show_popup("merde", false);
+ await show_popup("Failed to kick: " + await response.text(), false);
}
};
//--------------------------------------------------------------------------------/
const muteUser = async (username: string) => {
- const prompt = window.prompt("Enter mute duration in seconds");
+ await show_popup("Enter mute duration in seconds");
let response = await fetch(API_URL + "/users/" + username + "/byname", {
credentials: "include",
mode: "cors",
@@ -281,7 +277,7 @@
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ data: [target.ftId, +prompt] }),
+ body: JSON.stringify({ data: [target.ftId, +$content] }),
});
}
if (response.ok) await show_popup("User muted", false);
@@ -400,15 +396,9 @@
- {#if !blockedUsers.filter((user) => (user.username = selectedUser)).length}
-
- {:else}
-
- {/if}
+
@@ -446,6 +436,9 @@
+
{/each}
diff --git a/front/volume/src/components/NavBar.svelte b/front/volume/src/components/NavBar.svelte
index c6bd299..2c76a73 100644
--- a/front/volume/src/components/NavBar.svelte
+++ b/front/volume/src/components/NavBar.svelte
@@ -19,6 +19,7 @@
export let clickFriends = () => {};
export let clickChannels = () => {};
export let clickLeaderboard = () => {};
+ export let failedGameLogIn: boolean;
let hide = true;
@@ -27,7 +28,7 @@
}
-