From 5110d63efa9e80a0c24b18645571d57a971ccb01 Mon Sep 17 00:00:00 2001 From: Julian Jelfs Date: Sat, 21 Dec 2024 17:06:22 +0000 Subject: [PATCH] pass auth token to bot in body --- frontend/app/src/components/bots/CommandSelector.svelte | 4 ++-- frontend/app/src/components/bots/botState.ts | 4 ++-- frontend/openchat-client/src/openchat.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/app/src/components/bots/CommandSelector.svelte b/frontend/app/src/components/bots/CommandSelector.svelte index 1e231dea1c..02b47da582 100644 --- a/frontend/app/src/components/bots/CommandSelector.svelte +++ b/frontend/app/src/components/bots/CommandSelector.svelte @@ -135,7 +135,7 @@ } function selectCommand(command: FlattenedCommand) { - setSelectedCommand(command); + setSelectedCommand(commands, command); sendCommandIfValid(); } @@ -180,7 +180,7 @@ break; case "Enter": if (!$showingBuilder) { - setSelectedCommand(); + setSelectedCommand(commands); sendCommandIfValid(); } break; diff --git a/frontend/app/src/components/bots/botState.ts b/frontend/app/src/components/bots/botState.ts index 6b0926b3e8..3023a0ce06 100644 --- a/frontend/app/src/components/bots/botState.ts +++ b/frontend/app/src/components/bots/botState.ts @@ -164,8 +164,8 @@ export function createBotInstance( } } -export function setSelectedCommand(cmd?: FlattenedCommand) { - cmd = cmd ?? get(commands)[get(focusedCommandIndex)]; +export function setSelectedCommand(commands: FlattenedCommand[], cmd?: FlattenedCommand) { + cmd = cmd ?? commands[get(focusedCommandIndex)]; // make sure that we don't set the same command twice if (!commandsMatch(get(selectedCommand), cmd)) { diff --git a/frontend/openchat-client/src/openchat.ts b/frontend/openchat-client/src/openchat.ts index 46d5ce6ce9..86cbad2ab0 100644 --- a/frontend/openchat-client/src/openchat.ts +++ b/frontend/openchat-client/src/openchat.ts @@ -7757,11 +7757,11 @@ export class OpenChat extends EventTarget { #callBotCommandEndpoint(bot: ExternalBotCommandInstance, token: string): Promise { const headers = new Headers(); - headers.append("x-auth-jwt", token); - headers.append("Content-type", "application/json"); + headers.append("Content-type", "text/plain"); return fetch(`${bot.endpoint}/execute_command`, { method: "POST", headers: headers, + body: token, }).then((res) => { if (res.ok) { return res.json();