Complete client context menu: channel/server group assignment

Fills out the last two disabled entries in the client right-click menu
(#72): "Channel-Gruppe zuweisen" and "Server-Gruppe zuweisen".

- Connector: exposes each client's database_id, channel_group, and
  server_groups (already present in tsclientlib's bookkeeping Client
  struct, just not threaded through before) on the "channels" snapshot.
  Adds raw commands for channelgrouplist/servergrouplist (list requests,
  same InMessage pattern as banlist/complainlist) and
  setclientchannelgroup/servergroupaddclient/servergroupdelclient
  (assignment, fire-and-forget like kick/ban).
- Gateway: typed passthrough for the new client fields and five new
  message types (getChannelGroupList, getServerGroupList,
  setChannelGroup, addServerGroup, removeServerGroup).
- Frontend: new GroupAssignDialog reused for both channel groups
  (single-select, closes after assigning) and server groups
  (multi-select, checkmarked entries toggle add/remove and the dialog
  stays open). Demo mode simulates real group membership changes,
  including live re-render after assignment.

Verified against the real server: the client's own database_id/
channel_group/server_groups now flow correctly end-to-end (confirmed
via a throwaway gateway test script). The list-request commands are
permission-gated for the guest test account and decline silently, same
as serverlog/serverconninfo before them - the dialog's existing 6s
"unavailable" timeout already covers this.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
MoepchiandClaude Sonnet 5 committed 2026-08-05 20:40:52 +02:00
1 parent 203e8fba51
commit db8b5ea958
7 files changed
+464 -8

No files matched your search

+20
View File
@@ -194,6 +194,26 @@ wss.on("connection", (socket: WebSocket) => {
await connection?.markOfflineMessageRead(msg.messageId);
break;
}
case "getChannelGroupList": {
await connection?.getChannelGroupList();
break;
}
case "getServerGroupList": {
await connection?.getServerGroupList();
break;
}
case "setChannelGroup": {
await connection?.setChannelGroup(msg.channelGroupId, msg.channelId, msg.clientDbId);
break;
}
case "addServerGroup": {
await connection?.addServerGroup(msg.serverGroupId, msg.clientDbId);
break;
}
case "removeServerGroup": {
await connection?.removeServerGroup(msg.serverGroupId, msg.clientDbId);
break;
}
case "disconnect": {
await connection?.disconnect(msg.message ?? "");
break;
+40 -2
View File
@@ -33,6 +33,14 @@ export interface ClientInfo {
isChannelCommander: boolean;
country: string;
uid: string;
databaseId: number;
channelGroup: number;
serverGroups: number[];
}
export interface GroupEntry {
id: number;
name: string;
}
export interface BanListEntry {
@@ -132,7 +140,9 @@ export type Ts3ConnectionEvent =
subject: string;
message: string;
timestamp: string;
};
}
| { type: "channelGroupList"; entries: GroupEntry[] }
| { type: "serverGroupList"; entries: GroupEntry[] };
export interface Ts3ConnectOptions {
host: string;
@@ -190,6 +200,9 @@ export class Ts3Connection {
is_channel_commander: boolean;
country: string;
uid: string;
database_id: number;
channel_group: number;
server_groups: number[];
}
interface RawChannelInfo {
@@ -292,7 +305,9 @@ export class Ts3Connection {
subject: string;
message: string;
timestamp: string;
};
}
| { type: "channelGroupList"; entries: { id: number; name: string }[] }
| { type: "serverGroupList"; entries: { id: number; name: string }[] };
if (event.type === "connected") {
this.emit({
@@ -330,6 +345,9 @@ export class Ts3Connection {
isChannelCommander: c.is_channel_commander,
country: c.country,
uid: c.uid,
databaseId: c.database_id,
channelGroup: c.channel_group,
serverGroups: c.server_groups,
})),
});
} else if (event.type === "privateMessage") {
@@ -535,6 +553,26 @@ export class Ts3Connection {
this.child?.stdin.write(`messageupdateflag ${messageId} 1\n`);
}
async getChannelGroupList(): Promise<void> {
this.child?.stdin.write(`channelgrouplist\n`);
}
async getServerGroupList(): Promise<void> {
this.child?.stdin.write(`servergrouplist\n`);
}
async setChannelGroup(channelGroupId: number, channelId: number, clientDbId: number): Promise<void> {
this.child?.stdin.write(`setchannelgroup ${channelGroupId} ${channelId} ${clientDbId}\n`);
}
async addServerGroup(serverGroupId: number, clientDbId: number): Promise<void> {
this.child?.stdin.write(`addservergroup ${serverGroupId} ${clientDbId}\n`);
}
async removeServerGroup(serverGroupId: number, clientDbId: number): Promise<void> {
this.child?.stdin.write(`delservergroup ${serverGroupId} ${clientDbId}\n`);
}
async sendChatMessage(message: string): Promise<void> {
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
if (sanitized) this.child?.stdin.write(`chat ${sanitized}\n`);