feat: add API endpoint for uploading and validating team owner accounts with concurrent account ID fetching and database storage.

This commit is contained in:
2026-01-30 13:19:28 +08:00
parent 2a0a8941c2
commit 3430b57cbf

View File

@@ -10,6 +10,7 @@ import (
"unicode"
"codex-pool/internal/client"
"codex-pool/internal/config"
"codex-pool/internal/database"
"codex-pool/internal/logger"
)
@@ -255,7 +256,13 @@ func normalizeOwner(rec accountRecord, index int) (database.TeamOwner, error) {
// fetchAccountID 通过 token 获取 account_id
func fetchAccountID(token string) (string, error) {
tlsClient, err := client.New("")
// 使用配置中的代理(如果启用)
proxy := ""
if cfg := config.Get(); cfg != nil {
proxy = cfg.GetProxy()
}
tlsClient, err := client.New(proxy)
if err != nil {
return "", fmt.Errorf("创建 TLS 客户端失败: %v", err)
}
@@ -274,15 +281,15 @@ func fetchAccountID(token string) (string, error) {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("API 返回状态码: %d", resp.StatusCode)
}
body, err := client.ReadBody(resp)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("读取响应失败: %v", err)
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("API 返回状态码: %d, 响应: %s", resp.StatusCode, string(body)[:min(200, len(body))])
}
// 解析响应
var result struct {
Accounts map[string]struct {