notify_email_entry.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dto
  2. import "github.com/Wei-Shaw/sub2api/internal/service"
  3. // NotifyEmailEntry represents a notification email with enable/disable and verification state.
  4. // All emails are user-managed; maximum 3 entries per user.
  5. type NotifyEmailEntry struct {
  6. Email string `json:"email"`
  7. Disabled bool `json:"disabled"`
  8. Verified bool `json:"verified"`
  9. }
  10. // NotifyEmailEntriesFromService converts service entries to DTO entries.
  11. func NotifyEmailEntriesFromService(entries []service.NotifyEmailEntry) []NotifyEmailEntry {
  12. if entries == nil {
  13. return nil
  14. }
  15. result := make([]NotifyEmailEntry, len(entries))
  16. for i, e := range entries {
  17. result[i] = NotifyEmailEntry{
  18. Email: e.Email,
  19. Disabled: e.Disabled,
  20. Verified: e.Verified,
  21. }
  22. }
  23. return result
  24. }
  25. // NotifyEmailEntriesToService converts DTO entries to service entries.
  26. func NotifyEmailEntriesToService(entries []NotifyEmailEntry) []service.NotifyEmailEntry {
  27. if entries == nil {
  28. return nil
  29. }
  30. result := make([]service.NotifyEmailEntry, len(entries))
  31. for i, e := range entries {
  32. result[i] = service.NotifyEmailEntry{
  33. Email: e.Email,
  34. Disabled: e.Disabled,
  35. Verified: e.Verified,
  36. }
  37. }
  38. return result
  39. }