mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:38:26 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -16,12 +16,18 @@ function resolveAccountChannels(
|
||||
cfg: OpenClawConfig,
|
||||
accountId?: string | null,
|
||||
): { channels?: SlackChannels } {
|
||||
if (!accountId) return {};
|
||||
if (!accountId) {
|
||||
return {};
|
||||
}
|
||||
const normalized = normalizeAccountId(accountId);
|
||||
const accounts = cfg.channels?.slack?.accounts;
|
||||
if (!accounts || typeof accounts !== "object") return {};
|
||||
if (!accounts || typeof accounts !== "object") {
|
||||
return {};
|
||||
}
|
||||
const exact = accounts[normalized];
|
||||
if (exact?.channels) return { channels: exact.channels };
|
||||
if (exact?.channels) {
|
||||
return { channels: exact.channels };
|
||||
}
|
||||
const matchKey = Object.keys(accounts).find(
|
||||
(key) => key.toLowerCase() === normalized.toLowerCase(),
|
||||
);
|
||||
@@ -33,10 +39,18 @@ export function migrateSlackChannelsInPlace(
|
||||
oldChannelId: string,
|
||||
newChannelId: string,
|
||||
): { migrated: boolean; skippedExisting: boolean } {
|
||||
if (!channels) return { migrated: false, skippedExisting: false };
|
||||
if (oldChannelId === newChannelId) return { migrated: false, skippedExisting: false };
|
||||
if (!Object.hasOwn(channels, oldChannelId)) return { migrated: false, skippedExisting: false };
|
||||
if (Object.hasOwn(channels, newChannelId)) return { migrated: false, skippedExisting: true };
|
||||
if (!channels) {
|
||||
return { migrated: false, skippedExisting: false };
|
||||
}
|
||||
if (oldChannelId === newChannelId) {
|
||||
return { migrated: false, skippedExisting: false };
|
||||
}
|
||||
if (!Object.hasOwn(channels, oldChannelId)) {
|
||||
return { migrated: false, skippedExisting: false };
|
||||
}
|
||||
if (Object.hasOwn(channels, newChannelId)) {
|
||||
return { migrated: false, skippedExisting: true };
|
||||
}
|
||||
channels[newChannelId] = channels[oldChannelId];
|
||||
delete channels[oldChannelId];
|
||||
return { migrated: true, skippedExisting: false };
|
||||
@@ -63,7 +77,9 @@ export function migrateSlackChannelConfig(params: {
|
||||
migrated = true;
|
||||
scopes.push("account");
|
||||
}
|
||||
if (result.skippedExisting) skippedExisting = true;
|
||||
if (result.skippedExisting) {
|
||||
skippedExisting = true;
|
||||
}
|
||||
}
|
||||
|
||||
const globalChannels = params.cfg.channels?.slack?.channels;
|
||||
@@ -77,7 +93,9 @@ export function migrateSlackChannelConfig(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