feat(notify): add global toggles, percentage threshold, and visibility control
- Add global toggle for account quota notification in admin settings - Add percentage-based threshold type for per-account quota alerts - Hide balance notify card on user profile when global toggle is off - Expose balance_low_notify_enabled and account_quota_notify_enabled in PublicSettings - Add threshold type (fixed/percentage) to QuotaNotifyToggle with $ / % switcher
This commit is contained in:
@@ -1432,6 +1432,14 @@ func (a *Account) getExtraString(key string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// getExtraStringDefault 从 Extra 中读取指定 key 的字符串值,不存在时返回 defaultVal
|
||||
func (a *Account) getExtraStringDefault(key, defaultVal string) string {
|
||||
if v := a.getExtraString(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return defaultVal
|
||||
}
|
||||
|
||||
// getExtraInt 从 Extra 中读取指定 key 的 int 值
|
||||
func (a *Account) getExtraInt(key string) int {
|
||||
if a.Extra == nil {
|
||||
@@ -1498,6 +1506,10 @@ func (a *Account) GetQuotaNotifyDailyThreshold() float64 {
|
||||
return a.getExtraFloat64("quota_notify_daily_threshold")
|
||||
}
|
||||
|
||||
func (a *Account) GetQuotaNotifyDailyThresholdType() string {
|
||||
return a.getExtraStringDefault("quota_notify_daily_threshold_type", "fixed")
|
||||
}
|
||||
|
||||
func (a *Account) GetQuotaNotifyWeeklyEnabled() bool {
|
||||
return a.getExtraBool("quota_notify_weekly_enabled")
|
||||
}
|
||||
@@ -1506,6 +1518,10 @@ func (a *Account) GetQuotaNotifyWeeklyThreshold() float64 {
|
||||
return a.getExtraFloat64("quota_notify_weekly_threshold")
|
||||
}
|
||||
|
||||
func (a *Account) GetQuotaNotifyWeeklyThresholdType() string {
|
||||
return a.getExtraStringDefault("quota_notify_weekly_threshold_type", "fixed")
|
||||
}
|
||||
|
||||
func (a *Account) GetQuotaNotifyTotalEnabled() bool {
|
||||
return a.getExtraBool("quota_notify_total_enabled")
|
||||
}
|
||||
@@ -1514,6 +1530,10 @@ func (a *Account) GetQuotaNotifyTotalThreshold() float64 {
|
||||
return a.getExtraFloat64("quota_notify_total_threshold")
|
||||
}
|
||||
|
||||
func (a *Account) GetQuotaNotifyTotalThresholdType() string {
|
||||
return a.getExtraStringDefault("quota_notify_total_threshold_type", "fixed")
|
||||
}
|
||||
|
||||
// nextFixedDailyReset 计算在 after 之后的下一个每日固定重置时间点
|
||||
func nextFixedDailyReset(hour int, tz *time.Location, after time.Time) time.Time {
|
||||
t := after.In(tz)
|
||||
|
||||
Reference in New Issue
Block a user