slaventius 2 years ago
parent b0c2a977a7
commit 955a2e8b5f
  1. 2
      .vscode/launch.json
  2. 11
      internal/authPostman.go
  3. 20
      internal/config/config.go

@ -18,6 +18,8 @@
"SMTP_PASSWORD":"hwNhMgPyBzMjwCj3hFPp", "SMTP_PASSWORD":"hwNhMgPyBzMjwCj3hFPp",
"KAFKA_PORT":"9092", "KAFKA_PORT":"9092",
"KAFKA_HOST":"37.143.12.169", "KAFKA_HOST":"37.143.12.169",
"CHAT_ID":"150697696",
"CHAT_TOKEN":"5960577375:AAEZYPZV4-ErxQbX6yP084pIzCB0BPxN7ig",
}, },
"args": [] "args": []
} }

@ -14,8 +14,6 @@ import (
) )
const ( const (
chatID int64 = 150697696
token string = "5944264850:AAHaikh8r8NYciybnOpqEvFQpSYgr6JHDZc"
topicRegistrations string = "registrations" // Топик для регистраций topicRegistrations string = "registrations" // Топик для регистраций
) )
@ -66,8 +64,9 @@ func (s *AuthPostmanServer) ReadMessage(offset int64) error {
log.Printf("send code %s to %s ...", amsg.Code, amsg.Email) log.Printf("send code %s to %s ...", amsg.Code, amsg.Email)
// //
postman := telegram.NewService(token) text := fmt.Sprintf("Confirmation code %v", amsg.Code)
message := postman.NewMessage(chatID, 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) ers := postman.SendMessage(message)
if ers != nil { if ers != nil {
log.Print(ers) log.Print(ers)
@ -76,7 +75,7 @@ func (s *AuthPostmanServer) ReadMessage(offset int64) error {
} }
// // // //
// message := smtp.NewMessage("Confirmation code", amsg.Code) // message := smtp.NewMessage("Confirmation code", text)
// message.AppendRecipient(amsg.Email) // message.AppendRecipient(amsg.Email)
// // // //
@ -84,6 +83,8 @@ func (s *AuthPostmanServer) ReadMessage(offset int64) error {
// ers := smtpSender.Send(message) // ers := smtpSender.Send(message)
// if ers != nil { // if ers != nil {
// log.Print(ers) // log.Print(ers)
// } else {
// log.Printf("send code %s to %s completed", amsg.Code, amsg.Email)
// } // }
} }
} }

@ -6,11 +6,16 @@ import (
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
) )
type smtpConfig struct { // type smtpConfig struct {
Port int `envconfig:"SMTP_PORT"` // Port int `envconfig:"SMTP_PORT"`
Host string `envconfig:"SMTP_HOST"` // Host string `envconfig:"SMTP_HOST"`
Sender string `envconfig:"SMTP_SENDER"` // Sender string `envconfig:"SMTP_SENDER"`
Password string `envconfig:"SMTP_PASSWORD"` // Password string `envconfig:"SMTP_PASSWORD"`
// }
type telegramConfig struct {
ChatID int64 `envconfig:"CHAT_ID"`
ChatToken string `envconfig:"CHAT_TOKEN"`
} }
type kafkaConfig struct { type kafkaConfig struct {
@ -20,8 +25,9 @@ type kafkaConfig struct {
// ... // ...
type Config struct { type Config struct {
Smtp smtpConfig // Smtp smtpConfig
Kafka kafkaConfig Kafka kafkaConfig
Telegram telegramConfig
} }
func NewConfig() *Config { func NewConfig() *Config {

Loading…
Cancel
Save