fix: keep Telegram status reactions enabled when getChat lookup fails

This commit is contained in:
Ayaan Zaidi
2026-02-21 09:08:13 +05:30
parent a18a129c23
commit 8f6ba013f5
3 changed files with 23 additions and 5 deletions

View File

@@ -562,7 +562,7 @@ export const buildTelegramMessageContext = async ({
logVerbose(
`telegram status-reaction available_reactions lookup failed for chat ${chatId}: ${String(err)}`,
);
return new Set<string>();
return null;
});
}
const allowedStatusReactionEmojis = await allowedStatusReactionEmojisPromise;

View File

@@ -97,6 +97,20 @@ describe("resolveTelegramAllowedEmojiReactions", () => {
expect(result ? Array.from(result) : null).toEqual(["👍"]);
});
it("falls back to unrestricted reactions when getChat lookup fails", async () => {
const getChat = async () => {
throw new Error("lookup failed");
};
const result = await resolveTelegramAllowedEmojiReactions({
chat: { id: 1 },
chatId: 1,
getChat,
});
expect(result).toBeNull();
});
});
describe("resolveTelegramReactionVariant", () => {

View File

@@ -200,10 +200,14 @@ export async function resolveTelegramAllowedEmojiReactions(params: {
}
if (params.getChat) {
const chatInfo = await params.getChat(params.chatId);
const fromLookup = extractTelegramAllowedEmojiReactions(chatInfo);
if (fromLookup !== undefined) {
return fromLookup;
try {
const chatInfo = await params.getChat(params.chatId);
const fromLookup = extractTelegramAllowedEmojiReactions(chatInfo);
if (fromLookup !== undefined) {
return fromLookup;
}
} catch {
return null;
}
}