Files
sxchnge/backend/notifications/model/model.go

59 lines
1.5 KiB
Go

package model
import (
"git.sendico.io/tech/sxchnge/shared/database/record"
"time"
)
type State string
const (
Queued State = "queued"
Sending State = "sending"
RetryWait State = "retry_wait"
Accepted State = "accepted"
Failed State = "failed"
Expired State = "expired"
Unknown State = "unknown"
)
type Request struct {
Key string
UserID string
TemplateID string
TemplateVersion string
Parameters map[string]string
Locale string
Address string
ExpiresAt time.Time
}
// Email is a rendered immutable snapshot, independent of provider wire formats.
type Email struct {
Address string
Subject string
HTML string
Text string
}
type Notification struct {
storable.Base `bson:",inline"`
Caller string `bson:"caller"`
Key string `bson:"key"`
Fingerprint string `bson:"fingerprint"`
UserID string `bson:"user_id"`
TemplateID string `bson:"template_id"`
TemplateVersion string `bson:"template_version"`
Email Email `bson:"email"`
Driver string `bson:"driver"`
State State `bson:"state"`
Attempts uint32 `bson:"attempts"`
FailureCode string `bson:"failure_code"`
ExpiresAt time.Time `bson:"expires_at"`
NextAttemptAt time.Time `bson:"next_attempt_at"`
LeaseUntil time.Time `bson:"lease_until"`
PurgeAt time.Time `bson:"purge_at"`
}
func (*Notification) Collection() string { return "notifications" }