refactor(outbound): centralize telegram account defaults

This commit is contained in:
Peter Steinberger
2026-01-08 21:03:11 +01:00
parent e90c00768f
commit 31fb5867e8
9 changed files with 214 additions and 43 deletions

View File

@@ -7,7 +7,7 @@ import {
} from "./deliver.js";
describe("deliverOutboundPayloads", () => {
it("chunks telegram markdown and passes account id", async () => {
it("chunks telegram markdown and passes through accountId", async () => {
const sendTelegram = vi
.fn()
.mockResolvedValue({ messageId: "m1", chatId: "c1" });
@@ -28,7 +28,7 @@ describe("deliverOutboundPayloads", () => {
expect(sendTelegram).toHaveBeenCalledTimes(2);
for (const call of sendTelegram.mock.calls) {
expect(call[2]).toEqual(
expect.objectContaining({ accountId: "default", verbose: false }),
expect.objectContaining({ accountId: undefined, verbose: false }),
);
}
expect(results).toHaveLength(2);
@@ -42,6 +42,30 @@ describe("deliverOutboundPayloads", () => {
}
});
it("passes explicit accountId to sendTelegram", async () => {
const sendTelegram = vi
.fn()
.mockResolvedValue({ messageId: "m1", chatId: "c1" });
const cfg: ClawdbotConfig = {
telegram: { botToken: "tok-1", textChunkLimit: 2 },
};
await deliverOutboundPayloads({
cfg,
provider: "telegram",
to: "123",
accountId: "default",
payloads: [{ text: "hi" }],
deps: { sendTelegram },
});
expect(sendTelegram).toHaveBeenCalledWith(
"123",
"hi",
expect.objectContaining({ accountId: "default", verbose: false }),
);
});
it("uses signal media maxBytes from config", async () => {
const sendSignal = vi
.fn()