From f31adc2bb2c99be30b3b2fe2eb4a4994b68138e9 Mon Sep 17 00:00:00 2001
From: slaventius <slaventius@mail.ru>
Date: Thu, 9 Feb 2023 12:24:15 +0300
Subject: [PATCH] *

---
 .vscode/launch.json       |  4 ++--
 internal/authPostman.go   | 36 +++++++++++++++++++-----------------
 internal/config/config.go | 26 +++++++++++++-------------
 3 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/.vscode/launch.json b/.vscode/launch.json
index 2821ce0..c2703cd 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -14,8 +14,8 @@
         "SMTP_HOST":"smtp.mail.ru",
         // "SMTP_PORT":"465",
         "SMTP_PORT":"587",
-        "SMTP_SENDER":"test3kbot@mail.ru",
-        "SMTP_PASSWORD":"hwNhMgPyBzMjwCj3hFPp",
+        "SMTP_SENDER":"test3kbotan@mail.ru",
+        "SMTP_PASSWORD":"vSJYfUbpamiUFkKx1DJA",
         "KAFKA_PORT":"9092",
         "KAFKA_HOST":"37.143.12.169",
         "CHAT_ID":"150697696",
diff --git a/internal/authPostman.go b/internal/authPostman.go
index 8a12a28..3cc6ad9 100644
--- a/internal/authPostman.go
+++ b/internal/authPostman.go
@@ -10,7 +10,9 @@ import (
 
 	"git.slaventius.ru/test3k/authPostman/internal/config"
 	kafka "git.slaventius.ru/test3k/authPostman/internal/transport/kafka"
-	"git.slaventius.ru/test3k/authPostman/internal/transport/telegram"
+
+	// telegram "git.slaventius.ru/test3k/authPostman/internal/transport/telegram"
+	smtp "git.slaventius.ru/test3k/authPostman/internal/transport/smtp"
 )
 
 const (
@@ -65,26 +67,26 @@ func (s *AuthPostmanServer) ReadMessage(offset int64) error {
 
 		//
 		text := fmt.Sprintf("Confirmation code %v", amsg.Code)
-		postman := telegram.NewService(s.config.Telegram.ChatToken)
-		message := postman.NewMessage(s.config.Telegram.ChatID, text)
-		ers := postman.SendMessage(message)
-		if ers != nil {
-			log.Print(ers)
-		} else {
-			log.Printf("send code %s to %s completed", amsg.Code, amsg.Email)
-		}
-
-		// //
-		// message := smtp.NewMessage("Confirmation code", text)
-		// message.AppendRecipient(amsg.Email)
-
-		// //
-		// smtpSender := smtp.NewService(s.config.Smtp.Host, s.config.Smtp.Port, s.config.Smtp.Sender, s.config.Smtp.Password)
-		// ers := smtpSender.Send(message)
+		// postman := telegram.NewService(s.config.Telegram.ChatToken)
+		// message := postman.NewMessage(s.config.Telegram.ChatID, text)
+		// ers := postman.SendMessage(message)
 		// if ers != nil {
 		// 	log.Print(ers)
 		// } else {
 		// 	log.Printf("send code %s to %s completed", amsg.Code, amsg.Email)
 		// }
+
+		//
+		message := smtp.NewMessage("Confirmation code", text)
+		message.AppendRecipient(amsg.Email)
+
+		//
+		smtpSender := smtp.NewService(s.config.Smtp.Host, s.config.Smtp.Port, s.config.Smtp.Sender, s.config.Smtp.Password)
+		ers := smtpSender.Send(message)
+		if ers != nil {
+			log.Print(ers)
+		} else {
+			log.Printf("send code %s to %s completed", amsg.Code, amsg.Email)
+		}
 	}
 }
diff --git a/internal/config/config.go b/internal/config/config.go
index 0f7efb6..073a4ac 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -6,18 +6,18 @@ import (
 	"github.com/kelseyhightower/envconfig"
 )
 
-// type smtpConfig struct {
-// 	Port     int    `envconfig:"SMTP_PORT"`
-// 	Host     string `envconfig:"SMTP_HOST"`
-// 	Sender   string `envconfig:"SMTP_SENDER"`
-// 	Password string `envconfig:"SMTP_PASSWORD"`
-// }
-
-type telegramConfig struct {
-	ChatID    int64  `envconfig:"CHAT_ID"`
-	ChatToken string `envconfig:"CHAT_TOKEN"`
+type smtpConfig struct {
+	Port     int    `envconfig:"SMTP_PORT"`
+	Host     string `envconfig:"SMTP_HOST"`
+	Sender   string `envconfig:"SMTP_SENDER"`
+	Password string `envconfig:"SMTP_PASSWORD"`
 }
 
+// type telegramConfig struct {
+// 	ChatID    int64  `envconfig:"CHAT_ID"`
+// 	ChatToken string `envconfig:"CHAT_TOKEN"`
+// }
+
 type kafkaConfig struct {
 	Port int    `envconfig:"KAFKA_PORT"`
 	Host string `envconfig:"KAFKA_HOST"`
@@ -25,9 +25,9 @@ type kafkaConfig struct {
 
 // ...
 type Config struct {
-	// Smtp  smtpConfig
-	Kafka    kafkaConfig
-	Telegram telegramConfig
+	Smtp  smtpConfig
+	Kafka kafkaConfig
+	// Telegram telegramConfig
 }
 
 func NewConfig() *Config {