dotenv, parsing fix email, moved dump tracnsport to new file gz, removed unwanted var jwt, added in HS256 sign/parse

ptr, ref and deref funcs response, use fmt.Fprint(f) validate, few new funcs
This commit is contained in:
2025-10-03 00:12:00 +05:30
parent 74e56f55d6
commit 6f9fb2d8ec
14 changed files with 262 additions and 65 deletions

View File

@@ -5,36 +5,6 @@
package email
import (
"os"
"path/filepath"
"time"
"code.patial.tech/go/appcore/open"
)
type Transport interface {
Send(*Message) error
}
// DumpToTemp transport is for development environment to ensure emails are renderd as HTML ok
//
// once dump operation is done it will try to open the html with default app for html
type DumpToTemp struct{}
func (DumpToTemp) Send(msg *Message) error {
// validate msg first
if err := msg.Validate(); err != nil {
return err
}
dir := os.TempDir()
id := time.Now().Format("20060102T150405999")
file := filepath.Join(dir, id+".html")
if err := os.WriteFile(file, []byte(msg.HtmlBody), 0440); err != nil {
return err
}
return open.WithDefaultApp(file)
}

30
email/transport_dump.go Normal file
View File

@@ -0,0 +1,30 @@
package email
import (
"os"
"path/filepath"
"code.patial.tech/go/appcore/open"
"github.com/google/uuid"
)
// DumpToTemp transport is for development environment to ensure emails are renderd as HTML ok
// once dump operation is done it will try to open the html with default app for html
type DumpToTemp struct{}
func (DumpToTemp) Send(msg *Message) error {
// validate msg first
if err := msg.Validate(); err != nil {
return err
}
dir := os.TempDir()
id, _ := uuid.NewV7()
file := filepath.Join(dir, id.String()+".html")
if err := os.WriteFile(file, []byte(msg.HtmlBody), 0440); err != nil {
return err
}
return open.WithDefaultApp(file)
}