mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:31:23 +00:00
fix(telegram): cron and heartbeat messages land in wrong chat instead of target topic (#19367)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: bf02bbf9ce
Co-authored-by: Lukavyi <1013690+Lukavyi@users.noreply.github.com>
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Reviewed-by: @obviyus
This commit is contained in:
@@ -305,6 +305,46 @@ describe("resolveHeartbeatDeliveryTarget", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps explicit telegram targets", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: { defaults: { heartbeat: { target: "telegram", to: "123" } } },
|
||||
};
|
||||
expect(resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry })).toEqual({
|
||||
channel: "telegram",
|
||||
to: "123",
|
||||
accountId: undefined,
|
||||
lastChannel: undefined,
|
||||
lastAccountId: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("parses threadId from :topic: suffix in heartbeat to", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: {
|
||||
defaults: {
|
||||
heartbeat: { target: "telegram", to: "-100111:topic:42" },
|
||||
},
|
||||
},
|
||||
};
|
||||
const result = resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry });
|
||||
expect(result.channel).toBe("telegram");
|
||||
expect(result.to).toBe("-100111");
|
||||
expect(result.threadId).toBe(42);
|
||||
});
|
||||
|
||||
it("heartbeat to without :topic: has no threadId", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: {
|
||||
defaults: {
|
||||
heartbeat: { target: "telegram", to: "-100111" },
|
||||
},
|
||||
},
|
||||
};
|
||||
const result = resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry });
|
||||
expect(result.to).toBe("-100111");
|
||||
expect(result.threadId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("uses explicit heartbeat accountId when provided", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: {
|
||||
|
||||
Reference in New Issue
Block a user