Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
7b6ff135
Unverified
Commit
7b6ff135
authored
Apr 03, 2026
by
Wesley Liddick
Committed by
GitHub
Apr 03, 2026
Browse files
Merge pull request #1424 from DaydreamCoding/fix/antigravity-batch-privacy
fix(antigravity): 修复批量刷新令牌不设置隐私模式的问题
parents
055c48ab
b155bc56
Changes
4
Show whitespace changes
Inline
Side-by-side
backend/internal/handler/admin/account_handler.go
View file @
7b6ff135
...
@@ -839,6 +839,7 @@ func (h *AccountHandler) refreshSingleAccount(ctx context.Context, account *serv
...
@@ -839,6 +839,7 @@ func (h *AccountHandler) refreshSingleAccount(ctx context.Context, account *serv
if
updateErr
!=
nil
{
if
updateErr
!=
nil
{
return
nil
,
""
,
fmt
.
Errorf
(
"failed to update credentials: %w"
,
updateErr
)
return
nil
,
""
,
fmt
.
Errorf
(
"failed to update credentials: %w"
,
updateErr
)
}
}
h
.
adminService
.
EnsureAntigravityPrivacy
(
ctx
,
updatedAccount
)
return
updatedAccount
,
"missing_project_id_temporary"
,
nil
return
updatedAccount
,
"missing_project_id_temporary"
,
nil
}
}
...
...
backend/internal/service/admin_service.go
View file @
7b6ff135
...
@@ -2783,16 +2783,14 @@ func (s *adminServiceImpl) ForceOpenAIPrivacy(ctx context.Context, account *Acco
...
@@ -2783,16 +2783,14 @@ func (s *adminServiceImpl) ForceOpenAIPrivacy(ctx context.Context, account *Acco
}
}
// EnsureAntigravityPrivacy 检查 Antigravity OAuth 账号隐私状态。
// EnsureAntigravityPrivacy 检查 Antigravity OAuth 账号隐私状态。
// 如果 Extra["privacy_mode"] 已存在(无论成功或失败),直接跳过。
// 仅当 privacy_mode 已成功设置("privacy_set")时跳过;
// 仅对从未设置过隐私的账号执行 setUserSettings + fetchUserInfo 流程。
// 未设置或之前失败("privacy_set_failed")均会重试。
// 用户可通过前端 ForceAntigravityPrivacy(SetPrivacy 按钮)强制重新设置。
func
(
s
*
adminServiceImpl
)
EnsureAntigravityPrivacy
(
ctx
context
.
Context
,
account
*
Account
)
string
{
func
(
s
*
adminServiceImpl
)
EnsureAntigravityPrivacy
(
ctx
context
.
Context
,
account
*
Account
)
string
{
if
account
.
Platform
!=
PlatformAntigravity
||
account
.
Type
!=
AccountTypeOAuth
{
if
account
.
Platform
!=
PlatformAntigravity
||
account
.
Type
!=
AccountTypeOAuth
{
return
""
return
""
}
}
// 已设置过则跳过(无论成功或失败),用户可通过 Force 手动重试
if
account
.
Extra
!=
nil
{
if
account
.
Extra
!=
nil
{
if
existing
,
ok
:=
account
.
Extra
[
"privacy_mode"
]
.
(
string
);
ok
&&
existing
!
=
""
{
if
existing
,
ok
:=
account
.
Extra
[
"privacy_mode"
]
.
(
string
);
ok
&&
existing
=
=
AntigravityPrivacySet
{
return
existing
return
existing
}
}
}
}
...
...
backend/internal/service/antigravity_oauth_service.go
View file @
7b6ff135
...
@@ -91,6 +91,7 @@ type AntigravityTokenInfo struct {
...
@@ -91,6 +91,7 @@ type AntigravityTokenInfo struct {
ProjectID
string
`json:"project_id,omitempty"`
ProjectID
string
`json:"project_id,omitempty"`
ProjectIDMissing
bool
`json:"-"`
ProjectIDMissing
bool
`json:"-"`
PlanType
string
`json:"-"`
PlanType
string
`json:"-"`
PrivacyMode
string
`json:"-"`
}
}
// ExchangeCode 用 authorization code 交换 token
// ExchangeCode 用 authorization code 交换 token
...
@@ -159,6 +160,9 @@ func (s *AntigravityOAuthService) ExchangeCode(ctx context.Context, input *Antig
...
@@ -159,6 +160,9 @@ func (s *AntigravityOAuthService) ExchangeCode(ctx context.Context, input *Antig
}
}
}
}
// 令牌刚获取,立即设置隐私(不依赖后续账号创建流程)
result
.
PrivacyMode
=
setAntigravityPrivacy
(
ctx
,
result
.
AccessToken
,
result
.
ProjectID
,
proxyURL
)
return
result
,
nil
return
result
,
nil
}
}
...
@@ -248,6 +252,9 @@ func (s *AntigravityOAuthService) ValidateRefreshToken(ctx context.Context, refr
...
@@ -248,6 +252,9 @@ func (s *AntigravityOAuthService) ValidateRefreshToken(ctx context.Context, refr
}
}
}
}
// 令牌刚获取,立即设置隐私
tokenInfo
.
PrivacyMode
=
setAntigravityPrivacy
(
ctx
,
tokenInfo
.
AccessToken
,
tokenInfo
.
ProjectID
,
proxyURL
)
return
tokenInfo
,
nil
return
tokenInfo
,
nil
}
}
...
...
backend/internal/service/token_refresh_service.go
View file @
7b6ff135
...
@@ -489,15 +489,14 @@ func (s *TokenRefreshService) ensureOpenAIPrivacy(ctx context.Context, account *
...
@@ -489,15 +489,14 @@ func (s *TokenRefreshService) ensureOpenAIPrivacy(ctx context.Context, account *
}
}
// ensureAntigravityPrivacy 后台刷新中检查 Antigravity OAuth 账号隐私状态。
// ensureAntigravityPrivacy 后台刷新中检查 Antigravity OAuth 账号隐私状态。
// 仅
做 Extra["
privacy_mode
"] 存在性检查,不发起 HTTP 请求,避免每轮循环产生额外网络开销。
// 仅
当
privacy_mode
已成功设置("privacy_set")时跳过;
//
用户可通过前端 SetPrivacy 按钮强制重新设置
。
//
未设置或之前失败("privacy_set_failed")均会重试
。
func
(
s
*
TokenRefreshService
)
ensureAntigravityPrivacy
(
ctx
context
.
Context
,
account
*
Account
)
{
func
(
s
*
TokenRefreshService
)
ensureAntigravityPrivacy
(
ctx
context
.
Context
,
account
*
Account
)
{
if
account
.
Platform
!=
PlatformAntigravity
||
account
.
Type
!=
AccountTypeOAuth
{
if
account
.
Platform
!=
PlatformAntigravity
||
account
.
Type
!=
AccountTypeOAuth
{
return
return
}
}
// 已设置过(无论成功或失败)则跳过,不发 HTTP
if
account
.
Extra
!=
nil
{
if
account
.
Extra
!=
nil
{
if
_
,
ok
:=
account
.
Extra
[
"privacy_mode"
]
;
ok
{
if
mode
,
ok
:=
account
.
Extra
[
"privacy_mode"
]
.
(
string
);
ok
&&
mode
==
AntigravityPrivacySet
{
return
return
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment