fix(cron): parse telegram targets with prefixes (thanks @mitschabaude-bot)
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- Daemon: align generated systemd unit with docs for network-online + restart delay. (#479) — thanks @azade-c
|
- Daemon: align generated systemd unit with docs for network-online + restart delay. (#479) — thanks @azade-c
|
||||||
- Outbound: default Telegram account selection for config-only tokens; remove heartbeat-specific accountId handling. (follow-up #516) — thanks @YuriNachos
|
- Outbound: default Telegram account selection for config-only tokens; remove heartbeat-specific accountId handling. (follow-up #516) — thanks @YuriNachos
|
||||||
|
- Cron: allow Telegram delivery targets with topic/thread IDs (e.g. `-100…:topic:123`). (#474) — thanks @mitschabaude-bot
|
||||||
- Heartbeat: resolve Telegram account IDs from config-only tokens; cron tool accepts canonical `jobId` and legacy `id` for job actions. (#516) — thanks @YuriNachos
|
- Heartbeat: resolve Telegram account IDs from config-only tokens; cron tool accepts canonical `jobId` and legacy `id` for job actions. (#516) — thanks @YuriNachos
|
||||||
- Discord: stop provider when gateway reconnects are exhausted and surface errors. (#514) — thanks @joshp123
|
- Discord: stop provider when gateway reconnects are exhausted and surface errors. (#514) — thanks @joshp123
|
||||||
- Auto-reply: preserve block reply ordering with timeout fallback for streaming. (#503) — thanks @joshp123
|
- Auto-reply: preserve block reply ordering with timeout fallback for streaming. (#503) — thanks @joshp123
|
||||||
|
|||||||
@@ -716,4 +716,20 @@ describe("parseTelegramTarget", () => {
|
|||||||
topicId: undefined,
|
topicId: undefined,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("strips internal telegram prefix", () => {
|
||||||
|
expect(parseTelegramTarget("telegram:123")).toEqual({
|
||||||
|
chatId: "123",
|
||||||
|
topicId: undefined,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("strips internal telegram + group prefixes before parsing topic", () => {
|
||||||
|
expect(parseTelegramTarget("telegram:group:-1001234567890:topic:456")).toEqual(
|
||||||
|
{
|
||||||
|
chatId: "-1001234567890",
|
||||||
|
topicId: 456,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,7 +61,16 @@ export function parseTelegramTarget(to: string): {
|
|||||||
chatId: string;
|
chatId: string;
|
||||||
topicId: number | undefined;
|
topicId: number | undefined;
|
||||||
} {
|
} {
|
||||||
const trimmed = to.trim();
|
let trimmed = to.trim();
|
||||||
|
|
||||||
|
// Cron "lastTo" values can include internal prefixes like `telegram:...` or
|
||||||
|
// `telegram:group:...` (see normalizeChatId in telegram/send.ts).
|
||||||
|
// Strip these before parsing `:topic:` / `:<topicId>` suffixes.
|
||||||
|
while (true) {
|
||||||
|
const next = trimmed.replace(/^(telegram|tg|group):/i, "").trim();
|
||||||
|
if (next === trimmed) break;
|
||||||
|
trimmed = next;
|
||||||
|
}
|
||||||
|
|
||||||
// Try format: chatId:topic:topicId
|
// Try format: chatId:topic:topicId
|
||||||
const topicMatch = /^(.+?):topic:(\d+)$/.exec(trimmed);
|
const topicMatch = /^(.+?):topic:(\d+)$/.exec(trimmed);
|
||||||
|
|||||||
Reference in New Issue
Block a user