diff --git a/accounts/profile.js b/accounts/profile.js
index 88b92c7..76949c3 100755
--- a/accounts/profile.js
+++ b/accounts/profile.js
@@ -241,9 +241,7 @@ async function editProfile(body, token, admin) {
"X-Authentication": process.env.PROCESSING_SERVER_SECRET
}
});
- console.log("created request");
let oggFile = await fetch(request);
- console.log("finished request");
let filePath = `/data/${userData.id}/${crypto.randomUUID()}.ogg`;
await Bun.write(process.env.DATA_PATH + filePath, oggFile);
const updateAccount = accs.query(`UPDATE accounts SET music = $music WHERE username = $user`)
@@ -252,7 +250,6 @@ async function editProfile(body, token, admin) {
name: body.title,
artist: body.artist
}), $user: user });
- console.log("database");
}
return { success: true };
diff --git a/html/profile.html b/html/profile.html
index bbd40bf..e225ccb 100755
--- a/html/profile.html
+++ b/html/profile.html
@@ -7,7 +7,7 @@
-
+
diff --git a/html/profile_edit.html b/html/profile_edit.html
index e54fcf3..0fb07e3 100755
--- a/html/profile_edit.html
+++ b/html/profile_edit.html
@@ -7,7 +7,7 @@
-
+
diff --git a/html/users.html b/html/users.html
index 2c93324..321f45d 100644
--- a/html/users.html
+++ b/html/users.html
@@ -7,7 +7,7 @@
-
+
diff --git a/index.js b/index.js
index dfffd28..3a32ddf 100755
--- a/index.js
+++ b/index.js
@@ -37,27 +37,21 @@ import WebSocket, { WebSocketServer } from "ws";
const wss = new WebSocketServer({ noServer: true });
let openSockets = 0;
wss.on("connection", function connection(ws, req, res) {
- openSockets++;
+ ws.send(`online=${wss.clients.size}`);
setInterval(() => {
- ws.send("ping");
- }, 30000);
+ ws.send(`online=${wss.clients.size}`);
+ }, 5000);
ws.on("error", console.error);
ws.on("message", async function message(data, isBinary) {
let message = Buffer.from(data).toString();
- if (message.startsWith(process.env.ANNOUNCEMENT_KEY)) {
- wss.clients.forEach(function each(client) {
- if (client.readyState === WebSocket.OPEN) {
- client.send(message.replace(process.env.ANNOUNCEMENT_KEY, "announce."));
- }
- });
- } else if (message.startsWith("token") && (await verifyCookie(message.substring(6)))) {
+ if (message.startsWith("token") && (await verifyCookie(message.substring(6)))) {
ws.id = await getUserFromCookie(message.substring(6));
ws.send(ws.id);
const updateAccount = accs.query(`UPDATE accounts SET last_login = $login WHERE username = $user`)
updateAccount.get({ $login: new Date().toUTCString(), $user: ws.id });
- } else if (message.startsWith("pong")) {
+ } else if (message.startsWith("1")) {
if (ws.id) {
const updateAccount = accs.query(`UPDATE accounts SET last_login = $login WHERE username = $user`)
updateAccount.get({ $login: new Date().toUTCString(), $user: ws.id });
@@ -65,7 +59,7 @@ wss.on("connection", function connection(ws, req, res) {
}
});
- ws.on("close", () => {openSockets--;});
+ ws.on("close", () => {});
});
app.post(
"/api/event",