mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:02:42 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -16,12 +16,18 @@ function resolveAccountGroups(
|
||||
cfg: OpenClawConfig,
|
||||
accountId?: string | null,
|
||||
): { groups?: TelegramGroups } {
|
||||
if (!accountId) return {};
|
||||
if (!accountId) {
|
||||
return {};
|
||||
}
|
||||
const normalized = normalizeAccountId(accountId);
|
||||
const accounts = cfg.channels?.telegram?.accounts;
|
||||
if (!accounts || typeof accounts !== "object") return {};
|
||||
if (!accounts || typeof accounts !== "object") {
|
||||
return {};
|
||||
}
|
||||
const exact = accounts[normalized];
|
||||
if (exact?.groups) return { groups: exact.groups };
|
||||
if (exact?.groups) {
|
||||
return { groups: exact.groups };
|
||||
}
|
||||
const matchKey = Object.keys(accounts).find(
|
||||
(key) => key.toLowerCase() === normalized.toLowerCase(),
|
||||
);
|
||||
@@ -33,10 +39,18 @@ export function migrateTelegramGroupsInPlace(
|
||||
oldChatId: string,
|
||||
newChatId: string,
|
||||
): { migrated: boolean; skippedExisting: boolean } {
|
||||
if (!groups) return { migrated: false, skippedExisting: false };
|
||||
if (oldChatId === newChatId) return { migrated: false, skippedExisting: false };
|
||||
if (!Object.hasOwn(groups, oldChatId)) return { migrated: false, skippedExisting: false };
|
||||
if (Object.hasOwn(groups, newChatId)) return { migrated: false, skippedExisting: true };
|
||||
if (!groups) {
|
||||
return { migrated: false, skippedExisting: false };
|
||||
}
|
||||
if (oldChatId === newChatId) {
|
||||
return { migrated: false, skippedExisting: false };
|
||||
}
|
||||
if (!Object.hasOwn(groups, oldChatId)) {
|
||||
return { migrated: false, skippedExisting: false };
|
||||
}
|
||||
if (Object.hasOwn(groups, newChatId)) {
|
||||
return { migrated: false, skippedExisting: true };
|
||||
}
|
||||
groups[newChatId] = groups[oldChatId];
|
||||
delete groups[oldChatId];
|
||||
return { migrated: true, skippedExisting: false };
|
||||
@@ -59,7 +73,9 @@ export function migrateTelegramGroupConfig(params: {
|
||||
migrated = true;
|
||||
scopes.push("account");
|
||||
}
|
||||
if (result.skippedExisting) skippedExisting = true;
|
||||
if (result.skippedExisting) {
|
||||
skippedExisting = true;
|
||||
}
|
||||
}
|
||||
|
||||
const globalGroups = params.cfg.channels?.telegram?.groups;
|
||||
@@ -69,7 +85,9 @@ export function migrateTelegramGroupConfig(params: {
|
||||
migrated = true;
|
||||
scopes.push("global");
|
||||
}
|
||||
if (result.skippedExisting) skippedExisting = true;
|
||||
if (result.skippedExisting) {
|
||||
skippedExisting = true;
|
||||
}
|
||||
}
|
||||
|
||||
return { migrated, skippedExisting, scopes };
|
||||
|
||||
Reference in New Issue
Block a user