user-scoped channel sessions, whatsapp disconnect cleanup, browser relay token fix

Channel session IDs now include userId (channel-{provider}-{userId}-{contextId})
to prevent cross-user contamination in multi-user setups. WhatsApp disconnect
properly logs out and clears cached auth. Browser relay uses server-derived token
directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 14:14:47 +00:00
co-authored by Claude Opus 4.6
parent 209d58a525
commit 8f1963fedb
7 changed files with 45 additions and 28 deletions
+4 -4
View File
@@ -153,7 +153,7 @@ async function handleCommand(ctx: CommandContext): Promise<boolean> {
await channel.send('No models available.');
return true;
}
const current = getSessionModel('discord', discordId);
const current = getSessionModel('discord', ctx.userId, discordId);
const grouped = new Map<string, string[]>();
for (const m of models) {
const list = grouped.get(m.provider) ?? [];
@@ -170,7 +170,7 @@ async function handleCommand(ctx: CommandContext): Promise<boolean> {
}
if (lower === '!model') {
const current = getSessionModel('discord', discordId);
const current = getSessionModel('discord', ctx.userId, discordId);
await channel.send(current ? `Current model: **${current}**` : 'No active session yet — the default model will be used on your next message.');
return true;
}
@@ -178,7 +178,7 @@ async function handleCommand(ctx: CommandContext): Promise<boolean> {
if (lower.startsWith('!model ')) {
const requested = content.slice('!model '.length).trim();
if (!requested) {
const current = getSessionModel('discord', discordId);
const current = getSessionModel('discord', ctx.userId, discordId);
await channel.send(current ? `Current model: **${current}**` : 'No active session yet.');
return true;
}
@@ -188,7 +188,7 @@ async function handleCommand(ctx: CommandContext): Promise<boolean> {
await channel.send(`Model not found: \`${requested}\`\nUse \`!models\` to see available models.`);
return true;
}
setSessionModel('discord', discordId, match.id);
setSessionModel('discord', ctx.userId, discordId, match.id);
await channel.send(`Model switched to **${match.id}**. The new model will be used on your next message.`);
return true;
}