@@ -142,6 +142,7 @@ func (h *SettingHandler) GetSettings(c *gin.Context) {
142142 TurnstileEnabled : settings .TurnstileEnabled ,
143143 TurnstileSiteKey : settings .TurnstileSiteKey ,
144144 TurnstileSecretKeyConfigured : settings .TurnstileSecretKeyConfigured ,
145+ APIKeyACLTrustForwardedIP : settings .APIKeyACLTrustForwardedIP ,
145146 LinuxDoConnectEnabled : settings .LinuxDoConnectEnabled ,
146147 LinuxDoConnectClientID : settings .LinuxDoConnectClientID ,
147148 LinuxDoConnectClientSecretConfigured : settings .LinuxDoConnectClientSecretConfigured ,
@@ -264,6 +265,7 @@ func (h *SettingHandler) GetSettings(c *gin.Context) {
264265 BalanceLowNotifyEnabled : settings .BalanceLowNotifyEnabled ,
265266 BalanceLowNotifyThreshold : settings .BalanceLowNotifyThreshold ,
266267 BalanceLowNotifyRechargeURL : settings .BalanceLowNotifyRechargeURL ,
268+ SubscriptionExpiryNotifyEnabled : settings .SubscriptionExpiryNotifyEnabled ,
267269 AccountQuotaNotifyEnabled : settings .AccountQuotaNotifyEnabled ,
268270 AccountQuotaNotifyEmails : dto .NotifyEmailEntriesFromService (settings .AccountQuotaNotifyEmails ),
269271 PaymentEnabled : paymentCfg .Enabled ,
@@ -399,6 +401,9 @@ type UpdateSettingsRequest struct {
399401 TurnstileSiteKey string `json:"turnstile_site_key"`
400402 TurnstileSecretKey string `json:"turnstile_secret_key"`
401403
404+ // API Key IP 访问控制设置
405+ APIKeyACLTrustForwardedIP * bool `json:"api_key_acl_trust_forwarded_ip"`
406+
402407 // LinuxDo Connect OAuth 登录
403408 LinuxDoConnectEnabled bool `json:"linuxdo_connect_enabled"`
404409 LinuxDoConnectClientID string `json:"linuxdo_connect_client_id"`
@@ -582,12 +587,13 @@ type UpdateSettingsRequest struct {
582587 // OpenAI account scheduling
583588 OpenAIAdvancedSchedulerEnabled * bool `json:"openai_advanced_scheduler_enabled"`
584589
585- // Balance low notification
586- BalanceLowNotifyEnabled * bool `json:"balance_low_notify_enabled"`
587- BalanceLowNotifyThreshold * float64 `json:"balance_low_notify_threshold"`
588- BalanceLowNotifyRechargeURL * string `json:"balance_low_notify_recharge_url"`
589- AccountQuotaNotifyEnabled * bool `json:"account_quota_notify_enabled"`
590- AccountQuotaNotifyEmails * []dto.NotifyEmailEntry `json:"account_quota_notify_emails"`
590+ // 余额不足提醒
591+ BalanceLowNotifyEnabled * bool `json:"balance_low_notify_enabled"`
592+ BalanceLowNotifyThreshold * float64 `json:"balance_low_notify_threshold"`
593+ BalanceLowNotifyRechargeURL * string `json:"balance_low_notify_recharge_url"`
594+ SubscriptionExpiryNotifyEnabled * bool `json:"subscription_expiry_notify_enabled"`
595+ AccountQuotaNotifyEnabled * bool `json:"account_quota_notify_enabled"`
596+ AccountQuotaNotifyEmails * []dto.NotifyEmailEntry `json:"account_quota_notify_emails"`
591597
592598 // Payment configuration (integrated into settings, full replace)
593599 PaymentEnabled * bool `json:"payment_enabled"`
@@ -1432,28 +1438,34 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
14321438 }
14331439
14341440 settings := & service.SystemSettings {
1435- RegistrationEnabled : req .RegistrationEnabled ,
1436- EmailVerifyEnabled : req .EmailVerifyEnabled ,
1437- RegistrationEmailSuffixWhitelist : req .RegistrationEmailSuffixWhitelist ,
1438- PromoCodeEnabled : req .PromoCodeEnabled ,
1439- PasswordResetEnabled : req .PasswordResetEnabled ,
1440- FrontendURL : req .FrontendURL ,
1441- InvitationCodeEnabled : req .InvitationCodeEnabled ,
1442- TotpEnabled : req .TotpEnabled ,
1443- LoginAgreementEnabled : req .LoginAgreementEnabled ,
1444- LoginAgreementMode : loginAgreementMode ,
1445- LoginAgreementUpdatedAt : loginAgreementUpdatedAt ,
1446- LoginAgreementDocuments : loginAgreementDocuments ,
1447- SMTPHost : req .SMTPHost ,
1448- SMTPPort : req .SMTPPort ,
1449- SMTPUsername : req .SMTPUsername ,
1450- SMTPPassword : req .SMTPPassword ,
1451- SMTPFrom : req .SMTPFrom ,
1452- SMTPFromName : req .SMTPFromName ,
1453- SMTPUseTLS : req .SMTPUseTLS ,
1454- TurnstileEnabled : req .TurnstileEnabled ,
1455- TurnstileSiteKey : req .TurnstileSiteKey ,
1456- TurnstileSecretKey : req .TurnstileSecretKey ,
1441+ RegistrationEnabled : req .RegistrationEnabled ,
1442+ EmailVerifyEnabled : req .EmailVerifyEnabled ,
1443+ RegistrationEmailSuffixWhitelist : req .RegistrationEmailSuffixWhitelist ,
1444+ PromoCodeEnabled : req .PromoCodeEnabled ,
1445+ PasswordResetEnabled : req .PasswordResetEnabled ,
1446+ FrontendURL : req .FrontendURL ,
1447+ InvitationCodeEnabled : req .InvitationCodeEnabled ,
1448+ TotpEnabled : req .TotpEnabled ,
1449+ LoginAgreementEnabled : req .LoginAgreementEnabled ,
1450+ LoginAgreementMode : loginAgreementMode ,
1451+ LoginAgreementUpdatedAt : loginAgreementUpdatedAt ,
1452+ LoginAgreementDocuments : loginAgreementDocuments ,
1453+ SMTPHost : req .SMTPHost ,
1454+ SMTPPort : req .SMTPPort ,
1455+ SMTPUsername : req .SMTPUsername ,
1456+ SMTPPassword : req .SMTPPassword ,
1457+ SMTPFrom : req .SMTPFrom ,
1458+ SMTPFromName : req .SMTPFromName ,
1459+ SMTPUseTLS : req .SMTPUseTLS ,
1460+ TurnstileEnabled : req .TurnstileEnabled ,
1461+ TurnstileSiteKey : req .TurnstileSiteKey ,
1462+ TurnstileSecretKey : req .TurnstileSecretKey ,
1463+ APIKeyACLTrustForwardedIP : func () bool {
1464+ if req .APIKeyACLTrustForwardedIP != nil {
1465+ return * req .APIKeyACLTrustForwardedIP
1466+ }
1467+ return previousSettings .APIKeyACLTrustForwardedIP
1468+ }(),
14571469 LinuxDoConnectEnabled : req .LinuxDoConnectEnabled ,
14581470 LinuxDoConnectClientID : req .LinuxDoConnectClientID ,
14591471 LinuxDoConnectClientSecret : req .LinuxDoConnectClientSecret ,
@@ -1669,6 +1681,12 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
16691681 }
16701682 return previousSettings .BalanceLowNotifyRechargeURL
16711683 }(),
1684+ SubscriptionExpiryNotifyEnabled : func () bool {
1685+ if req .SubscriptionExpiryNotifyEnabled != nil {
1686+ return * req .SubscriptionExpiryNotifyEnabled
1687+ }
1688+ return previousSettings .SubscriptionExpiryNotifyEnabled
1689+ }(),
16721690 AccountQuotaNotifyEnabled : func () bool {
16731691 if req .AccountQuotaNotifyEnabled != nil {
16741692 return * req .AccountQuotaNotifyEnabled
@@ -1869,6 +1887,7 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
18691887 TurnstileEnabled : updatedSettings .TurnstileEnabled ,
18701888 TurnstileSiteKey : updatedSettings .TurnstileSiteKey ,
18711889 TurnstileSecretKeyConfigured : updatedSettings .TurnstileSecretKeyConfigured ,
1890+ APIKeyACLTrustForwardedIP : updatedSettings .APIKeyACLTrustForwardedIP ,
18721891 LinuxDoConnectEnabled : updatedSettings .LinuxDoConnectEnabled ,
18731892 LinuxDoConnectClientID : updatedSettings .LinuxDoConnectClientID ,
18741893 LinuxDoConnectClientSecretConfigured : updatedSettings .LinuxDoConnectClientSecretConfigured ,
@@ -1989,6 +2008,7 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
19892008 BalanceLowNotifyEnabled : updatedSettings .BalanceLowNotifyEnabled ,
19902009 BalanceLowNotifyThreshold : updatedSettings .BalanceLowNotifyThreshold ,
19912010 BalanceLowNotifyRechargeURL : updatedSettings .BalanceLowNotifyRechargeURL ,
2011+ SubscriptionExpiryNotifyEnabled : updatedSettings .SubscriptionExpiryNotifyEnabled ,
19922012 AccountQuotaNotifyEnabled : updatedSettings .AccountQuotaNotifyEnabled ,
19932013 AccountQuotaNotifyEmails : dto .NotifyEmailEntriesFromService (updatedSettings .AccountQuotaNotifyEmails ),
19942014 PaymentEnabled : updatedPaymentCfg .Enabled ,
@@ -2145,6 +2165,9 @@ func diffSettings(before *service.SystemSettings, after *service.SystemSettings,
21452165 if req .TurnstileSecretKey != "" {
21462166 changed = append (changed , "turnstile_secret_key" )
21472167 }
2168+ if before .APIKeyACLTrustForwardedIP != after .APIKeyACLTrustForwardedIP {
2169+ changed = append (changed , "api_key_acl_trust_forwarded_ip" )
2170+ }
21482171 if before .LinuxDoConnectEnabled != after .LinuxDoConnectEnabled {
21492172 changed = append (changed , "linuxdo_connect_enabled" )
21502173 }
@@ -2454,7 +2477,7 @@ func diffSettings(before *service.SystemSettings, after *service.SystemSettings,
24542477 if before .OpenAIAdvancedSchedulerEnabled != after .OpenAIAdvancedSchedulerEnabled {
24552478 changed = append (changed , "openai_advanced_scheduler_enabled" )
24562479 }
2457- // Balance & quota notification
2480+ // 余额、订阅到期与账号限额通知
24582481 if before .BalanceLowNotifyEnabled != after .BalanceLowNotifyEnabled {
24592482 changed = append (changed , "balance_low_notify_enabled" )
24602483 }
@@ -2464,6 +2487,9 @@ func diffSettings(before *service.SystemSettings, after *service.SystemSettings,
24642487 if before .BalanceLowNotifyRechargeURL != after .BalanceLowNotifyRechargeURL {
24652488 changed = append (changed , "balance_low_notify_recharge_url" )
24662489 }
2490+ if before .SubscriptionExpiryNotifyEnabled != after .SubscriptionExpiryNotifyEnabled {
2491+ changed = append (changed , "subscription_expiry_notify_enabled" )
2492+ }
24672493 if before .AccountQuotaNotifyEnabled != after .AccountQuotaNotifyEnabled {
24682494 changed = append (changed , "account_quota_notify_enabled" )
24692495 }
@@ -3472,6 +3498,8 @@ func emailTemplateEventOptionsToDTO(events []service.NotificationEmailEventInfo)
34723498 Value : event .Event ,
34733499 Label : event .Label ,
34743500 Description : event .Description ,
3501+ Category : event .Category ,
3502+ Optional : event .Optional ,
34753503 })
34763504 }
34773505 return items
0 commit comments