63 lines
2.1 KiB
Go
63 lines
2.1 KiB
Go
package mail
|
|
|
|
import "time"
|
|
|
|
// DisputeNotice is everything the four account-dispute emails say.
|
|
//
|
|
// vantage-admin's dispute package builds it. It never carries the staff note:
|
|
// the customer is told the reason category, not what staff wrote about them.
|
|
type DisputeNotice struct {
|
|
AccountName string
|
|
DisputeID string
|
|
Reason string
|
|
CloudNames []string
|
|
SelfHosted []SelfHostedNotice
|
|
DisputeEmail string
|
|
DisputeBy time.Time
|
|
}
|
|
|
|
// SelfHostedNotice names a self-hosted install and when its licence ends,
|
|
// because that is the one thing a dispute cannot change for it.
|
|
type SelfHostedNotice struct {
|
|
Name string
|
|
LicenceExpires time.Time
|
|
}
|
|
|
|
// InstanceRows lists the affected instances in the shape the layout's "rows"
|
|
// helper takes. A method rather than template logic, because a Go template
|
|
// has no way to build a list of maps.
|
|
func (n DisputeNotice) InstanceRows() []map[string]any {
|
|
rows := make([]map[string]any, 0, len(n.CloudNames)+len(n.SelfHosted))
|
|
for _, name := range n.CloudNames {
|
|
rows = append(rows, map[string]any{"k": "Cloud", "v": name})
|
|
}
|
|
for _, s := range n.SelfHosted {
|
|
rows = append(rows, map[string]any{
|
|
"k": "Self-hosted",
|
|
"v": s.Name + ", licence ends " + s.LicenceExpires.Format("2 January 2006"),
|
|
})
|
|
}
|
|
return rows
|
|
}
|
|
|
|
// SendAccountLocked tells the account a dispute has locked it, that nothing is
|
|
// deleted, and how to dispute. Replies go to the dispute address.
|
|
func (s Sender) SendAccountLocked(to string, n DisputeNotice) error {
|
|
return s.sendTemplate(to, n.DisputeEmail, "accountlocked", n)
|
|
}
|
|
|
|
// SendDisputeReminder repeats the dispute route shortly before the hold ends.
|
|
func (s Sender) SendDisputeReminder(to string, n DisputeNotice) error {
|
|
return s.sendTemplate(to, n.DisputeEmail, "disputereminder", n)
|
|
}
|
|
|
|
// SendAccountTerminated states the outcome of a failed dispute.
|
|
func (s Sender) SendAccountTerminated(to string, n DisputeNotice) error {
|
|
return s.sendTemplate(to, n.DisputeEmail, "accountterminated", n)
|
|
}
|
|
|
|
// SendAccountRestored states the outcome of an upheld dispute.
|
|
func (s Sender) SendAccountRestored(to string, n DisputeNotice) error {
|
|
return s.sendTemplate(to, "", "accountrestored", n)
|
|
}
|