File tree Expand file tree Collapse file tree 3 files changed +10
-19
lines changed Expand file tree Collapse file tree 3 files changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ package app
33var app * Application
44
55type Application struct {
6- Name string
7- Version string
8- Author string
9- Description string
6+ Name string
7+ Version string
8+ Author string
9+ Description string
10+ MailTemplate string
1011}
1112
1213func new () * Application {
Original file line number Diff line number Diff line change @@ -3,9 +3,6 @@ package update
33import (
44 _ "embed"
55 "fmt"
6- "io"
7- "net/http"
8-
96 "github.com/XotoX1337/tinymail"
107 "github.com/gofiber/fiber/v2"
118 "github.com/gofiber/fiber/v2/log"
@@ -57,17 +54,6 @@ func Mail(c *fiber.Ctx) error {
5754 return err
5855 }
5956
60- resp , err := http .Get (c .BaseURL () + "/html/mail/update.html" )
61- if err != nil {
62- fmt .Println (err )
63- }
64- defer resp .Body .Close ()
65-
66- body , err := io .ReadAll (resp .Body )
67- if err != nil {
68- log .Error (err )
69- }
70-
7157 tplData := map [string ]interface {}{
7258 "Update" : update ,
7359 "Machine" : machine ,
@@ -76,7 +62,7 @@ func Mail(c *fiber.Ctx) error {
7662 "App" : patchouli .GetApp ().Name ,
7763 }
7864
79- msg , err := tinymail .FromTemplateString (tplData , string ( body ) )
65+ msg , err := tinymail .FromTemplateString (tplData , patchouli . GetApp (). MailTemplate )
8066 if err != nil {
8167 log .Error (err )
8268 }
Original file line number Diff line number Diff line change @@ -30,8 +30,12 @@ var views embed.FS
3030//go:embed public
3131var public embed.FS
3232
33+ //go:embed public/html/mail/update.html
34+ var mailTemplate string
35+
3336func main () {
3437 App := patchouli .GetApp ()
38+ App .MailTemplate = mailTemplate
3539 engine := html .NewFileSystem (http .FS (views ), ".html" )
3640 engine .AddFunc ("Name" , func () string {
3741 return App .Name
You can’t perform that action at this time.
0 commit comments