fix(notify): use real-time balance for crossing detection and simplify email logic

- Fix cached balance causing threshold crossing to never trigger:
  read real-time balance from billingCacheService instead of stale
  API key auth snapshot
- Remove email="" placeholder concept; all emails are user-managed
- Only send notifications to verified && non-disabled emails
- Frontend: pre-fill user's email in add input when list is empty
- Remove FilterEnabledEmails/IsPrimaryDisabled helpers (no longer needed)
This commit is contained in:
erio
2026-04-13 01:29:07 +08:00
parent 915b7a4a56
commit 31550a2c6a
6 changed files with 34 additions and 55 deletions

View File

@@ -80,28 +80,3 @@ func MarshalNotifyEmails(entries []NotifyEmailEntry) string {
return string(data)
}
// filterEnabledEmails returns only non-disabled email addresses from entries.
// Empty email placeholders are skipped (caller should resolve them separately).
func FilterEnabledEmails(entries []NotifyEmailEntry) []string {
var result []string
for _, e := range entries {
if e.Disabled {
continue
}
email := strings.TrimSpace(e.Email)
if email != "" {
result = append(result, email)
}
}
return result
}
// isPrimaryDisabled checks if the primary email placeholder (email="") exists and is disabled.
func IsPrimaryDisabled(entries []NotifyEmailEntry) bool {
for _, e := range entries {
if e.Email == "" {
return e.Disabled
}
}
return false // No primary placeholder = not disabled
}