mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
refactor(pairing): share allowFrom path resolution
This commit is contained in:
@@ -14,6 +14,7 @@ import { saveSessionStore } from "../config/sessions.js";
|
||||
import { canonicalizeMainSessionAlias } from "../config/sessions/main-session.js";
|
||||
import type { SessionScope } from "../config/sessions/types.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { resolveChannelAllowFromPath } from "../pairing/pairing-store.js";
|
||||
import {
|
||||
buildAgentMainSessionKey,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
@@ -617,10 +618,11 @@ export async function detectLegacyStateMigrations(params: {
|
||||
const hasLegacyWhatsAppAuth =
|
||||
fileExists(path.join(oauthDir, "creds.json")) &&
|
||||
!fileExists(path.join(targetWhatsAppAuthDir, "creds.json"));
|
||||
const legacyTelegramAllowFromPath = path.join(oauthDir, "telegram-allowFrom.json");
|
||||
const targetTelegramAllowFromPath = path.join(
|
||||
oauthDir,
|
||||
`telegram-${DEFAULT_ACCOUNT_ID}-allowFrom.json`,
|
||||
const legacyTelegramAllowFromPath = resolveChannelAllowFromPath("telegram", env);
|
||||
const targetTelegramAllowFromPath = resolveChannelAllowFromPath(
|
||||
"telegram",
|
||||
env,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
);
|
||||
const hasLegacyTelegramAllowFrom =
|
||||
fileExists(legacyTelegramAllowFromPath) && !fileExists(targetTelegramAllowFromPath);
|
||||
|
||||
@@ -104,6 +104,14 @@ function resolveAllowFromPath(
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveChannelAllowFromPath(
|
||||
channel: PairingChannel,
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
accountId?: string,
|
||||
): string {
|
||||
return resolveAllowFromPath(channel, env, accountId);
|
||||
}
|
||||
|
||||
async function readJsonFile<T>(
|
||||
filePath: string,
|
||||
fallback: T,
|
||||
|
||||
Reference in New Issue
Block a user