mirror of
https://github.com/dnote/dnote
synced 2026-03-14 22:45:50 +01:00
parent
357a587653
commit
6fbe08e2a9
3 changed files with 8 additions and 8 deletions
|
|
@ -27,8 +27,8 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// makeDigest builds a weekly digest email
|
||||
func makeDigest(user database.User, emailAddr string) (*mailer.Email, error) {
|
||||
// MakeDigest builds a weekly digest email
|
||||
func MakeDigest(user database.User, emailAddr string) (*mailer.Email, error) {
|
||||
log.Printf("Sending for %s", emailAddr)
|
||||
db := database.DBConn
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ func sendDigest() error {
|
|||
continue
|
||||
}
|
||||
|
||||
email, err := makeDigest(user, account.Email.String)
|
||||
email, err := MakeDigest(user, account.Email.String)
|
||||
if err != nil {
|
||||
log.Printf("Error occurred while sending to %s: %s", account.Email.String, err.Error())
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func initTemplate(box *packr.Box, templateName string) (*template.Template, erro
|
|||
|
||||
// InitTemplates initializes templates
|
||||
func InitTemplates() {
|
||||
box := packr.New("emailTemplates", "../mailer/templates/src")
|
||||
box := packr.New("emailTemplates", "./templates/src")
|
||||
|
||||
weeklyDigestTmpl, err := initTemplate(box, EmailTypeWeeklyDigest)
|
||||
if err != nil {
|
||||
|
|
@ -123,7 +123,7 @@ func (e *Email) Send() error {
|
|||
if os.Getenv("GO_ENV") != "PRODUCTION" {
|
||||
fmt.Println("Not sending email because not production")
|
||||
fmt.Println(e.subject, e.to, e.from)
|
||||
// fmt.Println("Body", e.Body)
|
||||
fmt.Println("Body", e.Body)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/job/digest"
|
||||
"github.com/dnote/dnote/pkg/server/job"
|
||||
"github.com/dnote/dnote/pkg/server/mailer"
|
||||
"github.com/joho/godotenv"
|
||||
_ "github.com/lib/pq"
|
||||
|
|
@ -39,7 +39,7 @@ func weeklyDigestHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
email, err := digest.Make(user, "sung@dnote.io")
|
||||
email, err := job.MakeDigest(user, "sung@dnote.io")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
|
@ -79,7 +79,7 @@ func main() {
|
|||
database.InitDB()
|
||||
defer database.CloseDB()
|
||||
|
||||
mailer.InitTemplates("./src")
|
||||
mailer.InitTemplates()
|
||||
|
||||
log.Println("Email template debug server running on http://127.0.0.1:2300")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue