diff --git a/backend/cmd/server/VERSION b/backend/cmd/server/VERSION index 0ac4459d..bc34277a 100644 --- a/backend/cmd/server/VERSION +++ b/backend/cmd/server/VERSION @@ -1 +1 @@ -0.1.110.47 +0.1.110.48 diff --git a/backend/internal/handler/admin/setting_handler.go b/backend/internal/handler/admin/setting_handler.go index bc6d183c..0c1606ea 100644 --- a/backend/internal/handler/admin/setting_handler.go +++ b/backend/internal/handler/admin/setting_handler.go @@ -5,11 +5,10 @@ import ( "encoding/hex" "encoding/json" "fmt" - "log" + "log/slog" "net/http" "regexp" "strings" - "time" "github.com/Wei-Shaw/sub2api/internal/config" "github.com/Wei-Shaw/sub2api/internal/handler/dto" @@ -1120,11 +1119,11 @@ func (h *SettingHandler) auditSettingsUpdate(c *gin.Context, before *service.Sys subject, _ := middleware.GetAuthSubjectFromContext(c) role, _ := middleware.GetUserRoleFromContext(c) - log.Printf("AUDIT: settings updated at=%s user_id=%d role=%s changed=%v", - time.Now().UTC().Format(time.RFC3339), - subject.UserID, - role, - changed, + slog.Info("settings updated", + "audit", true, + "user_id", subject.UserID, + "role", role, + "changed", changed, ) } @@ -1358,6 +1357,22 @@ func diffSettings(before *service.SystemSettings, after *service.SystemSettings, if before.EnableCCHSigning != after.EnableCCHSigning { changed = append(changed, "enable_cch_signing") } + // Balance & quota notification + if before.BalanceLowNotifyEnabled != after.BalanceLowNotifyEnabled { + changed = append(changed, "balance_low_notify_enabled") + } + if before.BalanceLowNotifyThreshold != after.BalanceLowNotifyThreshold { + changed = append(changed, "balance_low_notify_threshold") + } + if before.BalanceLowNotifyRechargeURL != after.BalanceLowNotifyRechargeURL { + changed = append(changed, "balance_low_notify_recharge_url") + } + if before.AccountQuotaNotifyEnabled != after.AccountQuotaNotifyEnabled { + changed = append(changed, "account_quota_notify_enabled") + } + if !equalNotifyEmailEntries(before.AccountQuotaNotifyEmails, after.AccountQuotaNotifyEmails) { + changed = append(changed, "account_quota_notify_emails") + } return changed } @@ -1414,6 +1429,18 @@ func equalIntSlice(a, b []int) bool { return true } +func equalNotifyEmailEntries(a, b []service.NotifyEmailEntry) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i].Email != b[i].Email || a[i].Verified != b[i].Verified || a[i].Disabled != b[i].Disabled { + return false + } + } + return true +} + // TestSMTPRequest 测试SMTP连接请求 type TestSMTPRequest struct { SMTPHost string `json:"smtp_host"` diff --git a/frontend/src/components/account/QuotaNotifyToggle.vue b/frontend/src/components/account/QuotaNotifyToggle.vue index 0548f661..954d0929 100644 --- a/frontend/src/components/account/QuotaNotifyToggle.vue +++ b/frontend/src/components/account/QuotaNotifyToggle.vue @@ -1,4 +1,6 @@