fix(regression): guard malformed telegram reaction payloads

This commit is contained in:
Tak Hoffman
2026-03-27 23:33:48 -05:00
parent 1a7dc22995
commit 411494faa8
2 changed files with 11 additions and 0 deletions

View File

@@ -170,6 +170,9 @@ export function extractTelegramAllowedEmojiReactions(
// Explicitly omitted/null => all emoji reactions are allowed in this chat.
return null;
}
if (!Array.isArray(availableReactions)) {
return new Set<string>();
}
const allowed = new Set<string>();
for (const reaction of availableReactions) {

View File

@@ -157,6 +157,14 @@ describe("extractTelegramAllowedEmojiReactions", () => {
});
expect(result ? Array.from(result).toSorted() : null).toEqual(["👍", "🔥"]);
});
it("treats malformed available_reactions payloads as an empty allowlist instead of throwing", () => {
expect(
extractTelegramAllowedEmojiReactions({
available_reactions: { type: "emoji", emoji: "👍" },
} as never),
).toEqual(new Set<string>());
});
});
describe("resolveTelegramAllowedEmojiReactions", () => {