refactor(telegram): simplify send/dispatch/target handling (#17819)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: fcb7aeeca3
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Reviewed-by: @obviyus
This commit is contained in:
Ayaan Zaidi
2026-02-16 14:00:34 +05:30
committed by GitHub
parent 1f607bec49
commit b6a9741ba4
16 changed files with 1125 additions and 1141 deletions

View File

@@ -66,24 +66,19 @@ export function migrateTelegramGroupConfig(params: {
let migrated = false;
let skippedExisting = false;
const accountGroups = resolveAccountGroups(params.cfg, params.accountId).groups;
if (accountGroups) {
const result = migrateTelegramGroupsInPlace(accountGroups, params.oldChatId, params.newChatId);
if (result.migrated) {
migrated = true;
scopes.push("account");
}
if (result.skippedExisting) {
skippedExisting = true;
}
}
const migrationTargets: Array<{
scope: MigrationScope;
groups: TelegramGroups | undefined;
}> = [
{ scope: "account", groups: resolveAccountGroups(params.cfg, params.accountId).groups },
{ scope: "global", groups: params.cfg.channels?.telegram?.groups },
];
const globalGroups = params.cfg.channels?.telegram?.groups;
if (globalGroups) {
const result = migrateTelegramGroupsInPlace(globalGroups, params.oldChatId, params.newChatId);
for (const target of migrationTargets) {
const result = migrateTelegramGroupsInPlace(target.groups, params.oldChatId, params.newChatId);
if (result.migrated) {
migrated = true;
scopes.push("global");
scopes.push(target.scope);
}
if (result.skippedExisting) {
skippedExisting = true;