serveur down, tentative de récup

This commit is contained in:
2024-01-02 15:13:55 +01:00
parent de3349e1c3
commit 862b655dab
11 changed files with 154 additions and 113 deletions

View File

@ -14,7 +14,7 @@ class Channel {
// reload = function to use when we receive a message
async connect(reload) {
let url = `ws://${window.location.host}/ws/chat/${this.channel_id}/`;
let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/chat/${this.channel_id}`;
this.chatSocket = new WebSocket(url);
this.chatSocket.onmessage = (event) =>{
@ -73,6 +73,10 @@ class Channel {
return data;
}
async sendInvite() {
}
}
export {Channel}

View File

@ -6,18 +6,18 @@ class Channels {
this.client = client;
}
async createChannel(users_id, reload) {
async createChannel(members_id, reload) {
let null_id = false;
users_id.forEach(user_id => {
members_id.forEach(user_id => {
if (user_id == null)
null_id = true;
});
if (null_id)
return console.log(users_id, "createChannel error, null id;");
return console.log(members_id, "createChannel error, null id;");
let response = await this.client._post("/api/chat/", {
users_id:users_id
members_id:members_id
});
let data = await response.json();
@ -28,12 +28,12 @@ class Channels {
let messages = undefined;
if (exit_code == 200)
messages = data.messages;
return new Channel(this.client, data.channel_id, users_id, messages, reload);
return new Channel(this.client, data.channel_id, members_id, messages, reload);
}
async deleteChannel(users_id) {
async deleteChannel(members_id) {
let response = await this.client._delete("/api/chat/", {
users_id:users_id
members_id:members_id
});
let data = await response.json();