- Change balance_notify_extra_emails and account_quota_notify_emails
from []string to []NotifyEmailEntry{email, disabled, verified}
- Add per-email enable/disable toggle for both user and admin notifications
- Add PUT /user/notify-email/toggle API endpoint
- Fix critical bug: API key auth cache snapshot missing balance notify
fields (Email, Username, BalanceNotifyEnabled, etc.), causing
notifications to never fire on cached request paths
- Bump cache snapshot version 3→4 to invalidate stale entries
- Add SQL migration 104 to convert old format data
- Backward compatible: parseNotifyEmails auto-detects old/new format
- User balance notify: max 3 emails (primary + 2 extra)
- Admin quota notify: unlimited emails, each with toggle
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package dto
|
|
|
|
import "github.com/Wei-Shaw/sub2api/internal/service"
|
|
|
|
// NotifyEmailEntry represents a notification email with enable/disable and verification state.
|
|
// Email="" is a placeholder for the "primary email" (user's registration email or first admin email).
|
|
type NotifyEmailEntry struct {
|
|
Email string `json:"email"`
|
|
Disabled bool `json:"disabled"`
|
|
Verified bool `json:"verified"`
|
|
}
|
|
|
|
// NotifyEmailEntriesFromService converts service entries to DTO entries.
|
|
func NotifyEmailEntriesFromService(entries []service.NotifyEmailEntry) []NotifyEmailEntry {
|
|
if entries == nil {
|
|
return nil
|
|
}
|
|
result := make([]NotifyEmailEntry, len(entries))
|
|
for i, e := range entries {
|
|
result[i] = NotifyEmailEntry{
|
|
Email: e.Email,
|
|
Disabled: e.Disabled,
|
|
Verified: e.Verified,
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// NotifyEmailEntriesToService converts DTO entries to service entries.
|
|
func NotifyEmailEntriesToService(entries []NotifyEmailEntry) []service.NotifyEmailEntry {
|
|
if entries == nil {
|
|
return nil
|
|
}
|
|
result := make([]service.NotifyEmailEntry, len(entries))
|
|
for i, e := range entries {
|
|
result[i] = service.NotifyEmailEntry{
|
|
Email: e.Email,
|
|
Disabled: e.Disabled,
|
|
Verified: e.Verified,
|
|
}
|
|
}
|
|
return result
|
|
}
|