fix: show password protected channels

This commit is contained in:
illusia committed 2026-10-12 10:34:06 +08:00
1 parent ff508a8eb9
commit cec2a81549
23 files changed
+189 -27

No files matched your search

+13 -3
View File
@@ -313,14 +313,14 @@ test("a current avatar download preserves its bytes and rejects a mismatched ide
assert.equal(f.sdk.downloaded, 1);
});
test("public channel capacity survives directory snapshots and follows channel edits", () => {
test("public channel metadata survives directory snapshots and follows channel edits", () => {
const f = fixture();
const snapshots: Array<{ channels: Array<{ id: bigint; maxClients?: number; maxClientsLimited?: boolean }>; clients: unknown[] }> = [];
const snapshots: Array<{ channels: Array<{ id: bigint; maxClients?: number; maxClientsLimited?: boolean; passwordProtected?: boolean }>; clients: unknown[] }> = [];
f.client.on("directorySnapshot", snapshot => snapshots.push(snapshot));
f.sdk.emit("rawNotification", {
name: "notifychannelcreated",
params: { cid: "1", channel_maxclients: "10", channel_flag_maxclients_unlimited: "0" },
params: { cid: "1", channel_maxclients: "10", channel_flag_maxclients_unlimited: "0", channel_flag_password: "1" },
});
f.sdk.emit("directorySnapshot", {
channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Room", description: "" }],
@@ -328,6 +328,7 @@ test("public channel capacity survives directory snapshots and follows channel e
});
assert.equal(snapshots.at(-1)?.channels[0]?.maxClients, 10);
assert.equal(snapshots.at(-1)?.channels[0]?.maxClientsLimited, true);
assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, true);
f.sdk.emit("rawNotification", { name: "notifychanneledited", params: { cid: "1", channel_maxclients: "12" } });
f.sdk.emit("directorySnapshot", {
@@ -336,6 +337,14 @@ test("public channel capacity survives directory snapshots and follows channel e
});
assert.equal(snapshots.at(-1)?.channels[0]?.maxClients, 12);
assert.equal(snapshots.at(-1)?.channels[0]?.maxClientsLimited, true);
assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, true, "partial edits retain the previously reported password flag");
f.sdk.emit("rawNotification", { name: "notifychanneledited", params: { cid: "1", channel_flag_password: "0" } });
f.sdk.emit("directorySnapshot", {
channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Room", description: "" }],
clients: [],
});
assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, false);
f.sdk.emit("rawNotification", { name: "notifychanneldeleted", params: { cid: "1" } });
f.sdk.emit("directorySnapshot", {
@@ -343,6 +352,7 @@ test("public channel capacity survives directory snapshots and follows channel e
clients: [],
});
assert.equal(snapshots.at(-1)?.channels[0]?.maxClients, undefined);
assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, undefined);
});
test("a retired SDK client's disconnect cannot invalidate a current avatar request", async () => {