mirror of https://github.com/openclaw/openclaw.git
fix(regression): guard malformed telegram reaction payloads
This commit is contained in:
parent
1a7dc22995
commit
411494faa8
|
|
@ -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", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue