修复 OpenAI OAuth 刷新未补全账号信息#2881
Open
xiaoyiluck666 wants to merge 1 commit into
Open
Conversation
Contributor
|
All contributors have signed the CLA. ✅ |
f677a96 to
eba2046
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复内容
本 PR 修复 OpenAI OAuth 账号刷新时账号信息补全没有生效的问题:
OpenAIOAuthService的正式启动注入PrivacyClientFactory,确保enrichTokenInfo能实际调用 ChatGPT backend-api。refresh_token、仅复用现有access_token的刷新路径,使手动“刷新令牌”时也会执行账号信息补全。accounts/check没有返回subscription_expires_at时,补充调用backend-api/subscriptions?account_id=...,从active_until回填 Plus 到期时间。问题背景
当前代码里已有 OpenAI plan / privacy / subscription enrichment 相关逻辑,但
OpenAIOAuthService在 Wire 启动链路中是直接通过NewOpenAIOAuthService创建的,没有注入PrivacyClientFactory。因此enrichTokenInfo会因为privacyClientFactory == nil直接返回。另外,当账号没有
refresh_token但已有access_token时,RefreshAccountToken会直接复用现有 token 返回,也没有执行补全逻辑。这样会导致管理员手动点击刷新后,Plus 到期时间、训练数据共享状态等字段仍然不更新。测试
已执行:
结果通过。
本地也通过真实刷新接口验证:对一个
subscription_expires_at为空的 OpenAI OAuth Plus 账号调用/api/v1/admin/accounts/:id/refresh后,数据库成功写入subscription_expires_at,并更新privacy_mode=training_off。