mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 01:33:10 -06:00
Embed default templates
This commit is contained in:
parent
6aa4152e6e
commit
a35ad92ac0
|
|
@ -103,11 +103,17 @@ func NewMailer(c *config.UserAPI) (Mailer, error) {
|
||||||
}
|
}
|
||||||
sessionTypes := api.ThreepidSessionTypes()
|
sessionTypes := api.ThreepidSessionTypes()
|
||||||
templates := make([]*template.Template, len(sessionTypes))
|
templates := make([]*template.Template, len(sessionTypes))
|
||||||
for _, t := range sessionTypes {
|
for i, t := range sessionTypes {
|
||||||
name := t.Name()
|
name := t.Name()
|
||||||
templateRaw, err := ioutil.ReadFile(fmt.Sprintf("%s/%s.eml", c.Email.TemplatesPath, name))
|
var templateRaw []byte
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, err
|
if c.Email.TemplatesPath != "" {
|
||||||
|
templateRaw, err = ioutil.ReadFile(fmt.Sprintf("%s/%s.eml", c.Email.TemplatesPath, name))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
templateRaw = []byte(defaults[i])
|
||||||
}
|
}
|
||||||
template, err := template.New(name).Parse(string(templateRaw))
|
template, err := template.New(name).Parse(string(templateRaw))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -159,3 +165,50 @@ func validateLine(line string) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaults = []string{
|
||||||
|
`Date: {{.Date}}
|
||||||
|
From: noreply@example.com
|
||||||
|
To: {{.To}}
|
||||||
|
Message-ID: <{{.MessageId}}>
|
||||||
|
Subject: Confirm your email address for Matrix
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Disposition: inline
|
||||||
|
|
||||||
|
We have received request to reset password for you Matrix account. Please click following link to confirm your email:
|
||||||
|
{{.Link}}
|
||||||
|
Alternatively pass following token to your Matrix client:
|
||||||
|
{{.Token}}
|
||||||
|
`,
|
||||||
|
`Date: {{.Date}}
|
||||||
|
From: noreply@example.com
|
||||||
|
To: {{.To}}
|
||||||
|
Message-ID: <{{.MessageId}}>
|
||||||
|
Subject: Confirm your email address for Matrix
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Disposition: inline
|
||||||
|
|
||||||
|
We have received request to add this email to your Matrix account. Please click following link to confirm your email:
|
||||||
|
{{.Link}}
|
||||||
|
Alternatively pass following token to your Matrix client:
|
||||||
|
{{.Token}}
|
||||||
|
`,
|
||||||
|
`Date: {{.Date}}
|
||||||
|
From: noreply@example.com
|
||||||
|
To: {{.To}}
|
||||||
|
Message-ID: <{{.MessageId}}>
|
||||||
|
Subject: Confirm your email address for Matrix
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Disposition: inline
|
||||||
|
|
||||||
|
We have received request to register account in Matrix server using this email. Please click following link to finish registration:
|
||||||
|
{{.Link}}
|
||||||
|
Alternatively pass following token to your Matrix client:
|
||||||
|
{{.Token}}
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@ func TestSendVerification(t *testing.T) {
|
||||||
err := dut.Send(
|
err := dut.Send(
|
||||||
&Mail{
|
&Mail{
|
||||||
To: "kevil11378@186site.com",
|
To: "kevil11378@186site.com",
|
||||||
Link: "my",
|
Link: "http://my",
|
||||||
Token: "foo",
|
Token: "foo",
|
||||||
Extra: []string{
|
Extra: []string{
|
||||||
"bar",
|
"bar",
|
||||||
},
|
},
|
||||||
}, api.Verification)
|
}, api.Register)
|
||||||
is.NoErr(err)
|
is.NoErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue