fix(mattermost): fail closed when slash channel type is unknown

This commit is contained in:
Echo 2026-02-19 10:32:23 -05:00 committed by Muhammed Mukhthar CM
parent dde00aef62
commit d879f5b67b
1 changed files with 20 additions and 3 deletions

View File

@ -140,11 +140,28 @@ async function authorizeSlashInvocation(params: {
let channelInfo: MattermostChannel | null = null;
try {
channelInfo = await fetchMattermostChannel(client, channelId);
} catch {
// continue without channel info
} catch (err) {
log?.(`mattermost: slash channel lookup failed for ${channelId}: ${String(err)}`);
}
const channelType = channelInfo?.type ?? undefined;
if (!channelInfo) {
return {
ok: false,
denyResponse: {
response_type: "ephemeral",
text: "Temporary error: unable to determine channel type. Please try again.",
},
commandAuthorized: false,
channelInfo: null,
kind: "channel",
chatType: "channel",
channelName: "",
channelDisplay: "",
roomLabel: `#${channelId}`,
};
}
const channelType = channelInfo.type ?? undefined;
const isDirectMessage = channelType?.toUpperCase() === "D";
const kind: SlashInvocationAuth["kind"] = isDirectMessage
? "direct"