Merge pull request #2571 from sherlockwhite/fix/openai-account-email-and-usage-refresh

fix(accounts): show email and fix usage refresh for OpenAI OAuth accounts
This commit is contained in:
Wesley Liddick
2026-05-19 16:56:26 +08:00
committed by GitHub
6 changed files with 50 additions and 17 deletions
@@ -1643,7 +1643,7 @@ func (h *OAuthHandler) SetupTokenCookieAuth(c *gin.Context) {
}
// GetUsage handles getting account usage information
// GET /api/v1/admin/accounts/:id/usage?source=passive|active
// GET /api/v1/admin/accounts/:id/usage?source=passive|active&force=true
func (h *AccountHandler) GetUsage(c *gin.Context) {
accountID, err := strconv.ParseInt(c.Param("id"), 10, 64)
if err != nil {
@@ -1652,12 +1652,13 @@ func (h *AccountHandler) GetUsage(c *gin.Context) {
}
source := c.DefaultQuery("source", "active")
force := c.Query("force") == "true"
var usage *service.UsageInfo
if source == "passive" {
usage, err = h.accountUsageService.GetPassiveUsage(c.Request.Context(), accountID)
} else {
usage, err = h.accountUsageService.GetUsage(c.Request.Context(), accountID)
usage, err = h.accountUsageService.GetUsage(c.Request.Context(), accountID, force)
}
if err != nil {
response.ErrorFrom(c, err)