|
@ -7,9 +7,9 @@ |
|
|
import { createEventDispatcher, onDestroy, onMount } from "svelte"; |
|
|
import { createEventDispatcher, onDestroy, onMount } from "svelte"; |
|
|
import { store, API_URL } from "../Auth"; |
|
|
import { store, API_URL } from "../Auth"; |
|
|
import { socket } from "../socket"; |
|
|
import { socket } from "../socket"; |
|
|
|
|
|
import { show_popup, content } from "./Alert/content"; |
|
|
import type { ChannelsType } from "./Channels.svelte"; |
|
|
import type { ChannelsType } from "./Channels.svelte"; |
|
|
import type User from "./Profile.svelte"; |
|
|
import type User from "./Profile.svelte"; |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
@ -119,8 +119,9 @@ |
|
|
body: JSON.stringify({ id: target.ftId }), |
|
|
body: JSON.stringify({ id: target.ftId }), |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
if (response.ok) alert("User blocked"); |
|
|
if (response.ok) |
|
|
else alert("Failed to block user"); |
|
|
await show_popup("User blocked", false); |
|
|
|
|
|
else await show_popup("Failed to block user",false); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------/ |
|
|
//--------------------------------------------------------------------------------/ |
|
@ -142,8 +143,8 @@ |
|
|
body: JSON.stringify({ id: target.ftId }), |
|
|
body: JSON.stringify({ id: target.ftId }), |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
if (response.ok) alert("User blocked"); |
|
|
if (response.ok) show_popup("User blocked", false); |
|
|
else alert("Failed to block user"); |
|
|
else show_popup("Failed to block user", false); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------/ |
|
|
//--------------------------------------------------------------------------------/ |
|
@ -155,7 +156,8 @@ |
|
|
}); |
|
|
}); |
|
|
if (response.ok) { |
|
|
if (response.ok) { |
|
|
const target = await response.json(); |
|
|
const target = await response.json(); |
|
|
const duration = prompt("Enter a time for which the user will be banned from this channel") |
|
|
await show_popup("Enter a time for which the user will be banned from this channel") |
|
|
|
|
|
const duration = $content |
|
|
response = await fetch(API_URL + "/channels/" + channel.id + "/ban", { |
|
|
response = await fetch(API_URL + "/channels/" + channel.id + "/ban", { |
|
|
credentials: "include", |
|
|
credentials: "include", |
|
|
method: "POST", |
|
|
method: "POST", |
|
@ -168,8 +170,8 @@ |
|
|
socket.emit("kickUser", channel.id, $store.ftId, target.ftId); |
|
|
socket.emit("kickUser", channel.id, $store.ftId, target.ftId); |
|
|
} |
|
|
} |
|
|
if (response.ok) { |
|
|
if (response.ok) { |
|
|
alert("User banned"); |
|
|
show_popup("User banned", false); |
|
|
} else alert("Failed to ban user"); |
|
|
} else show_popup("Failed to ban user", false); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------/ |
|
|
//--------------------------------------------------------------------------------/ |
|
@ -191,8 +193,8 @@ |
|
|
body: JSON.stringify({ id: target.ftId }), |
|
|
body: JSON.stringify({ id: target.ftId }), |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
if (response.ok) alert("User unbanned"); |
|
|
if (response.ok) show_popup("User unbanned",false); |
|
|
else alert("Failed to unban user"); |
|
|
else show_popup("Failed to unban user",false); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------/ |
|
|
//--------------------------------------------------------------------------------/ |
|
@ -205,7 +207,7 @@ |
|
|
if (response.ok) { |
|
|
if (response.ok) { |
|
|
const target = await response.json(); |
|
|
const target = await response.json(); |
|
|
socket.emit("kickUser", {chan : channel.id, from : $store.ftId, to: target.ftId}); |
|
|
socket.emit("kickUser", {chan : channel.id, from : $store.ftId, to: target.ftId}); |
|
|
} else {alert("merde")} |
|
|
} else {show_popup("merde",false)} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------/ |
|
|
//--------------------------------------------------------------------------------/ |
|
@ -228,8 +230,8 @@ |
|
|
body: JSON.stringify({ data: [target.ftId, +prompt] }), |
|
|
body: JSON.stringify({ data: [target.ftId, +prompt] }), |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
if (response.ok) alert("User muted"); |
|
|
if (response.ok) show_popup("User muted",false); |
|
|
else alert("Failed to mute user"); |
|
|
else show_popup("Failed to mute user",false); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------/ |
|
|
//--------------------------------------------------------------------------------/ |
|
@ -252,9 +254,9 @@ |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
if (response.ok) { |
|
|
if (response.ok) { |
|
|
alert("User admined"); |
|
|
show_popup("User admined",false); |
|
|
} else { |
|
|
} else { |
|
|
alert("Failed to admin user"); |
|
|
show_popup("Failed to admin user",false); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -278,17 +280,17 @@ |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
if (response.ok) { |
|
|
if (response.ok) { |
|
|
alert("User admined"); |
|
|
show_popup("User admined", false); |
|
|
} else { |
|
|
} else { |
|
|
alert("Failed to admin user"); |
|
|
show_popup("Failed to admin user", false); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------/ |
|
|
//--------------------------------------------------------------------------------/ |
|
|
|
|
|
|
|
|
const leaveChannel = async () => { |
|
|
const leaveChannel = async () => { |
|
|
const prompt = window.prompt("Are you sure you want to leave this channel? (y/n)"); |
|
|
await show_popup("Press \"Okay\" to leave this channel?", false); |
|
|
if (prompt == "y") { |
|
|
if ($content == 'ok') { |
|
|
const response = await fetch(API_URL + "/channels/" + channel.id + "/leave", { |
|
|
const response = await fetch(API_URL + "/channels/" + channel.id + "/leave", { |
|
|
credentials: "include", |
|
|
credentials: "include", |
|
|
mode: "cors", |
|
|
mode: "cors", |
|
@ -296,7 +298,7 @@ |
|
|
if (response.ok) { |
|
|
if (response.ok) { |
|
|
window.location.href = "/channels"; |
|
|
window.location.href = "/channels"; |
|
|
} else { |
|
|
} else { |
|
|
alert("Failed to leave channel"); |
|
|
await show_popup("Failed to leave channel",false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|