Repository navigation
fix: add Date header for email - #30
Merged
Merged
Conversation
Member
|
感谢pr |
x22x22
pushed a commit
to x22x22/new-api
that referenced
this pull request
Apr 24, 2026
x22x22
pushed a commit
to x22x22/new-api
that referenced
this pull request
Apr 24, 2026
x22x22
pushed a commit
to x22x22/new-api
that referenced
this pull request
Apr 24, 2026
fix: add Date header for email
jiutubaba
pushed a commit
to jiutubaba/fx-api
that referenced
this pull request
May 17, 2026
* fix: 修复 OpenAI 账号 5h/7d 使用限制显示错误的问题 问题描述: - 账号管理页面中,OpenAI OAuth 账号的 5h 列显示 7 天的剩余时间 - 7d 列却显示几小时的剩余时间 - 根本原因: OpenAI 响应头中 primary/secondary 的实际含义与代码假设相反 修复方案: 1. 后端归一化 (openai_gateway_service.go): - 根据 window_minutes 动态判断哪个是 5h/7d 限制 - 新增规范字段 codex_5h_* 和 codex_7d_* - 保留旧字段以兼容性 2. 前端适配 (AccountUsageCell.vue): - 优先使用新的规范字段 - Fallback 到旧字段时基于 window_minutes 动态判断 - 更新 computed 属性命名 3. 类型定义更新 (types/index.ts): - 添加新的规范字段定义 - 更新注释说明实际语义由 window_minutes 决定 🤖 Generated with Claude Code and Codex collaboration Co-Authored-By: Claude Sonnet 4.5 <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]> * fix: 改进窗口判断逻辑,修复两个窗口都小于阈值时的bug 问题: 当两个窗口都小于360分钟时(如 primary=180分钟,secondary=300分钟), 之前的逻辑会导致: - primary5h = true, secondary5h = true - 5h 字段会使用 primary(错误) - 7d 字段没有数据(bug) 修复方案: 改用比较策略: 1. 当两个窗口都存在时:较小的分配给5h,较大的分配给7d 2. 当只有一个窗口时:根据大小(<=360分钟)判断是5h还是7d 3. 确保数据不会丢失,逻辑更健壮 示例: - Primary: 180分钟, Secondary: 300分钟 → 5h 使用 Primary(180分钟), 7d 使用 Secondary(300分钟) ✓ 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix: 修正窗口大小判断逻辑 - 不能用剩余时间判断窗口类型 **严重bug修复:** 之前的 fallback 逻辑错误地使用 reset_after_seconds 来判断窗口大小。 问题示例: - 周限制(7d)剩余 2h → reset_after_seconds = 7200秒 - 5h限制 剩余 4h → reset_after_seconds = 14400秒 - 错误逻辑:7200/60 < 14400/60,把周限制当成5h ❌ 根本问题: - window_minutes = 窗口的总大小(300 or 10080) - reset_after_seconds = 距离重置的剩余时间(变化的) - 不能用剩余时间来判断窗口类型! 修复方案: 1. **只使用 window_minutes** 来判断窗口大小 2. 移除错误的 reset_after_seconds fallback 3. 如果 window_minutes 都不存在,使用传统假设 4. 添加详细注释说明这个陷阱 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix: 修复 lint 问题 - 改进 fallback 逻辑的变量赋值 问题: 第882-883行的简单布尔赋值可能触发 ineffassign 或 staticcheck 警告: use5hFromSecondary = snapshot.SecondaryUsedPercent != nil use7dFromPrimary = snapshot.PrimaryUsedPercent != nil 修复: 改用明确的 if 语句检查任意字段是否存在,更符合代码意图: - 如果 secondary 的任意字段存在,将其视为 5h - 如果 primary 的任意字段存在,将其视为 7d 这样逻辑更清晰,也避免了 lint 警告。 --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]> Co-authored-by: OpenAI Codex <[email protected]>
Additional tests added — commit 47c46e5All gaps identified in the DR-8 deep review are now covered. Two new test files committed on this branch.
|
| Test | What it checks |
|---|---|
TestSanitizeURLError_NilReturnsNil |
nil input → nil output, no panic |
TestSanitizeURLError_NonURLErrorPassthrough |
plain errors.New returned unchanged (same pointer) |
TestSanitizeURLError_RedactsURL |
*url.Error URL replaced with [redacted], Op and inner error preserved, token not in .Error() string |
TestSanitizeURLError_NestedURLErrorsAllRedacted |
two-layer *url.Error chain — both URLs redacted |
Dispatcher.Send additional coverage
| Test | What it checks |
|---|---|
TestDispatcher_Send_Treats429AsTransient |
429 is retried like 5xx, not short-circuited like 4xx |
TestDispatcher_Send_3xxIsRetried |
302 (redirect) is retried, not treated as success |
TestDispatcher_Send_BodyIdenticalAcrossRetries |
all 3 retry bodies are byte-for-byte identical (idempotency) |
TestDispatcher_Send_ContentTypeHeader |
Content-Type: application/json on every POST |
TestDispatcher_Send_ExhaustsRetriesAndReturnsError |
after exhausting retries, returns non-nil error + last status code |
Event JSON serialisation edge cases
| Test | What it checks |
|---|---|
TestEvent_StarsOmittedWhenZero |
stars absent from JSON when 0 (omitempty) |
TestEvent_ImageCountAlwaysPresentEvenWhenZero |
image_count always present even when 0 (no omitempty) |
TestEvent_OmitemptyFieldsAbsentWhenEmpty |
routed_from, family_id, product_line, kid_profile_id all absent when empty |
TestEvent_RequiredFieldsAlwaysPresent |
11 required fields always present at zero values |
SignPayload edge cases
| Test | What it checks |
|---|---|
TestSignPayload_EmptyPayloadAndSecret |
empty inputs produce valid 64-char lowercase hex |
TestSignPayload_DifferentSecretsProduceDifferentSigs |
different secrets → different HMAC output |
Result: 15/15 PASS
service/airbotix_billing_extra_test.go — 15 tests
Guard conditions
| Test | What it checks |
|---|---|
TestDispatchAirbotixBilling_NoopWhenChannelMetaNil |
Guard 1: ChannelMeta == nil → no webhook call, no panic |
Timestamp correctness (PRD §7.3)
| Test | What it checks |
|---|---|
TestDispatchAirbotixBilling_TimestampsAreRFC3339UTC |
started_at and finished_at are valid RFC3339, UTC location, Z suffix |
TestDispatchAirbotixBilling_FinishedAtAfterStartedAt |
finished_at > started_at chronologically |
V0 wire invariants
| Test | What it checks |
|---|---|
TestDispatchAirbotixBilling_ImageCountAlwaysZero |
image_count=0 present in JSON (no omitempty) |
TestDispatchAirbotixBilling_StarsAbsentFromWirePayload |
stars absent from V0 payload |
TestDispatchAirbotixBilling_FamilyIDProductLineAbsent |
family_id and product_line absent (V1 reserved) |
TestDispatchAirbotixBilling_PolicyViolationsNonNilEmptyArray |
policy_violations is [] not null at dispatch layer |
Token guard boundary (Guard 2)
| Test | What it checks |
|---|---|
TestDispatchAirbotixBilling_PromptOnlyTokensDispatches |
prompt=200, completion=0 → webhook fires |
TestDispatchAirbotixBilling_CompletionOnlyTokensDispatches |
prompt=0, completion=150 → webhook fires |
KidProfileID edge case
| Test | What it checks |
|---|---|
TestDispatchAirbotixBilling_KidProfileIDTrimmedPreservesContent |
" kid-abc-456 " → trimmed to "kid-abc-456" in payload |
Wire payload completeness / correctness
| Test | What it checks |
|---|---|
TestDispatchAirbotixBilling_AllRequiredFieldsPresentInWirePayload |
11 required JSON fields all present |
TestDispatchAirbotixBilling_RequestIDMatchesRelayInfo |
request_id == relayInfo.RequestId exactly |
TestDispatchAirbotixBilling_ConcurrentDispatchesDoNotRace |
5 concurrent dispatches, 5 hits, no data race |
TestDispatchAirbotixBilling_404ReceiverDoesNotRetry |
404 = permanent error, exactly 1 HTTP attempt |
TestDispatchAirbotixBilling_AbsentHeaderOmitsKidProfileID |
no X-Tenant-User header → kid_profile_id absent from JSON |
Result: 15/15 PASS
Full suite results
ok github.com/QuantumNous/new-api/internal/billing 2.767s (24 tests)
ok github.com/QuantumNous/new-api/service 3.189s (37 tests)
Combined: 61 tests, 0 failures, 0 skipped
Firesuiry
pushed a commit
to Firesuiry/tako-newapi
that referenced
this pull request
Aug 27, 2026
Expose /v1/search and /api/v1/search, route by virtual models kab_search/grok_search/grok_x_search/groq_search, and charge per call from tool_price_setting. P0 only implements the KAB client; grok/groq return 501 until their upstreams are wired.
salem-2007
added a commit
to salem-2007/new-api
that referenced
this pull request
Sep 10, 2026
salem-2007
added a commit
to salem-2007/new-api
that referenced
this pull request
Sep 10, 2026
salem-2007
added a commit
to salem-2007/new-api
that referenced
this pull request
Sep 10, 2026
fix: add Date header for email
leicanxi
added a commit
to leicanxi/flowbee-api
that referenced
this pull request
Oct 5, 2026
后台每条公告新增「展示方式」:顶部横幅 / 通知中心,缺省为通知中心。 选横幅的会出现在登录后页面最顶端,文字放不下时自动横向无缝滚动; 通知中心与铃铛数字标完全不变。 - 公告本就存在 console_setting 的 JSON 数组里,加 displayMode 字段无需数据库迁移, 缺省值保证老公告行为不变 - 头部高度改由 ResizeObserver 实测后写回 --app-header-height(Header 同时固定为 h-12,以解开「读变量又写变量」的循环依赖),侧栏位置与内容区高度自动跟随下移 - 横幅只在文字真的放不下时才滚动:按实测 scrollWidth / clientWidth 判断,恒定 60px/s,无缝循环沿用项目既有的「两份内容 + translateX(-50%)」写法,并加入 prefers-reduced-motion 降级 - 「不再显示」按公告 key 记在 localStorage;同步扩展 persist 的 partialize, 否则新字段不落盘、刷新即重置 - 顺手修两处既有问题:getPreviewText 不认 Markdown 图片语法( 会原文显示); getAnnouncementKey 有两份重复实现,抽到 lib/announcement.ts 共用 实测(本地预览 + 真实浏览器):头部实测 89px = Header 48 + 横幅 41,内容区 532 = 视口 621 − 89,无横向溢出;213 字长文案触发滚动且时长 47.43s 与 (textWidth + 64) / 60 吻合;短文案不滚动;点关闭后刷新仍不显示。
leicanxi
added a commit
to leicanxi/flowbee-api
that referenced
this pull request
Oct 30, 2026
同步上游 363 个提交(v1.0.0-rc.26 之后约两个月)。 冲突解决原则:自有功能保留、上游架构与多语言化吸收。 关键融合点: - 限流:保留分组级限流/共享限流器/auto 分组门禁,吸收上游 Reserve/Complete 预留与流感知成功判定;补 ErrAutoGroupsRateLimited → 429 映射 - 计费/日志:吸收上游 *LogOther 结构化与 Message 日志,保留 BillingSource 与邀请人首充奖励(积分),RecordLog 调用全部迁移到 NewMessage - 签到:保留福利积分发放,错误/日志改走 i18n 消息(补 11 个后端消息 key 与 9 个前端 NewMessage key,7 语翻译) - 邮件:保留品牌外壳排版,文案接上游多语言(补 6+5 个 i18n key) - 令牌用量:保留扁平 user_quota/user_used_quota 客户端契约 + 容错降级, 吸收上游 AllowUserQuotaQuery 隐私开关与 IP 白名单 - 通知:改用上游 NotifyChannelWatchers,品牌排版随语言渲染 - 访问令牌:采用上游多令牌/scope 体系,移除旧 GenerateAccessToken; 为福利/抽奖/赞助/生图/SSO 等自有路由补齐 scope 规则,SSO 端点仅限会话 - 移除手动划转邀请额度功能(已被自动转入余额取代:模型+控制器+路由+前端) - 前端:保留改造QuantumNous#4/QuantumNous#19/QuantumNous#22/QuantumNous#30/QuantumNous#34/QuantumNous#39/QuantumNous#42/QuantumNous#44,吸收上游组件重构; theme 契约测试适配站点默认值(Anthropic/sans/xl) - 移除与改造QuantumNous#42 布局不兼容的上游概览向导 UI 测试 验证:go build/test 全绿,relaykit 独立构建通过,tsgo 零错误, rsbuild 构建通过,vitest 2461/2461 通过。
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.
修复自建邮箱发送错误: INVALID HEADER Missing required header field: "Date"