Skip to content

Commit 381b44a

Browse files
authored
Match native Zalo bot identity fields (#99274)
1 parent 5fa2082 commit 381b44a

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

extensions/zalo/src/api.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ describe("Zalo API request methods", () => {
7676
});
7777
});
7878

79+
it("accepts the native Zalo getMe identity fields", async () => {
80+
const fetcher: ZaloFetch = vi.fn(async () =>
81+
Response.json({
82+
ok: true,
83+
result: {
84+
account_name: "bot.example",
85+
account_type: "BASIC",
86+
can_join_groups: false,
87+
id: "1459232241454765289",
88+
},
89+
}),
90+
);
91+
92+
await expect(getMe("test-token", undefined, fetcher)).resolves.toMatchObject({
93+
result: {
94+
account_name: "bot.example",
95+
account_type: "BASIC",
96+
can_join_groups: false,
97+
},
98+
});
99+
});
100+
79101
it("uses POST for getWebhookInfo", async () => {
80102
await expectPostJsonRequest(getWebhookInfo);
81103
});

extensions/zalo/src/api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ export type ZaloApiResponse<T = unknown> = {
2121

2222
export type ZaloBotInfo = {
2323
id: string;
24-
name: string;
25-
avatar?: string;
24+
account_name: string;
25+
account_type: string;
26+
can_join_groups: boolean;
2627
};
2728

2829
export type ZaloMessage = {

extensions/zalo/src/channel.runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function startZaloGatewayAccount(
5454
const fetcher = resolveZaloProxyFetch(account.config.proxy);
5555
try {
5656
const probe = await probeZalo(token, 2500, fetcher);
57-
const name = probe.ok ? probe.bot?.name?.trim() : null;
57+
const name = probe.ok ? probe.bot?.account_name?.trim() : null;
5858
if (name) {
5959
zaloBotLabel = ` (${name})`;
6060
}

0 commit comments

Comments
 (0)