Skip to content

Commit

Permalink
Merge pull request #351 from factly/fix/add-template-storage-url
Browse files Browse the repository at this point in the history
fetch invite template from storage url
  • Loading branch information
shreeharsha-factly authored Mar 8, 2023
2 parents f624ca2 + 9b1e2b8 commit 12fe7ac
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion server/util/email/send-email.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"html/template"
"net/http"

"github.com/factly/x/loggerx"
"github.com/sendgrid/sendgrid-go"
Expand All @@ -25,8 +26,21 @@ func SendmailwithSendGrid(data MailReceiver) error {
to := mail.NewEmail(data.InviteeName, data.InviteeEmail)
var body *template.Template
var err error
body, err = template.ParseFiles("/app/util/email/template.html")
resp, err := http.Get("https://storage.googleapis.com/kavach.factly.in/templates/invite.html")
if err != nil {
loggerx.Error(err)
return err
}
defer resp.Body.Close()

bodyContent, err := ioutil.ReadAll(resp.Body)
if err != nil {
loggerx.Error(err)
return err
}
body, err = template.New("invite").Parse(string(bodyContent))
if err != nil {
loggerx.Error(err)
return err
}
buf := new(bytes.Buffer)
Expand Down

0 comments on commit 12fe7ac

Please sign in to comment.