add official suyu listings

This commit is contained in:
not-nullptr 2024-03-22 15:11:37 +00:00
parent fcd165e990
commit 8aaa779c44
2 changed files with 7 additions and 1 deletions

View file

@ -4,7 +4,7 @@ import type { SuyuUser } from "../schema";
import { v4 } from "uuid"; import { v4 } from "uuid";
export class RoomManager { export class RoomManager {
private static rooms: Room[] = []; static rooms: Room[] = [];
static roomTimeout: Record<string, number> = {}; // room id, last heard from static roomTimeout: Record<string, number> = {}; // room id, last heard from
static createRoom(room: IRoomConfig) { static createRoom(room: IRoomConfig) {
const existingRoom = this.rooms.find((r) => r.host.username === room.host.username); const existingRoom = this.rooms.find((r) => r.host.username === room.host.username);

View file

@ -66,5 +66,11 @@ export async function POST({ request, getClientAddress }) {
hasPassword: body.hasPassword || false, hasPassword: body.hasPassword || false,
}); });
console.log("Room added:", JSON.stringify(room, null, 2)); console.log("Room added:", JSON.stringify(room, null, 2));
// push every room to the top which starts with `[SUYU OFFICIAL]` and was created with username "suyu"
const suyuRoom = RoomManager.rooms.find((r) => r.roomInfo.name.startsWith("[SUYU OFFICIAL]"));
if (suyuRoom && user.username === "suyu") {
RoomManager.rooms.splice(RoomManager.rooms.indexOf(suyuRoom), 1);
RoomManager.rooms.unshift(suyuRoom);
}
return json(room.toJSON()); return json(room.toJSON());
} }