53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package mailer
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
|
|
"clickandjoin.app/emailserver/modules/cache"
|
|
"clickandjoin.app/emailserver/modules/config"
|
|
gocnjhelper "git.ex.umbach.dev/ClickandJoin/go-cnj-helper"
|
|
)
|
|
|
|
func readTemplatesConfig() {
|
|
gocnjhelper.LogDebug("START READING TEMPLATE CONFIG")
|
|
|
|
byteValue, err := os.ReadFile(config.Cfg.Templates.ConfigPath)
|
|
|
|
if err != nil {
|
|
gocnjhelper.LogFatalf("Failed to read config file, err: %s", err)
|
|
}
|
|
|
|
err = json.Unmarshal(byteValue, &cache.Templates)
|
|
|
|
if err != nil {
|
|
gocnjhelper.LogFatalf("Failed to unmarshal templates config, err: %s", err)
|
|
}
|
|
|
|
gocnjhelper.LogDebug("FINISHED READING TEMPLATE CONFIG")
|
|
}
|
|
|
|
func loadTemplateFiles() {
|
|
gocnjhelper.LogDebug("STARTING IMPORTING TEMPLATE FILES")
|
|
|
|
for templateName := range cache.Templates.Templates {
|
|
data, err := os.ReadFile(config.Cfg.Templates.FolderPath + templateName + ".html")
|
|
|
|
if err != nil {
|
|
gocnjhelper.LogFatalf("Failed to read file, err: %s", err)
|
|
}
|
|
/*
|
|
minifiedHtml, err := minify.HTML(string(data))
|
|
|
|
if err != nil {
|
|
gocnjhelper.LogFatalf("Failed to minify html, err: %s", err)
|
|
} */
|
|
|
|
// cache.BodyTemplates[templateName] = []byte(minifiedHtml)
|
|
|
|
cache.BodyTemplates[templateName] = []byte(data)
|
|
}
|
|
|
|
gocnjhelper.LogDebug("FINISHED IMPORTING TEMPLATE FILES")
|
|
}
|