fix: normalize gateway dev mode detection
This commit is contained in:
@@ -115,8 +115,8 @@ export async function auditTelegramGroupMembership(params: {
|
||||
matchKey: chatId,
|
||||
matchSource: "id",
|
||||
});
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const status = isRecord((json as TelegramApiOk<unknown>).result)
|
||||
? ((json as TelegramApiOk<{ status?: string }>).result.status ?? null)
|
||||
: null;
|
||||
|
||||
@@ -48,8 +48,6 @@ describe("expandTextLinks", () => {
|
||||
it("preserves offsets from the original string", () => {
|
||||
const text = " Hello world";
|
||||
const entities = [{ type: "text_link", offset: 1, length: 5, url: "https://example.com" }];
|
||||
expect(expandTextLinks(text, entities)).toBe(
|
||||
" [Hello](https://example.com) world",
|
||||
);
|
||||
expect(expandTextLinks(text, entities)).toBe(" [Hello](https://example.com) world");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,10 +121,7 @@ type TelegramTextLinkEntity = {
|
||||
url?: string;
|
||||
};
|
||||
|
||||
export function expandTextLinks(
|
||||
text: string,
|
||||
entities?: TelegramTextLinkEntity[] | null,
|
||||
): string {
|
||||
export function expandTextLinks(text: string, entities?: TelegramTextLinkEntity[] | null): string {
|
||||
if (!text || !entities?.length) return text;
|
||||
|
||||
const textLinks = entities
|
||||
@@ -140,7 +137,8 @@ export function expandTextLinks(
|
||||
for (const entity of textLinks) {
|
||||
const linkText = text.slice(entity.offset, entity.offset + entity.length);
|
||||
const markdown = `[${linkText}](${entity.url})`;
|
||||
result = result.slice(0, entity.offset) + markdown + result.slice(entity.offset + entity.length);
|
||||
result =
|
||||
result.slice(0, entity.offset) + markdown + result.slice(entity.offset + entity.length);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -70,9 +70,7 @@ export async function probeTelegram(
|
||||
id: meJson.result?.id ?? null,
|
||||
username: meJson.result?.username ?? null,
|
||||
canJoinGroups:
|
||||
typeof meJson.result?.can_join_groups === "boolean"
|
||||
? meJson.result?.can_join_groups
|
||||
: null,
|
||||
typeof meJson.result?.can_join_groups === "boolean" ? meJson.result?.can_join_groups : null,
|
||||
canReadAllGroupMessages:
|
||||
typeof meJson.result?.can_read_all_group_messages === "boolean"
|
||||
? meJson.result?.can_read_all_group_messages
|
||||
|
||||
Reference in New Issue
Block a user