Repository navigation
feat(notify): add user-configurable notification cooldown (+ tests & e2e) - #7
Merged
Merged
Conversation
Allow users to set a custom cooldown period (in minutes) between quota warning notifications, reducing email spam for active users. When set to 0, the server default (2 per 10 minutes) applies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the notify_cooldown_minutes field to the classic theme's notification settings, matching the default theme implementation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The lockfile lives at web/bun.lock (workspace root), but CI was running bun install from web/default/ and web/classic/ subdirectories, causing --frozen-lockfile to hang looking for a non-existent lockfile. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The bun.lock was generated with the internal Alibaba npm mirror (registry.anpm.alibaba-inc.com), which is unreachable from GitHub Actions runners. Switch to the public npm registry and drop --frozen-lockfile since the registry URLs differ from the lockfile. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover CheckNotificationLimit's user-configurable cooldown branches: within-window suppression, per-user and per-notifyType bucket scoping, re-allow after the window elapses, and the cooldownMinutes=0 fallback to the server-default cap. The default-path test initializes constant.NotifyLimitCount / NotificationLimitDurationMinute in-fixture since those are only populated at server startup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add real-browser e2e coverage for the notify_cooldown_minutes field in both themes: default (/sign-in -> /profile -> Settings & Preferences tab -> #cooldown) and classic (/login -> /console/personal -> Semi AutoComplete). Both verify render + set/save/persist round-trip against PUT/GET /api/user/self. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolve .github/workflows/frontend-tests.yml by taking dev's npm-based CI (setup-node + resolve-catalogs + npm install + npx vitest run), consistent with the setup-node step git auto-merged in. Trigger paths become the union (workflow file + web/bun.lock + web/package.json + theme dirs), which equals dev's version. Cooldown feature + tests + e2e unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 of 5 tasks
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.
Important
📝 变更描述 / Description
为每个用户增加可配置的通知冷却时间
notify_cooldown_minutes,避免活跃用户在额度低于预警阈值时被频繁邮件轰炸。生效机制(已核对代码):
service/notify-limit.go:CheckNotificationLimit新增cooldownMinutes参数;cooldownMinutes > 0时走新增的checkRedisCooldown/checkMemoryCooldown分支——key 为{userId}:{category}:cooldown,窗口内仅放行 1 条。service/user_notify.go:NotifyUser传入userSetting.NotifyCooldownMinutes;冷却检查发生在渠道分派(switch notifyType)之前,且 key 不含渠道字段——因此对所有通知渠道(email / webhook / bark / gotify / feishu / qqbot)一致生效,换渠道不会绕过冷却;按"通知类别"(quota_exceed/channel_update等)独立分桶,类别之间互不抑制。cooldownMinutes = 0:回退原服务端默认(NOTIFY_LIMIT_COUNT=2/NOTIFICATION_LIMIT_DURATION_MINUTE=10,同样渠道无关)。UpdateUserSetting校验0 ≤ 值 ≤ 43200。notification-tab.tsx的#cooldown数字输入)+ classic(NotificationSettings.jsx的 Semi AutoCompletenotifyCooldownMinutes)。测试覆盖:
service/notify-limit_test.go(5 项:窗口内抑制 / per-user / per-notifyType / 窗口过期再放行 / 0 回退服务端默认)。web/e2e-cooldown.mjs(default)+web/e2e-classic-cooldown.mjs(classic),覆盖 setup → 登录 → 设置页 cooldown 字段渲染 → 填值 → 保存 → 重载持久化 → API 校验。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
docs/decisions/2026-07-14-notify-cooldown-user-configurable.md✅ 提交前检查项 / Checklist
investigate/quota-warning-email-frequency。📸 运行证明 / Proof of Work
后端
go build ./...✅go test ./service/... ./controller/...✅(全 package pass)go test ./service -run TestCheckNotificationLimit→ 5/5 PASSgo vet ./service/clean前端(
bun installfromweb/,vitest run)web/default→ 130 files / 2660 tests ✅web/classic→ 28 files / 592 tests ✅Playwright 真实浏览器 e2e(chromium headless,against sqlite 后端 + 真实 dist)
setting={"notify_type":"email",...,"notify_cooldown_minutes":30}/console/personal的 Semi AutoComplete → 填 60 → 保存 → reload 仍 60;API ={"...","notify_cooldown_minutes":60}Diff vs dev: 19 files, +577 / -10。