mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-20 05:31:30 +00:00
refactor: move Telegram channel implementation to extensions/ (#45635)
* refactor: move Telegram channel implementation to extensions/telegram/src/ Move all Telegram channel code (123 files + 10 bot/ files + 8 channel plugin files) from src/telegram/ and src/channels/plugins/*/telegram.ts to extensions/telegram/src/. Leave thin re-export shims at original locations so cross-cutting src/ imports continue to resolve. - Fix all relative import paths in moved files (../X/ -> ../../../src/X/) - Fix vi.mock paths in 60 test files - Fix inline typeof import() expressions - Update tsconfig.plugin-sdk.dts.json rootDir to "." for cross-directory DTS - Update write-plugin-sdk-entry-dts.ts for new rootDir structure - Move channel plugin files with correct path remapping * fix: support keyed telegram send deps * fix: sync telegram extension copies with latest main * fix: correct import paths and remove misplaced files in telegram extension * fix: sync outbound-adapter with main (add sendTelegramPayloadMessages) and fix delivery.test import path
This commit is contained in:
58
extensions/telegram/src/fetch.env-proxy-runtime.test.ts
Normal file
58
extensions/telegram/src/fetch.env-proxy-runtime.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { createRequire } from "node:module";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const EnvHttpProxyAgent = require("undici/lib/dispatcher/env-http-proxy-agent.js") as {
|
||||
new (opts?: Record<string, unknown>): Record<PropertyKey, unknown>;
|
||||
};
|
||||
const { kHttpsProxyAgent, kNoProxyAgent } = require("undici/lib/core/symbols.js") as {
|
||||
kHttpsProxyAgent: symbol;
|
||||
kNoProxyAgent: symbol;
|
||||
};
|
||||
|
||||
function getOwnSymbolValue(
|
||||
target: Record<PropertyKey, unknown>,
|
||||
description: string,
|
||||
): Record<string, unknown> | undefined {
|
||||
const symbol = Object.getOwnPropertySymbols(target).find(
|
||||
(entry) => entry.description === description,
|
||||
);
|
||||
const value = symbol ? target[symbol] : undefined;
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : undefined;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
describe("undici env proxy semantics", () => {
|
||||
it("uses proxyTls rather than connect for proxied HTTPS transport settings", () => {
|
||||
vi.stubEnv("HTTPS_PROXY", "http://127.0.0.1:7890");
|
||||
const connect = {
|
||||
family: 4,
|
||||
autoSelectFamily: false,
|
||||
};
|
||||
|
||||
const withoutProxyTls = new EnvHttpProxyAgent({ connect });
|
||||
const noProxyAgent = withoutProxyTls[kNoProxyAgent] as Record<PropertyKey, unknown>;
|
||||
const httpsProxyAgent = withoutProxyTls[kHttpsProxyAgent] as Record<PropertyKey, unknown>;
|
||||
|
||||
expect(getOwnSymbolValue(noProxyAgent, "options")?.connect).toEqual(
|
||||
expect.objectContaining(connect),
|
||||
);
|
||||
expect(getOwnSymbolValue(httpsProxyAgent, "proxy tls settings")).toBeUndefined();
|
||||
|
||||
const withProxyTls = new EnvHttpProxyAgent({
|
||||
connect,
|
||||
proxyTls: connect,
|
||||
});
|
||||
const httpsProxyAgentWithProxyTls = withProxyTls[kHttpsProxyAgent] as Record<
|
||||
PropertyKey,
|
||||
unknown
|
||||
>;
|
||||
|
||||
expect(getOwnSymbolValue(httpsProxyAgentWithProxyTls, "proxy tls settings")).toEqual(
|
||||
expect.objectContaining(connect),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user