diff --git a/extensions/mattermost/src/mattermost/accounts.ts b/extensions/mattermost/src/mattermost/accounts.ts index 9af9074087e..ca120d08c6b 100644 --- a/extensions/mattermost/src/mattermost/accounts.ts +++ b/extensions/mattermost/src/mattermost/accounts.ts @@ -83,7 +83,21 @@ function mergeMattermostAccountConfig( defaultAccount?: unknown; }; const account = resolveAccountConfig(cfg, accountId) ?? {}; - return { ...base, ...account }; + + // Shallow merging is fine for most keys, but `commands` should be merged + // so that account-specific overrides (callbackPath/callbackUrl) do not + // accidentally reset global settings like `native: true`. + const mergedCommands = { + ...(base.commands ?? {}), + ...(account.commands ?? {}), + }; + + const merged = { ...base, ...account }; + if (Object.keys(mergedCommands).length > 0) { + merged.commands = mergedCommands; + } + + return merged; } function resolveMattermostRequireMention(config: MattermostAccountConfig): boolean | undefined { diff --git a/extensions/mattermost/src/mattermost/slash-http.ts b/extensions/mattermost/src/mattermost/slash-http.ts index 3b784409378..1bc9d18773e 100644 --- a/extensions/mattermost/src/mattermost/slash-http.ts +++ b/extensions/mattermost/src/mattermost/slash-http.ts @@ -146,11 +146,13 @@ async function authorizeSlashInvocation(params: { const channelType = channelInfo?.type ?? undefined; const isDirectMessage = channelType?.toUpperCase() === "D"; - const kind = isDirectMessage + const kind: SlashInvocationAuth["kind"] = isDirectMessage ? "direct" - : channelType?.toUpperCase() === "G" - ? "group" - : "channel"; + : channelInfo + ? channelType?.toUpperCase() === "G" + ? "group" + : "channel" + : "direct"; const chatType = kind === "direct" ? "direct" : kind === "group" ? "group" : "channel";