mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 03:11:10 +00:00
fix(regression): guard malformed telegram reaction payloads
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user