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

+10 -3
View File
@@ -10,9 +10,9 @@
- 相关节点累积后统一验证,避免每个小改动都重跑完整验证。
- 记录中不放服务器地址、密码、密钥、成员名单、聊天内容或其他隐私数据。
## 当前检查点(2026-10-11)
- KAAK 当前源码版本为 3.1.76;最近新增 TeamSpeak 服务器横幅与欢迎语展示,沿用客户端握手携带的真实服务器信息并在缺少内容时隐藏卡片;同时保留真实服务器名与收藏/历史快速切换入口,并以宿主频道树呈现嵌套语音频道、频道成员头像和状态。服务器显示名过滤像地址的内容;快速切换不向皮肤暴露连接目标。控制坞保留 WebSpeak 现有分享、降噪、伴奏、麦克风、扬声器和设置操作;降噪关闭状态新增红色斜杠提示;已移除无效的录制占位,仅保留屏幕共享和伴奏入口。频道树成员行与成员卡片右键均使用 KOOK 深色浮层格式,菜单项和行为仍为 WebSpeak 原有操作;频道树成员行支持悬停反馈和跨频道拖放移动。屏幕共享播放器限定在中央语音舞台内,具有明确响应高度;成员卡片使用播放器下方剩余区域。3.1.55 的横向单行方案已被用户明确否决,不再沿用;3.1.53 已移除皮肤布局运行时对宿主控件强加的 44px 尺寸。
## 当前检查点(2026-10-12)
- KAAK 当前源码版本为 3.1.77;最近新增 TeamSpeak 服务器横幅与欢迎语展示,沿用客户端握手携带的真实服务器信息并在缺少内容时隐藏卡片;同时保留真实服务器名与收藏/历史快速切换入口,并以宿主频道树呈现嵌套语音频道、频道成员头像和状态。服务器显示名过滤像地址的内容;快速切换不向皮肤暴露连接目标。控制坞保留 WebSpeak 现有分享、降噪、伴奏、麦克风、扬声器和设置操作;降噪关闭状态新增红色斜杠提示;已移除无效的录制占位,仅保留屏幕共享和伴奏入口。频道树成员行与成员卡片右键均使用 KOOK 深色浮层格式,菜单项和行为仍为 WebSpeak 原有操作;频道树成员行支持悬停反馈和跨频道拖放移动。屏幕共享播放器限定在中央语音舞台内,具有明确响应高度;成员卡片使用播放器下方剩余区域。3.1.55 的横向单行方案已被用户明确否决,不再沿用;3.1.53 已移除皮肤布局运行时对宿主控件强加的 44px 尺寸。
- 语音布局、成员卡、频道/聊天收起、音量反馈、性能卡片、设备下拉交互和字体层级均已有对应实现;音频设置标签为 KOOK 已记录的 14px/400,表单卡与字段行按实测宽度/行高调整。
- 直接观察记录覆盖语音侧栏/频道树、成员卡与悬停姓名、当前语音频道聊天开合、语音坞、音频设置字体及设备列表尺寸和状态。独立文字频道不复刻;KOOK 的付费分享呈现不复刻,WebSpeak 自带屏幕分享入口和播放器保留。
- 设备选择菜单已按皮肤实际高度限位;KAAK 音频滑杆、性能反馈、字体和成员卡交互均有对应实现。3.1.66 完整验证为 680/680,服务端 TypeScript 构建、前端类型检查和生产构建通过。用户已明确 KOOK 音乐语音频道附带聊天默认收起、普通语音频道默认展开。TeamSpeak `ChannelInfo` 与皮肤上下文没有音乐类别字段;当前实现按频道分别记住聊天开合,尚不能判断从未设置过的频道是否为音乐频道。
@@ -600,3 +600,10 @@
- 根因:播放器组件在非全屏状态会以内联 `aspect-ratio: auto` 覆盖皮肤 CSS;KAAK 先前设置 `height: auto`,而视频与控件为绝对定位,因此舞台失去可计算高度。
- 修复范围:仅 KAAK 皮肤显式设定桌面和窄屏播放器高度,保持视频 `object-fit: contain` 和黑边;保留播放器与成员卡片分区布局,不改宿主播放器逻辑或其他皮肤。KAAK 升至 3.1.76。
- 验证:示例和内置 `.wskin` 已重建;高度断言和完整 `npm run verify` 通过(690/690 测试、服务端构建、前端类型检查与 Vite 生产构建);`git diff --check` 通过。3040 的新版 KAAK 包返回 HTTP 200(21,950 字节);未做活动语音会话的浏览器目视验收。
## 本轮频道图标回归修复(2026-10-12)
- 用户反馈:频道树的上锁频道仍显示喇叭,当前频道标题仍显示半圆图标。
- 根因:TeamSpeak 初始频道查询未请求 flags,密码标记无法进入共享频道模型;KAAK 当前频道标题使用皮肤模板中的固定半圆字符。此外,已安装的 KAAK 包按皮肤版本复用,本地 3.1.76 包会覆盖服务端更新后的同版本包。
- 修复:初始查询请求 `channellist -flags`,将密码状态送到树形频道图标;普通成员栏也按同一状态显示锁或喇叭。KAAK 标题符号换为喇叭,并升至 3.1.77 触发本地包更新。
- 验证:完整验证通过(692/692 测试、服务端构建、前端类型检查和生产构建);示例皮肤包与内置包同步。3040 已重启并返回健康状态;未在浏览器中进行目视验收。
+1 -1
View File
@@ -30,7 +30,7 @@ The owner authorized inspection of the first two voice rooms in the KOOK server.
## Components and permissions
The connection page and voice workspace are full-page declarative surfaces in [components.json](./kaak-voice/components.json). The voice surface requests only the capabilities it uses: visible server shortcuts, channel and member data, cached profile-avatar display inside the trusted member-card widget, channel joining, channel chat, voice status, microphone/output controls, whisper controls, disconnect, and screen-share status/read/control. Its member-card widget explicitly enables share status and watch actions; the KAAK dock uses the host's screen-share control. The performance panel hides only share transport metrics. The host renders trusted connection, language, skin, and audio controls. KAAK 3.1.76 keeps the shared-screen player inside the central voice-stage column with an explicit responsive height, so the player cannot collapse when the host applies its inline video sizing; member cards scroll in the remaining area. The full source image remains visible with black letterboxing. It rechecks permissions and connection state when each action runs; approval is local to this skin version and can be revoked from the host access control.
The connection page and voice workspace are full-page declarative surfaces in [components.json](./kaak-voice/components.json). The voice surface requests only the capabilities it uses: visible server shortcuts, channel and member data, cached profile-avatar display inside the trusted member-card widget, channel joining, channel chat, voice status, microphone/output controls, whisper controls, disconnect, and screen-share status/read/control. Its member-card widget explicitly enables share status and watch actions; the KAAK dock uses the host's screen-share control. The performance panel hides only share transport metrics. The host renders trusted connection, language, skin, and audio controls. KAAK 3.1.77 keeps the shared-screen player inside the central voice-stage column with an explicit responsive height, so the player cannot collapse when the host applies its inline video sizing; member cards scroll in the remaining area. The full source image remains visible with black letterboxing. It rechecks permissions and connection state when each action runs; approval is local to this skin version and can be revoked from the host access control.
The server header uses the live, privacy-filtered TeamSpeak server label and a trusted `voice.server-switcher` menu backed by favorites and recent connections. Its click handler reuses WebSpeak's existing connection flow with an opaque local ID; addresses and credentials never enter skin data. The left panel uses the trusted `voice.channel-tree` widget to retain TeamSpeak channel nesting, member counts and capacity, available avatars, and mute/speaking/away states. Expanding a branch is local UI state, a single click selects a channel, and double-click joins it. With `memberActions` enabled, right-clicking another member row opens WebSpeak's existing host-owned action menu. With `memberDragDrop` enabled, another member can be dragged onto a different channel row; the member row and target channel receive visual feedback, and the host reuses its existing move-client operation. Both options default off for other skins. The skin does not add KOOK's separate text-channel list.
Binary file not shown.
+1 -1
View File
@@ -638,7 +638,7 @@
},
"children": [
{
"text": "◖"
"text": "🔊︎"
}
]
},
+1 -1
View File
@@ -3,7 +3,7 @@
"packageType": "open-skin",
"id": "community.kaak-voice",
"name": "KAAK",
"version": "3.1.76",
"version": "3.1.77",
"author": "WebSpeak Project",
"license": "AGPL-3.0-only",
"description": "A KOOK-inspired voice workspace with a searchable server header, TeamSpeak banner and welcome message, nested channel members, attached channel chat, and a compact WebSpeak audio dock.",
+1 -1
View File
@@ -756,7 +756,7 @@
}
[data-ws-plugin-part="kaak-workspace.voice-stage-heading-item"] { display: contents; }
[data-ws-plugin-part="kaak-workspace.voice-stage-glyph"] { color: var(--skin-kaak-muted); font-size: 17px; }
[data-ws-plugin-part="kaak-workspace.voice-stage-glyph"] { color: var(--skin-kaak-muted); font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif; font-size: 15px; filter: grayscale(1); }
[data-ws-plugin-part="kaak-workspace.voice-stage-title"] { min-width: 0; margin: 0; overflow: hidden; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
[data-ws-plugin-part="kaak-workspace.voice-stage-member-count"] { color: var(--skin-kaak-muted); font-size: 12px; }
[data-ws-plugin-part="kaak-workspace.voice-stage-member-count"]::before { content: "-"; margin-right: 6px; color: var(--skin-kaak-dim); }
+28 -1
View File
@@ -1,6 +1,11 @@
import assert from "node:assert/strict";
import test from "node:test";
import { applyChannelCapacityNotification, parseChannelCapacities } from "./channel-capacity.js";
import {
applyChannelCapacityNotification,
applyChannelPasswordProtectionNotification,
parseChannelCapacities,
parseChannelPasswordProtections,
} from "./channel-capacity.js";
test("channel capacity rows keep finite limits and distinguish unlimited channels", () => {
const capacities = parseChannelCapacities([
@@ -35,3 +40,25 @@ test("channel capacity notifications merge edits and remove deleted channels", (
applyChannelCapacityNotification("notifychanneldeleted", { cid: "2" }, capacities);
assert.equal(capacities.has(2n), false);
});
test("channel password protection is parsed as a public boolean and tracks channel edits", () => {
const protections = parseChannelPasswordProtections([
{ cid: "1", channel_flag_password: "1" },
{ cid: "2", channel_flag_password: "0" },
{ cid: "3", channel_flag_password: "unknown" },
{ cid: "18446744073709551616", channel_flag_password: "1" },
]);
assert.deepEqual([...protections], [[1n, true], [2n, false]]);
assert.deepEqual(
applyChannelPasswordProtectionNotification("notifychanneledited", { cid: "1", channel_flag_password: "0" }, protections),
{ channelId: 1n, passwordProtected: false },
);
assert.deepEqual(
applyChannelPasswordProtectionNotification("notifychannelcreated", { cid: "4", channel_flag_password: "1" }, protections),
{ channelId: 4n, passwordProtected: true },
);
assert.equal(applyChannelPasswordProtectionNotification("notifychanneldeleted", { cid: "4" }, protections), null);
assert.equal(protections.has(4n), false);
assert.equal(protections.has(3n), false, "unknown flag values are not interpreted as unlocked");
});
+42
View File
@@ -3,6 +3,10 @@ export interface ChannelCapacity {
maxClientsLimited: boolean;
}
export interface ChannelPasswordProtection {
passwordProtected: boolean;
}
const UINT64_MAX = 18_446_744_073_709_551_615n;
function parseChannelId(value: string | undefined): bigint | null {
@@ -34,6 +38,44 @@ export function parseChannelCapacities(rows: readonly Record<string, string>[]):
return capacities;
}
/** The password flag reveals whether a password is required, never the password itself. */
export function parseChannelPasswordProtection(row: Record<string, string>): boolean | null {
if (row.channel_flag_password === "1") return true;
if (row.channel_flag_password === "0") return false;
return null;
}
export function parseChannelPasswordProtections(rows: readonly Record<string, string>[]): Map<bigint, boolean> {
const protections = new Map<bigint, boolean>();
for (const row of rows) {
const id = parseChannelId(row.cid);
const passwordProtected = parseChannelPasswordProtection(row);
if (id !== null && passwordProtected !== null) protections.set(id, passwordProtected);
}
return protections;
}
/** Keep the password-required flag current as channels are created or edited. */
export function applyChannelPasswordProtectionNotification(
name: string,
params: Record<string, string>,
protections: Map<bigint, boolean>,
): { channelId: bigint; passwordProtected: boolean } | null {
const id = parseChannelId(params.cid);
if (id === null) return null;
if (name === "notifychanneldeleted") {
protections.delete(id);
return null;
}
if (name !== "notifychannelcreated" && name !== "notifychanneledited") return null;
const passwordProtected = parseChannelPasswordProtection(params);
if (passwordProtected === null) return null;
protections.set(id, passwordProtected);
return { channelId: id, passwordProtected };
}
/** Keep capacity metadata in step with TeamSpeak's incremental channel events. */
export function applyChannelCapacityNotification(
name: string,
+2 -1
View File
@@ -5,7 +5,7 @@ import { mapChannelTree, normalizeDirectorySnapshot } from "./directory-view.js"
import { parseServerMessage } from "../shared/server-messages.js";
const directory = (): TSDirectorySnapshot => ({
channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Lobby", description: "" }, { id: 18446744073709551615n, parentID: 1n, order: 1n, name: "Room", description: "", maxClients: 10, maxClientsLimited: true }],
channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Lobby", description: "" }, { id: 18446744073709551615n, parentID: 1n, order: 1n, name: "Room", description: "", maxClients: 10, maxClientsLimited: true, passwordProtected: true }],
clients: [{ id: 2, channelID: 1n, nickname: "Member", uid: "uid-2", type: 0, serverGroups: [], away: true, inputMuted: true }],
});
@@ -38,5 +38,6 @@ test("directory presentation survives JSON transport with large IDs, member flag
assert.equal(decoded.channels[0]?.members?.[0]?.avatar, "data:image/png;base64,test");
assert.equal(decoded.channels[1]?.maxClients, 10);
assert.equal(decoded.channels[1]?.maxClientsLimited, true);
assert.equal(decoded.channels[1]?.passwordProtected, true);
assert.deepEqual(decoded.channels[1]?.members, []);
});
+1
View File
@@ -11,6 +11,7 @@ export function mapChannelTree(snapshot: TSDirectorySnapshot, avatarCache = new
...(typeof channel.maxClients === "number" && typeof channel.maxClientsLimited === "boolean"
? { maxClients: channel.maxClients, maxClientsLimited: channel.maxClientsLimited }
: {}),
...(typeof channel.passwordProtected === "boolean" ? { passwordProtected: channel.passwordProtected } : {}),
members: snapshot.clients
.filter((client) => client.channelID === channel.id)
.map((client) => {
+18
View File
@@ -98,6 +98,24 @@ test("channel changes preserve large identifiers and publish only actual create,
assert.equal(f.events.length, 0);
});
test("live channel password changes update and publish the lock state without a full tree refresh", t => {
const f = fixture(t);
f.client.emit("directorySnapshot", snapshot(member(1)));
f.coordinator.syncSelf(); f.phase.published = true;
f.client.emit("channelPasswordProtectionChanged", { channelId: 2n, passwordProtected: true });
assert.equal(f.state.channelTree.find(item => item.id === "2")?.passwordProtected, true);
let published = f.messages.at(-1);
assert.equal(published?.type, "channelList");
if (published?.type === "channelList") assert.equal(published.channels.find(item => item.id === "2")?.passwordProtected, true);
f.client.emit("channelPasswordProtectionChanged", { channelId: 2n, passwordProtected: false });
assert.equal(f.state.channelTree.find(item => item.id === "2")?.passwordProtected, false);
published = f.messages.at(-1);
assert.equal(published?.type, "channelList");
if (published?.type === "channelList") assert.equal(published.channels.find(item => item.id === "2")?.passwordProtected, false);
});
test("reset rejects backoff events and close detaches only owned listeners including captured callbacks", t => {
const f = fixture(t);
f.client.emit("directorySnapshot", snapshot(member(1), member(2)));
+9
View File
@@ -23,6 +23,7 @@ interface SdkEvents {
clientMoved: { id: number; targetChannelID?: bigint };
clientUpdated: TSDirectoryClient;
directoryClientsSnapshot: TSDirectoryClient[];
channelPasswordProtectionChanged: { channelId: bigint; passwordProtected: boolean };
rawNotification: TSRawNotification;
voiceData: TSVoiceData;
textMessage: TSChatMessage;
@@ -135,6 +136,14 @@ export class SessionEventCoordinator {
this.refresh();
this.publishDirectory();
});
this.listenDirectory("channelPasswordProtectionChanged", change => {
const channelId = String(change.channelId);
if (!state.channelTree.some(channel => channel.id === channelId)) return;
state.channelTree = state.channelTree.map(channel => channel.id === channelId
? { ...channel, passwordProtected: change.passwordProtected }
: channel);
this.publishDirectory();
});
this.listen("rawNotification", options.onNotification);
this.listen("voiceData", options.onVoice);
this.listen("textMessage", message => {
+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 () => {
+36 -5
View File
@@ -20,7 +20,14 @@ import { describeTeamSpeakError, normalizeTeamSpeakError, normalizeTeamSpeakKick
import { TeamSpeakAdapter, type TeamSpeakProtocol } from "./teamspeak-adapter.js";
import type { TeamSpeakTarget } from "../domain/teamspeak-target.js";
import { createAccelerationRelayClient, type AccelerationRelayClient, type AccelerationRelayOptions } from "./acceleration-relay.js";
import { applyChannelCapacityNotification, parseChannelCapacities, type ChannelCapacity } from "./channel-capacity.js";
import {
applyChannelCapacityNotification,
applyChannelPasswordProtectionNotification,
parseChannelCapacities,
parseChannelPasswordProtections,
type ChannelCapacity,
type ChannelPasswordProtection,
} from "./channel-capacity.js";
export interface TSClientOptions {
target: TeamSpeakTarget;
@@ -62,7 +69,7 @@ const MAX_SERVER_ICON_BYTES = 128 * 1024;
const MAX_SERVER_BANNER_URL_LENGTH = 2_048;
const MAX_SERVER_WELCOME_MESSAGE_LENGTH = 4_096;
export type TSDirectoryChannel = DirectorySnapshot["channels"][number] & Partial<ChannelCapacity>;
export type TSDirectoryChannel = DirectorySnapshot["channels"][number] & Partial<ChannelCapacity> & Partial<ChannelPasswordProtection>;
export type TSDirectorySnapshot = Omit<DirectorySnapshot, "channels"> & { channels: TSDirectoryChannel[] };
export type TSDirectoryClient = DirectoryClientInfo;
export type TSRawNotification = RawNotification;
@@ -108,6 +115,7 @@ export class TSClient extends EventEmitter {
private preferredChannelId = 0n;
private accelerationClient: AccelerationRelayClient | null = null;
private readonly channelCapacities = new Map<bigint, ChannelCapacity>();
private readonly channelPasswordProtection = new Map<bigint, boolean>();
// Reason id of the most recent self leave, kept so the SDK `kicked` event can
// tell a plain kick (4) from a kick with ban (5). The SDK only forwards the
// reason message to its `kicked` handler, not the reason id.
@@ -126,6 +134,7 @@ export class TSClient extends EventEmitter {
this.inputStateQueue = Promise.resolve();
this.selfLeaveReasonId = null;
this.channelCapacities.clear();
this.channelPasswordProtection.clear();
if (!this.adapter || !this.client) {
let transportTarget = this.options.target;
if (this.options.acceleration && !this.accelerationClient) {
@@ -184,14 +193,19 @@ export class TSClient extends EventEmitter {
// The high-level SDK directory type intentionally omits channel limit
// metadata. Its raw client-protocol rows still include the public
// maximum-client properties, so retain those without another SDK API.
const rows = await client.execCommandWithResponse("channellist", 5_000);
// TeamSpeak only includes channel flag fields (including the public
// password-required bit) when the client asks for flags explicitly.
const rows = await client.execCommandWithResponse("channellist -flags", 5_000);
const capacities = parseChannelCapacities(rows);
for (const [id, capacity] of capacities) this.channelCapacities.set(id, capacity);
for (const [id, passwordProtected] of parseChannelPasswordProtections(rows)) {
this.channelPasswordProtection.set(id, passwordProtected);
}
} catch (error: unknown) {
this.logger.warn({ err: error instanceof Error ? error.message : String(error) }, "Could not read TeamSpeak channel limits");
}
this.emit("directorySnapshot", {
channels: channels.map((channel) => ({ ...channel, ...this.channelCapacities.get(channel.id) })),
channels: this.applyChannelMetadata(channels),
clients,
});
} catch (error: unknown) {
@@ -356,7 +370,7 @@ export class TSClient extends EventEmitter {
client.on("directorySnapshot", (snapshot) => {
if (this.client !== client) return;
this.emit("directorySnapshot", {
channels: snapshot.channels.map((channel) => ({ ...channel, ...this.channelCapacities.get(channel.id) })),
channels: this.applyChannelMetadata(snapshot.channels),
clients: snapshot.clients.slice(),
});
});
@@ -364,6 +378,12 @@ export class TSClient extends EventEmitter {
client.on("rawNotification", (notification: RawNotification) => {
if (this.client !== client) return;
applyChannelCapacityNotification(notification.name, notification.params, this.channelCapacities);
const protectionChange = applyChannelPasswordProtectionNotification(
notification.name,
notification.params,
this.channelPasswordProtection,
);
if (protectionChange) this.emit("channelPasswordProtectionChanged", protectionChange);
this.emit("rawNotification", {
name: notification.name,
params: { ...notification.params },
@@ -395,6 +415,7 @@ export class TSClient extends EventEmitter {
this.connected = false;
this.clientId = 0;
this.channelCapacities.clear();
this.channelPasswordProtection.clear();
this.emit("disconnected", err);
});
@@ -590,6 +611,16 @@ export class TSClient extends EventEmitter {
this.clientId = 0;
}
}
private applyChannelMetadata(channels: readonly TSDirectoryChannel[]): TSDirectoryChannel[] {
return channels.map((channel) => ({
...channel,
...this.channelCapacities.get(channel.id),
...(this.channelPasswordProtection.has(channel.id)
? { passwordProtected: this.channelPasswordProtection.get(channel.id)! }
: {}),
}));
}
}
function normalizeTeamSpeakBannerUrl(value: unknown): string | null {
+2 -1
View File
@@ -16,7 +16,7 @@ const samples: Record<ServerMessage["type"], ServerMessage> = {
memberEnter: { type: "memberEnter", id: 2, nickname: "Visitor", uid: "uid-2", isSelf: false },
memberLeave: { type: "memberLeave", id: 2 },
memberAvatar: { type: "memberAvatar", id: 2, avatar: "data:image/png;base64,test" },
channelList: { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 10, maxClientsLimited: true, members: [{ id: 1, nickname: "Owner" }] }] },
channelList: { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 10, maxClientsLimited: true, passwordProtected: true, members: [{ id: 1, nickname: "Owner" }] }] },
chatMessage: { type: "chatMessage", scope: "channel", targetId: "1", invokerId: 2, message: "hello" },
pokeReceived: { type: "pokeReceived", invokerId: 2, message: "poke" },
serverEvent: { type: "serverEvent", event },
@@ -70,6 +70,7 @@ test("malformed nested directory and event data is rejected before client state
{ type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", members: [{}] }] },
{ type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 10 }] },
{ type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 65536, maxClientsLimited: true }] },
{ type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", passwordProtected: "yes" }] },
{ type: "memberEnter", id: 65536, nickname: "bad id" },
{ type: "memberEnter", id: 1, nickname: "bad flag", inputMuted: "false" },
{ type: "serverEvent", event: { ...event, timestamp: Infinity } },
+1
View File
@@ -72,6 +72,7 @@ function channel(value: unknown): value is ChannelInfo {
&& text(value.name) && optional(value.order, text) && optional(value.description, text)
&& optional(value.maxClients, maximum => finite(maximum) && Number.isInteger(maximum) && maximum >= 0 && maximum <= 65_535)
&& optional(value.maxClientsLimited, boolean)
&& optional(value.passwordProtected, boolean)
&& (value.maxClients === undefined) === (value.maxClientsLimited === undefined)
&& optional(value.members, members => arrayOf(members, member));
}
+2
View File
@@ -23,6 +23,8 @@ export interface ChannelInfo {
maxClients?: number;
/** False means the channel has no individual client limit. */
maxClientsLimited?: boolean;
/** TeamSpeak's public channel flag; absent when the connected server omits it. */
passwordProtected?: boolean;
members?: ChannelMember[];
}
Binary file not shown.
+6 -2
View File
@@ -36,8 +36,12 @@
<circle cx="6" cy="18" r="3" />
<circle cx="16" cy="16" r="3" />
</template>
<path v-else-if="name === 'headset'" d="M4 14v-2a8 8 0 0 1 16 0v2M4 14h3v5H5a1 1 0 0 1-1-1zm16 0h-3v5h2a1 1 0 0 1-1-1z" />
<path v-else-if="name === 'volume'" d="M4 10v4h3l4 3V7l-4 3zm10.5-2.5a6 6 0 0 1 0 9m2-11a9 9 0 0 1 0 13" />
<path v-else-if="name === 'headset'" d="M4 14v-2a8 8 0 0 1 16 0v2M4 14h3v5H5a1 1 0 0 1-1-1zm16 0h-3v5h2a1 1 0 0 1-1-1z" />
<path v-else-if="name === 'volume'" d="M4 10v4h3l4 3V7l-4 3zm10.5-2.5a6 6 0 0 1 0 9m2-11a9 9 0 0 1 0 13" />
<template v-else-if="name === 'speaker'">
<path d="M3 9v6h4l5 4V5L7 9H3Z" fill="currentColor" stroke="none" />
<path d="M16 9a4 4 0 0 1 0 6m2.5-8.5a7.5 7.5 0 0 1 0 11" />
</template>
<path v-else-if="name === 'volume-off'" d="m4 4 16 16M4 10v4h3l4 3V7l-4 3z" />
<template v-else-if="name === 'search'">
<circle cx="10.8" cy="10.8" r="6.8" />
@@ -65,7 +65,7 @@
@click="emit('selectChannel', channelItem)"
>
<Icon
name="volume"
:name="channelItem.passwordProtected ? 'lock' : 'speaker'"
:size="16"
/>
<span>{{ channelItem.name }}</span>
@@ -25,7 +25,8 @@
class="ws-voice-channel-row"
data-ws-part="voice.channel-tree.row"
:data-drag-over="memberDragDrop && dragOverChannelId === node.channel.id ? 'true' : undefined"
:title="`双击或按 Enter 加入 ${node.channel.name} / Double-click or press Enter to join`"
:title="`双击或按 Enter 加入 ${node.channel.name} / Double-click or press Enter to join${node.channel.passwordProtected ? ' · 需要频道密码 / Channel password required' : ''}`"
:data-password-protected="node.channel.passwordProtected ? 'true' : undefined"
@click="emit('select', node.channel.id)"
@dblclick.stop.prevent="join"
@keydown.enter.prevent.stop="join"
@@ -33,7 +34,13 @@
@dragleave="handleChannelDragLeave($event)"
@drop="handleChannelDrop($event)"
>
<Icon class="ws-voice-channel-type" data-ws-part="voice.channel-tree.icon" name="volume" :size="14" />
<Icon
class="ws-voice-channel-type"
data-ws-part="voice.channel-tree.icon"
:name="node.channel.passwordProtected ? 'lock' : 'speaker'"
:data-password-protected="node.channel.passwordProtected ? 'true' : 'false'"
:size="14"
/>
<span class="ws-voice-channel-name" data-ws-part="voice.channel-tree.name">{{ node.channel.name }}</span>
<span v-if="selected && !current" class="ws-voice-channel-join-hint" data-ws-part="voice.channel-tree.join-hint">双击加入</span>
<span class="ws-voice-channel-count" data-ws-part="voice.channel-tree.count">
+1 -1
View File
@@ -46,7 +46,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.1.76",
version: "3.1.77",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A KOOK-inspired voice-room workspace with a searchable server header, TeamSpeak banner and welcome message, nested channel members, attached channel chat, and a compact WebSpeak audio dock.",
+4 -3
View File
@@ -479,7 +479,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
const skin = await importSkinPack(file);
assert.equal(skin.id, "community.kaak-voice");
assert.equal(skin.version, "3.1.76");
assert.equal(skin.version, "3.1.77");
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
assert.equal(skin.schemaVersion, 3);
const home = skin.pluginData?.components.find((component) => component.page === "home");
@@ -545,8 +545,9 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.equal(findPart(voice?.root, "identity-online")?.attributes?.role, "img");
const voiceStageHeadingItem = findPart(voice?.root, "voice-stage-heading-item");
assert.equal(voiceStageHeadingItem?.repeat?.path, "session.channels");
const voiceStageHeading = findPart(voiceStageHeadingItem, "voice-stage-heading");
assert.deepEqual(voiceStageHeading?.when, { path: "stagechannel.current", equals: true });
const voiceStageHeading = findPart(voiceStageHeadingItem, "voice-stage-heading");
assert.deepEqual(voiceStageHeading?.when, { path: "stagechannel.current", equals: true });
assert.equal(findPart(voiceStageHeading, "voice-stage-glyph")?.children?.[0]?.text, "🔊︎");
assert.equal(findPart(voiceStageHeading, "voice-stage-title")?.children?.[0]?.text, "{{stagechannel.name}}");
assert.equal(findPart(voiceStageHeading, "voice-stage-member-count")?.children?.[0]?.text, "{{stagechannel.memberCountLabel}}");
assert.deepEqual(findPart(voiceStageHeading, "voice-stage-capacity")?.when, { path: "stagechannel.maxClientsLimited", equals: true });