domainView builds the unified DNS-records array. Status derivation: - Inbound records (ownership, inbound_mx) follow `verified`: the domain is either verified (TXT/MX confirmed) or pending. - Sending records reflect their OWN persisted SES axis: the dkim record follows SendingDkimStatus and the mai
(d *identity.Domain)
| 72 | // layer must not import senderidentity (AWS SDK/River), so the MAIL FROM record |
| 73 | // shapes are mirrored locally from mailfrom.Domain + the region. |
| 74 | func (s *Server) domainView(d *identity.Domain) DomainView { |
| 75 | sendingStatus := d.SendingStatus |
| 76 | if sendingStatus == "" { |
| 77 | sendingStatus = "none" // pre-migration-030 rows read as none |
| 78 | } |
| 79 | |
| 80 | inboundStatus := "pending" |
| 81 | if d.Verified { |
| 82 | inboundStatus = "verified" |
| 83 | } |
| 84 | // Per-axis: each sending record reflects its own SES axis, falling back to |
| 85 | // the all-or-nothing sending_status rollup when the axis is unset. |
| 86 | dkimRec := sendingAxisStatus(d.SendingDkimStatus, sendingStatus) |
| 87 | mailFromRec := sendingAxisStatus(d.SendingMailFromStatus, sendingStatus) |
| 88 | mxPriority := 10 |
| 89 | |
| 90 | records := []DNSRecord{ |
| 91 | // ownership — prove control of the domain (also drives the SPF check). |
| 92 | {Type: "TXT", Name: d.Domain, Value: d.VerificationToken, Purpose: "ownership", Status: inboundStatus}, |
| 93 | // inbound_mx — route inbound mail to the e2a relay. |
| 94 | {Type: "MX", Name: d.Domain, Value: s.deps.SMTPDomain, Priority: &mxPriority, Purpose: "inbound_mx", Status: inboundStatus}, |
| 95 | } |
| 96 | |
| 97 | // dkim — surfaced for rows that have a stored per-domain key (migration 014+). |
| 98 | if d.DKIMSelector != "" && d.DKIMPublicKey != "" { |
| 99 | name, value := dkim.DNSRecord(d.DKIMSelector, d.Domain, d.DKIMPublicKey) |
| 100 | records = append(records, DNSRecord{Type: "TXT", Name: name, Value: value, Purpose: "dkim", Status: dkimRec}) |
| 101 | } |
| 102 | |
| 103 | // mail_from_* — the custom MAIL FROM subdomain's MX + SPF, deterministic and |
| 104 | // returned regardless of provisioning state, but only when sending is enabled. |
| 105 | if s.deps.SESRegion != "" { |
| 106 | mf := mailfrom.Domain(d.Domain) |
| 107 | records = append(records, |
| 108 | DNSRecord{Type: "MX", Name: mf, Value: fmt.Sprintf("feedback-smtp.%s.amazonses.com", s.deps.SESRegion), Priority: &mxPriority, Purpose: "mail_from_mx", Status: mailFromRec}, |
| 109 | DNSRecord{Type: "TXT", Name: mf, Value: "v=spf1 include:amazonses.com ~all", Purpose: "mail_from_spf", Status: mailFromRec}, |
| 110 | ) |
| 111 | } |
| 112 | |
| 113 | return DomainView{ |
| 114 | Domain: d.Domain, |
| 115 | Verified: d.Verified, |
| 116 | VerificationToken: d.VerificationToken, |
| 117 | DNSRecords: records, |
| 118 | CreatedAt: d.CreatedAt, |
| 119 | VerifiedAt: d.VerifiedAt, |
| 120 | LastCheckedAt: d.LastCheckedAt, |
| 121 | AgentCount: d.AgentCount, |
| 122 | SendingStatus: sendingStatus, |
| 123 | SendingError: d.SendingError, |
| 124 | SendingLastCheckedAt: d.SendingLastCheckedAt, |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | // sendingAxisStatus derives a sending record's per-record status from its OWN |
| 129 | // persisted SES axis (sending_dkim_status for the dkim record; |