From 2433104689b398b6c0cf7ec6bcab30d6e79a523f Mon Sep 17 00:00:00 2001 From: drew Date: Mon, 28 Jul 2025 11:41:20 +0400 Subject: [PATCH] feat: added name to the config --- config/config.go | 1 + sender/sender.go | 2 +- tui/login.go | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index beddd99e7f4ce3293029aa96400ecba370e0b710..b6dfd95467ea677eed7015f83e395380f4333992 100644 --- a/config/config.go +++ b/config/config.go @@ -11,6 +11,7 @@ type Config struct { ServiceProvider string `json:"service_provider"` Email string `json:"email"` Password string `json:"password"` + Name string `json:"name"` } // configDir returns the path to the configuration directory. diff --git a/sender/sender.go b/sender/sender.go index 2b64bb1acb5ed189ff83c78ef8c6635baa8e5db3..0865eb855316c8dafcc8e384ed00e87ca1c274c2 100644 --- a/sender/sender.go +++ b/sender/sender.go @@ -23,7 +23,7 @@ func SendEmail(cfg *config.Config, to []string, subject, body string) error { } auth := smtp.PlainAuth("", cfg.Email, cfg.Password, smtpHost) - msg := fmt.Sprintf("From: %s <%s>\r\n", "Some Name", cfg.Email) + + msg := fmt.Sprintf("From: %s <%s>\r\n", cfg.Name, cfg.Email) + fmt.Sprintf("To: %s\r\n", to[0]) + fmt.Sprintf("Subject: %s\r\n", subject) + "\r\n" + // An empty line is required between headers and the body. diff --git a/tui/login.go b/tui/login.go index 786e5d00f1d27334956713d735dc38d223bdc63d..cca62b1cdce7ae0647de4d3b99f0408f40791f73 100644 --- a/tui/login.go +++ b/tui/login.go @@ -20,7 +20,7 @@ type loginModel struct { func initialLoginModel() loginModel { m := loginModel{ - inputs: make([]textinput.Model, 3), + inputs: make([]textinput.Model, 4), } var t textinput.Model @@ -45,6 +45,10 @@ func initialLoginModel() loginModel { t.EchoMode = textinput.EchoPassword t.EchoCharacter = '•' t.CharLimit = 64 + case 3: + t.Placeholder = "Name" + t.Prompt = " " + t.CharLimit = 64 } m.inputs[i] = t } @@ -67,6 +71,7 @@ func (m loginModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ServiceProvider: m.inputs[0].Value(), Email: m.inputs[1].Value(), Password: m.inputs[2].Value(), + Name: m.inputs[3].Value(), } if err := config.SaveConfig(m.config); err != nil { m.err = err