fix: surface match metadata in audits and slack logs

Co-authored-by: thewilloftheshadow <thewilloftheshadow@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-18 00:50:33 +00:00
parent 79a44d0da4
commit 22c7f659f6
5 changed files with 59 additions and 11 deletions

View File

@@ -24,6 +24,8 @@ type DiscordPermissionsAuditSummary = {
ok?: boolean;
missing?: string[];
error?: string | null;
matchKey?: string;
matchSource?: string;
}>;
};
@@ -72,11 +74,15 @@ function readDiscordPermissionsAuditSummary(value: unknown): DiscordPermissionsA
? entry.missing.map((v) => asString(v)).filter(Boolean)
: undefined;
const error = asString(entry.error) ?? null;
const matchKey = asString(entry.matchKey) ?? undefined;
const matchSource = asString(entry.matchSource) ?? undefined;
return {
channelId,
ok,
missing: missing?.length ? missing : undefined,
error,
matchKey,
matchSource,
};
})
.filter(Boolean) as DiscordPermissionsAuditSummary["channels"])
@@ -122,11 +128,15 @@ export function collectDiscordStatusIssues(
if (channel.ok === true) continue;
const missing = channel.missing?.length ? ` missing ${channel.missing.join(", ")}` : "";
const error = channel.error ? `: ${channel.error}` : "";
const matchMeta =
channel.matchKey || channel.matchSource
? ` (matchKey=${channel.matchKey ?? "none"} matchSource=${channel.matchSource ?? "none"})`
: "";
issues.push({
channel: "discord",
accountId,
kind: "permissions",
message: `Channel ${channel.channelId} permission check failed.${missing}${error}`,
message: `Channel ${channel.channelId} permission check failed.${missing}${error}${matchMeta}`,
fix: "Ensure the bot role can view + send in this channel (and that channel overrides don't deny it).",
});
}

View File

@@ -17,6 +17,8 @@ type TelegramGroupMembershipAuditSummary = {
ok?: boolean;
status?: string | null;
error?: string | null;
matchKey?: string;
matchSource?: string;
}>;
};
@@ -53,7 +55,9 @@ function readTelegramGroupMembershipAuditSummary(
const ok = typeof entry.ok === "boolean" ? entry.ok : undefined;
const status = asString(entry.status) ?? null;
const error = asString(entry.error) ?? null;
return { chatId, ok, status, error };
const matchKey = asString(entry.matchKey) ?? undefined;
const matchSource = asString(entry.matchSource) ?? undefined;
return { chatId, ok, status, error, matchKey, matchSource };
})
.filter(Boolean) as TelegramGroupMembershipAuditSummary["groups"])
: undefined;
@@ -107,11 +111,15 @@ export function collectTelegramStatusIssues(
if (group.ok === true) continue;
const status = group.status ? ` status=${group.status}` : "";
const err = group.error ? `: ${group.error}` : "";
const matchMeta =
group.matchKey || group.matchSource
? ` (matchKey=${group.matchKey ?? "none"} matchSource=${group.matchSource ?? "none"})`
: "";
issues.push({
channel: "telegram",
accountId,
kind: "runtime",
message: `Group ${group.chatId} not reachable by bot.${status}${err}`,
message: `Group ${group.chatId} not reachable by bot.${status}${err}${matchMeta}`,
fix: "Invite the bot to the group, then DM the bot once (/start) and restart the gateway.",
});
}