mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 00:53:33 +00:00
refactor: 统一账户过期时间字段映射和检查逻辑
主要改进: 1. 创建 mapExpiryField() 工具函数统一处理前后端字段映射(expiresAt -> subscriptionExpiresAt) 2. 统一 subscriptionExpiresAt 初始值为 null(替代空字符串) 3. 规范过期检查方法名为 isSubscriptionExpired(),返回 true 表示已过期 4. 优化过期检查条件判断,只检查 null 而非空字符串 5. 补充 OpenAI-Responses 和调度器中缺失的过期检查逻辑 6. 添加代码评审文档记录未修复问题 影响范围: - 所有 9 种账户服务的过期字段处理 - admin.js 中所有账户更新路由 - 统一调度器的过期账户过滤逻辑 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -738,7 +738,7 @@ class DroidAccountService {
|
||||
expiresAt: normalizedExpiresAt || '', // OAuth Token 过期时间(技术字段,自动刷新)
|
||||
|
||||
// ✅ 新增:账户订阅到期时间(业务字段,手动管理)
|
||||
subscriptionExpiresAt: options.subscriptionExpiresAt || '',
|
||||
subscriptionExpiresAt: options.subscriptionExpiresAt || null,
|
||||
|
||||
proxy: proxy ? JSON.stringify(proxy) : '',
|
||||
isActive: isActive.toString(),
|
||||
@@ -828,6 +828,7 @@ class DroidAccountService {
|
||||
|
||||
// ✅ 前端显示订阅过期时间(业务字段)
|
||||
expiresAt: account.subscriptionExpiresAt || null,
|
||||
platform: account.platform || 'droid',
|
||||
|
||||
apiKeyCount: (() => {
|
||||
const parsedCount = this._parseApiKeyEntries(account.apiKeys).length
|
||||
@@ -1276,8 +1277,8 @@ class DroidAccountService {
|
||||
* @param {Object} account - 账户对象
|
||||
* @returns {boolean} - true: 已过期, false: 未过期
|
||||
*/
|
||||
_isSubscriptionExpired(account) {
|
||||
if (!account.subscriptionExpiresAt || account.subscriptionExpiresAt === '') {
|
||||
isSubscriptionExpired(account) {
|
||||
if (!account.subscriptionExpiresAt) {
|
||||
return false // 未设置视为永不过期
|
||||
}
|
||||
const expiryDate = new Date(account.subscriptionExpiresAt)
|
||||
@@ -1330,7 +1331,7 @@ class DroidAccountService {
|
||||
const status = typeof account.status === 'string' ? account.status.toLowerCase() : ''
|
||||
|
||||
// ✅ 检查账户订阅是否过期
|
||||
if (this._isSubscriptionExpired(account)) {
|
||||
if (this.isSubscriptionExpired(account)) {
|
||||
logger.debug(
|
||||
`⏰ Skipping expired Droid account: ${account.name}, expired at ${account.subscriptionExpiresAt}`
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user