mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-19 19:59:13 +03:00
Merge 9cb4c26ac5
into 2fdafd34ca
This commit is contained in:
commit
d9555bb1ce
4 changed files with 5 additions and 4 deletions
|
@ -3,6 +3,7 @@ package emailer
|
||||||
type Attachment struct {
|
type Attachment struct {
|
||||||
Name string
|
Name string
|
||||||
Data []byte
|
Data []byte
|
||||||
|
MimeType string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Emailer interface {
|
type Emailer interface {
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (o *SendgridApiMail) Send(toName string, to string, subject string, content
|
||||||
var att mail.Attachment
|
var att mail.Attachment
|
||||||
encoded := base64.StdEncoding.EncodeToString(attachments[i].Data)
|
encoded := base64.StdEncoding.EncodeToString(attachments[i].Data)
|
||||||
att.SetContent(encoded)
|
att.SetContent(encoded)
|
||||||
att.SetType("text/plain")
|
att.SetType(attachments[i].MimeType)
|
||||||
att.SetFilename(attachments[i].Name)
|
att.SetFilename(attachments[i].Name)
|
||||||
att.SetDisposition("attachment")
|
att.SetDisposition("attachment")
|
||||||
toAdd = append(toAdd, &att)
|
toAdd = append(toAdd, &att)
|
||||||
|
|
|
@ -91,7 +91,7 @@ func (o *SmtpMail) Send(toName string, to string, subject string, content string
|
||||||
SetBody(mail.TextHTML, content)
|
SetBody(mail.TextHTML, content)
|
||||||
|
|
||||||
for _, v := range attachments {
|
for _, v := range attachments {
|
||||||
email.Attach(&mail.File{Name: v.Name, Data: v.Data})
|
email.Attach(&mail.File{Name: v.Name, Data: v.Data, MimeType: v.MimeType})
|
||||||
}
|
}
|
||||||
|
|
||||||
err = email.Send(smtpClient)
|
err = email.Send(smtpClient)
|
||||||
|
|
|
@ -547,14 +547,14 @@ func EmailClient(db store.IStore, mailer emailer.Emailer, emailSubject, emailCon
|
||||||
globalSettings, _ := db.GetGlobalSettings()
|
globalSettings, _ := db.GetGlobalSettings()
|
||||||
config := util.BuildClientConfig(*clientData.Client, server, globalSettings)
|
config := util.BuildClientConfig(*clientData.Client, server, globalSettings)
|
||||||
|
|
||||||
cfgAtt := emailer.Attachment{Name: "wg0.conf", Data: []byte(config)}
|
cfgAtt := emailer.Attachment{Name: "wg0.conf", Data: []byte(config), MimeType: "text/conf"}
|
||||||
var attachments []emailer.Attachment
|
var attachments []emailer.Attachment
|
||||||
if clientData.Client.PrivateKey != "" {
|
if clientData.Client.PrivateKey != "" {
|
||||||
qrdata, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(clientData.QRCode, "data:image/png;base64,"))
|
qrdata, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(clientData.QRCode, "data:image/png;base64,"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "decoding: " + err.Error()})
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "decoding: " + err.Error()})
|
||||||
}
|
}
|
||||||
qrAtt := emailer.Attachment{Name: "wg.png", Data: qrdata}
|
qrAtt := emailer.Attachment{Name: "wg.png", Data: qrdata, MimeType: "image/png"}
|
||||||
attachments = []emailer.Attachment{cfgAtt, qrAtt}
|
attachments = []emailer.Attachment{cfgAtt, qrAtt}
|
||||||
} else {
|
} else {
|
||||||
attachments = []emailer.Attachment{cfgAtt}
|
attachments = []emailer.Attachment{cfgAtt}
|
||||||
|
|
Loading…
Add table
Reference in a new issue