fix(mattermost): merge commands config + be lenient on DM channel lookup

This commit is contained in:
Echo
2026-02-15 10:13:15 -05:00
committed by Muhammed Mukhthar CM
parent 5e62c4a3eb
commit 66cfba8221
2 changed files with 21 additions and 5 deletions

View File

@@ -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 {

View File

@@ -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";