feat: support TeamSpeak server nickname connections

This commit is contained in:
yumi committed 2026-10-08 23:48:47 +08:00
1 parent 35dde81cc2
commit 60d3cfd569
21 files changed
+644 -87

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ test("schema 7 upgrades preserve the previously unused public host and initializ
const original = new WebSpeakDatabase(filename);
original.close();
const legacy = new DatabaseSync(filename);
legacy.exec("ALTER TABLE settings DROP COLUMN webrtc_ipv6_enabled; ALTER TABLE settings DROP COLUMN webrtc_stun_server; PRAGMA user_version = 7;");
legacy.exec("ALTER TABLE settings DROP COLUMN ts_target; ALTER TABLE managed_invites DROP COLUMN target_text; ALTER TABLE settings DROP COLUMN webrtc_ipv6_enabled; ALTER TABLE settings DROP COLUMN webrtc_stun_server; PRAGMA user_version = 7;");
legacy.prepare("UPDATE settings SET webrtc_public_host = ?").run("media.example.com");
legacy.close();
const migrated = new WebSpeakDatabase(filename);
+21
View File
@@ -88,6 +88,27 @@ async function mount(path = "/admin/server") {
assert.equal(state.loading, false);
}
test("nickname defaults load and save without forcing the voice port", async () => {
handler = path => Promise.resolve(json(path === "/server" ? settings({ target: "team eco" }) : defaults(path)));
await mount();
assert.equal(serverModel.serverForm.address, "team eco");
assert.equal(serverModel.serverForm.port, "");
serverModel.serverForm.address = "voice.example.com";
assert.equal(serverModel.serverForm.port, "9987");
serverModel.serverForm.address = "another guild";
assert.equal(serverModel.serverForm.port, "");
handler = (path, init) => {
if (path === "/server" && init.method === "PUT") {
assert.equal(JSON.parse(init.body).target, "another guild");
return Promise.resolve(json({ ok: true, settings: settings({ target: "another guild" }) }));
}
return Promise.resolve(json(defaults(path)));
};
await serverModel.saveServerSettings();
assert.equal(serverModel.serverForm.port, "");
assert.equal(state.errorMessage, "");
});
test("saving settings preserves edits made after the request started", async () => {
await mount();
const save = deferred();
+13 -2
View File
@@ -15,10 +15,11 @@ after(async () => { await vite?.close(); });
function mount(t) {
const scope = effectScope(), errors = ref(""), message = ref(""), switched = ref(""), calls = [];
const dialog = reactive({ open: true, channelId: "2", password: "draft", error: "", submitting: false });
const serverHost = ref("fixture.invalid"), serverPort = ref("9987");
const connection = scope.run(() => useWebClientConnection({
initialized: ref(true), accessMode: ref("fixed"), isConnecting: ref(false), errorCode: errors,
errorMessage: message, channelSwitchedChannelId: switched,
nickname: ref("Preview"), channelName: ref("Room"), serverHost: ref("fixture.invalid"), serverPort: ref("9987"),
nickname: ref("Preview"), channelName: ref("Room"), serverHost, serverPort,
serverPassword: ref(""), rememberIdentity: ref(false), identityMaterial: ref(""), accelerationRelayId: ref(""),
inviteToken: "", selectedChannelId: ref("2"), channels: ref([]), clientId: ref(1),
channelPasswordDialog: dialog, serverPasswordDialog: reactive({ open: false, password: "", errorCode: "" }),
@@ -26,9 +27,19 @@ function mount(t) {
clearError: () => { errors.value = ""; message.value = ""; }, t: key => key,
}));
t.after(() => scope.stop());
return { dialog, connection, errors, message, switched, calls };
return { dialog, connection, errors, message, switched, calls, serverHost, serverPort };
}
test("pasting a nickname clears the prefilled port and preserves a custom override", t => {
const { connection, serverHost, serverPort } = mount(t);
serverHost.value = "https://named.myteamspeak.com/lookup?name=team%20eco";
assert.equal(serverPort.value, "");
assert.equal(connection.currentServerTarget(), "team eco");
serverPort.value = "10000";
serverHost.value = "another guild";
assert.equal(connection.currentServerTarget(), "another guild:10000");
});
test("a waiting channel password request cannot be submitted twice", t => {
const { connection, calls, dialog } = mount(t);
connection.submitChannelPassword(); connection.submitChannelPassword();