From 60428921a1e3dcd346e0ce128373fc69a07f1e2e Mon Sep 17 00:00:00 2001 From: Feng Yue <2525275@gmail.com> Date: Tue, 2 Sep 2025 09:58:05 +0800 Subject: [PATCH 1/3] Fix schedulable flag for OpenAI and Azure accounts --- src/services/azureOpenaiAccountService.js | 6 +++++- src/services/openaiAccountService.js | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/azureOpenaiAccountService.js b/src/services/azureOpenaiAccountService.js index 49cb78cc..8ff86a99 100644 --- a/src/services/azureOpenaiAccountService.js +++ b/src/services/azureOpenaiAccountService.js @@ -296,7 +296,11 @@ async function getAllAccounts() { } } - accounts.push(accountData) + accounts.push({ + ...accountData, + isActive: accountData.isActive === 'true', + schedulable: accountData.schedulable !== 'false' + }) } } diff --git a/src/services/openaiAccountService.js b/src/services/openaiAccountService.js index 1e88cdec..e60a8b3a 100644 --- a/src/services/openaiAccountService.js +++ b/src/services/openaiAccountService.js @@ -502,6 +502,8 @@ async function getAllAccounts() { // 不解密敏感字段,只返回基本信息 accounts.push({ ...accountData, + isActive: accountData.isActive === 'true', + schedulable: accountData.schedulable !== 'false', openaiOauth: accountData.openaiOauth ? '[ENCRYPTED]' : '', accessToken: accountData.accessToken ? '[ENCRYPTED]' : '', refreshToken: accountData.refreshToken ? '[ENCRYPTED]' : '', From 23cb44f60f0d90470c883af7a350af2b54f6b920 Mon Sep 17 00:00:00 2001 From: Feng Yue <2525275@gmail.com> Date: Tue, 2 Sep 2025 10:06:59 +0800 Subject: [PATCH 2/3] fix: handle boolean account flags in OpenAI scheduler --- src/services/unifiedOpenAIScheduler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/unifiedOpenAIScheduler.js b/src/services/unifiedOpenAIScheduler.js index f800621c..32978328 100644 --- a/src/services/unifiedOpenAIScheduler.js +++ b/src/services/unifiedOpenAIScheduler.js @@ -34,7 +34,7 @@ class UnifiedOpenAIScheduler { // 普通专属账户 const boundAccount = await openaiAccountService.getAccount(apiKeyData.openaiAccountId) - if (boundAccount && boundAccount.isActive === 'true' && boundAccount.status !== 'error') { + if (boundAccount && boundAccount.isActive && boundAccount.status !== 'error') { // 检查是否被限流 const isRateLimited = await this.isAccountRateLimited(boundAccount.id) if (isRateLimited) { @@ -165,7 +165,7 @@ class UnifiedOpenAIScheduler { const openaiAccounts = await openaiAccountService.getAllAccounts() for (const account of openaiAccounts) { if ( - account.isActive === 'true' && + account.isActive && account.status !== 'error' && (account.accountType === 'shared' || !account.accountType) && // 兼容旧数据 this._isSchedulable(account.schedulable) @@ -233,7 +233,7 @@ class UnifiedOpenAIScheduler { try { if (accountType === 'openai') { const account = await openaiAccountService.getAccount(accountId) - if (!account || account.isActive !== 'true' || account.status === 'error') { + if (!account || !account.isActive || account.status === 'error') { return false } // 检查是否可调度 @@ -395,7 +395,7 @@ class UnifiedOpenAIScheduler { const account = await openaiAccountService.getAccount(memberId) if ( account && - account.isActive === 'true' && + account.isActive && account.status !== 'error' && this._isSchedulable(account.schedulable) ) { From 9f3fff1f27a49160a7bd0b1a6cecbd0c30def286 Mon Sep 17 00:00:00 2001 From: Feng Yue <2525275@gmail.com> Date: Tue, 2 Sep 2025 10:13:27 +0800 Subject: [PATCH 3/3] fix: treat OpenAI account isActive as string --- src/services/unifiedOpenAIScheduler.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/unifiedOpenAIScheduler.js b/src/services/unifiedOpenAIScheduler.js index 32978328..153f75b0 100644 --- a/src/services/unifiedOpenAIScheduler.js +++ b/src/services/unifiedOpenAIScheduler.js @@ -34,7 +34,11 @@ class UnifiedOpenAIScheduler { // 普通专属账户 const boundAccount = await openaiAccountService.getAccount(apiKeyData.openaiAccountId) - if (boundAccount && boundAccount.isActive && boundAccount.status !== 'error') { + if ( + boundAccount && + (boundAccount.isActive === true || boundAccount.isActive === 'true') && + boundAccount.status !== 'error' + ) { // 检查是否被限流 const isRateLimited = await this.isAccountRateLimited(boundAccount.id) if (isRateLimited) {