fix: honor Telegram proxy dispatcher (#4456) (thanks @spiceoogway)
This commit is contained in:
@@ -72,6 +72,7 @@ Status: stable.
|
||||
- **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed).
|
||||
|
||||
### Fixes
|
||||
- Telegram: use undici fetch for per-account proxy dispatcher. (#4456) Thanks @spiceoogway.
|
||||
- Telegram: avoid silent empty replies by tracking normalization skips before fallback. (#3796)
|
||||
- Telegram: scope native skill commands to bound agent per bot. (#4360) Thanks @robhparker.
|
||||
- Mentions: honor mentionPatterns even when explicit mentions are present. (#3303) Thanks @HirokiKobayashi-R.
|
||||
|
||||
45
src/telegram/proxy.test.ts
Normal file
45
src/telegram/proxy.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { ProxyAgent, undiciFetch, proxyAgentSpy, getLastAgent } = vi.hoisted(() => {
|
||||
const undiciFetch = vi.fn();
|
||||
const proxyAgentSpy = vi.fn();
|
||||
class ProxyAgent {
|
||||
static lastCreated: ProxyAgent | undefined;
|
||||
proxyUrl: string;
|
||||
constructor(proxyUrl: string) {
|
||||
this.proxyUrl = proxyUrl;
|
||||
ProxyAgent.lastCreated = this;
|
||||
proxyAgentSpy(proxyUrl);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ProxyAgent,
|
||||
undiciFetch,
|
||||
proxyAgentSpy,
|
||||
getLastAgent: () => ProxyAgent.lastCreated,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("undici", () => ({
|
||||
ProxyAgent,
|
||||
fetch: undiciFetch,
|
||||
}));
|
||||
|
||||
import { makeProxyFetch } from "./proxy.js";
|
||||
|
||||
describe("makeProxyFetch", () => {
|
||||
it("uses undici fetch with ProxyAgent dispatcher", async () => {
|
||||
const proxyUrl = "http://proxy.test:8080";
|
||||
undiciFetch.mockResolvedValue({ ok: true });
|
||||
|
||||
const proxyFetch = makeProxyFetch(proxyUrl);
|
||||
await proxyFetch("https://api.telegram.org/bot123/getMe");
|
||||
|
||||
expect(proxyAgentSpy).toHaveBeenCalledWith(proxyUrl);
|
||||
expect(undiciFetch).toHaveBeenCalledWith(
|
||||
"https://api.telegram.org/bot123/getMe",
|
||||
expect.objectContaining({ dispatcher: getLastAgent() }),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user