Documentation
¶
Index ¶
- type Config
- type InviteData
- type LinkData
- type LoginCodeData
- type Sender
- func (s *Sender) Send(ctx context.Context, to, subject, body string) error
- func (s *Sender) SendEmailVerification(ctx context.Context, to, link string) error
- func (s *Sender) SendInvite(ctx context.Context, to, workspaceName, invitationID string) error
- func (s *Sender) SendLoginCode(ctx context.Context, to, code string) error
- func (s *Sender) SendPasswordReset(ctx context.Context, to, link string) error
- type Template
- type Templates
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InviteData ¶ added in v0.8.0
InviteData is the data fed to the Invite templates. InvitationID is part of the default body ("邀请标识:…"), so it travels with the workspace name.
type LinkData ¶ added in v0.8.0
type LinkData struct {
Link string
}
LinkData is the data fed to the PasswordReset and EmailVerification templates.
type LoginCodeData ¶ added in v0.8.0
type LoginCodeData struct {
Code string
}
LoginCodeData is the data fed to the LoginCode templates.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
func NewWithTemplates ¶ added in v0.8.0
NewWithTemplates builds a Sender with a custom copy set. All templates are parsed once here; a parse failure fails construction (fail-fast). Empty Subject/Body fields fall back to the built-in Chinese defaults.
func (*Sender) SendEmailVerification ¶
func (*Sender) SendInvite ¶
func (*Sender) SendLoginCode ¶
type Template ¶ added in v0.8.0
Template is one renderable piece of email copy: a subject plus a plain-text body, both text/template sources. An empty Subject or Body means "use the built-in Chinese default for that piece", so the zero-value Templates reproduces the original hardcoded copy byte for byte.
type Templates ¶ added in v0.8.0
type Templates struct {
LoginCode Template
Invite Template
PasswordReset Template
EmailVerification Template
}
Templates is the injectable copy set for the four templated send methods. Per-locale selection stays product-side: the product compiles the copy it wants and passes it to NewWithTemplates.
Each group is executed with exactly the data its method carries:
- LoginCode: LoginCodeData{Code}
- Invite: InviteData{Workspace, InvitationID}
- PasswordReset: LinkData{Link}
- EmailVerification: LinkData{Link}
Referencing a field outside the group's data (e.g. {{.Link}} in a LoginCode body) fails the send at render time.