mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 12:02:27 +08:00
fix(grok): preserve media eligibility in scheduler cache
This commit is contained in:
@@ -961,6 +961,8 @@ func filterSchedulerExtra(extra map[string]any) map[string]any {
|
||||
"auto_pause_7d_disabled",
|
||||
"model_rate_limits",
|
||||
service.UpstreamBillingProbeExtraKey,
|
||||
service.GrokMediaEligibleExtraKey,
|
||||
"grok_billing_snapshot",
|
||||
}
|
||||
filtered := make(map[string]any)
|
||||
for _, key := range keys {
|
||||
|
||||
@@ -276,6 +276,50 @@ func TestBuildSchedulerMetadataAccount_KeepsOpenAIWSFlags(t *testing.T) {
|
||||
require.Nil(t, got.Extra["unused_large_field"])
|
||||
}
|
||||
|
||||
func TestBuildSchedulerMetadataAccount_KeepsGrokMediaEligibility(t *testing.T) {
|
||||
t.Run("explicit override", func(t *testing.T) {
|
||||
account := service.Account{
|
||||
ID: 43,
|
||||
Platform: service.PlatformGrok,
|
||||
Type: service.AccountTypeOAuth,
|
||||
Extra: map[string]any{
|
||||
service.GrokMediaEligibleExtraKey: false,
|
||||
"unused_large_field": "drop-me",
|
||||
},
|
||||
}
|
||||
|
||||
got := buildSchedulerMetadataAccount(account)
|
||||
|
||||
eligible, reason := got.GrokMediaGenerationEligibility()
|
||||
require.False(t, eligible)
|
||||
require.Equal(t, "override_disabled", reason)
|
||||
require.Equal(t, false, got.Extra[service.GrokMediaEligibleExtraKey])
|
||||
require.Nil(t, got.Extra["unused_large_field"])
|
||||
})
|
||||
|
||||
t.Run("forbidden billing observation", func(t *testing.T) {
|
||||
account := service.Account{
|
||||
ID: 44,
|
||||
Platform: service.PlatformGrok,
|
||||
Type: service.AccountTypeOAuth,
|
||||
Extra: map[string]any{
|
||||
"grok_billing_snapshot": map[string]any{
|
||||
"status_code": 200,
|
||||
"weekly_status_code": 403,
|
||||
"monthly_status_code": 200,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
got := buildSchedulerMetadataAccount(account)
|
||||
|
||||
eligible, reason := got.GrokMediaGenerationEligibility()
|
||||
require.False(t, eligible)
|
||||
require.Equal(t, "billing_forbidden", reason)
|
||||
require.NotNil(t, got.Extra["grok_billing_snapshot"])
|
||||
})
|
||||
}
|
||||
|
||||
func TestBuildSchedulerMetadataAccount_KeepsSlimGroupMembership(t *testing.T) {
|
||||
account := service.Account{
|
||||
ID: 42,
|
||||
|
||||
Reference in New Issue
Block a user