Skip to content

Commit 92d953f

Browse files
committed
extend input parameters of SendEmail
added flexibility to add more info when sending emails
1 parent 0eb7946 commit 92d953f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

service/common.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/hex"
66
"errors"
7+
"fmt"
78
"strconv"
89
"strings"
910
"time"
@@ -85,7 +86,7 @@ func DelMem2FA(authID uint64) {
8586
// {false, nil} => email delivery not required/service not configured
8687
//
8788
// {false, error} => email delivery failed
88-
func SendEmail(email string, emailType int) (bool, error) {
89+
func SendEmail(email string, emailType int, opts ...string) (bool, error) {
8990
// send email if required by the application
9091
appConfig := config.GetConfig()
9192

@@ -187,6 +188,14 @@ func SendEmail(email string, emailType int) (bool, error) {
187188
htmlModel["secret_code"] = code
188189
htmlModel["email_validity_period"] = timestring.HourMinuteSecond(keyTTL)
189190

191+
optsLen := len(opts)
192+
if optsLen > 0 {
193+
for i := 0; i < optsLen; i++ {
194+
key := fmt.Sprintf("additional_info_%d", i)
195+
htmlModel[key] = opts[i]
196+
}
197+
}
198+
190199
params := PostmarkParams{}
191200
params.ServerToken = appConfig.EmailConf.APIToken
192201

0 commit comments

Comments
 (0)