tests passed
This commit is contained in:
parent
67e6ea4a5a
commit
261c52f840
@ -37,18 +37,25 @@ type PendingTasks struct {
|
|||||||
QuizConfig model.QuizConfig
|
QuizConfig model.QuizConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed mail/to_client.tmpl
|
//go:embed template/to_client.tmpl
|
||||||
var toClientTemplate string
|
var toClientTemplate string
|
||||||
|
|
||||||
//go:embed mail/reminder.tmpl
|
//go:embed template/reminder.tmpl
|
||||||
var reminderTemplate string
|
var reminderTemplate string
|
||||||
|
|
||||||
|
//go:embed template/client_tg.tmpl
|
||||||
|
var toClientTgTemplate string
|
||||||
|
|
||||||
|
//go:embed template/client_whatsapp.tmpl
|
||||||
|
var toClientWhatsAppTemplate string
|
||||||
|
|
||||||
func NewSendToClient(deps DepsSendToClient, errChan chan<- error) *SendToClient {
|
func NewSendToClient(deps DepsSendToClient, errChan chan<- error) *SendToClient {
|
||||||
return &SendToClient{
|
return &SendToClient{
|
||||||
redis: deps.Redis,
|
redis: deps.Redis,
|
||||||
dal: deps.Dal,
|
dal: deps.Dal,
|
||||||
customerService: deps.CustomerService,
|
customerService: deps.CustomerService,
|
||||||
errChan: errChan,
|
errChan: errChan,
|
||||||
|
leadSenders: deps.LeadSenders,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,13 +211,13 @@ func (w *SendToClient) processAnswerWithPrivileges(ctx context.Context, data Pro
|
|||||||
|
|
||||||
if wctools.HasUnlimitedPrivilege(data.privileges) {
|
if wctools.HasUnlimitedPrivilege(data.privileges) {
|
||||||
err := w.ProcessMessageToClient(ctx, DepsProcessMsgToClient{
|
err := w.ProcessMessageToClient(ctx, DepsProcessMsgToClient{
|
||||||
quizConfig: data.quizConfig,
|
QuizConfig: data.quizConfig,
|
||||||
questionsMap: data.questionsMap,
|
QuestionsMap: data.questionsMap,
|
||||||
account: data.account,
|
Account: data.account,
|
||||||
allAnswers: data.allAnswers,
|
AllAnswers: data.allAnswers,
|
||||||
answerContent: data.answerContent,
|
AnswerContent: data.answerContent,
|
||||||
answerTime: data.answerTime,
|
AnswerTime: data.answerTime,
|
||||||
quiz: data.quiz,
|
Quiz: data.quiz,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -220,13 +227,13 @@ func (w *SendToClient) processAnswerWithPrivileges(ctx context.Context, data Pro
|
|||||||
privilege := wctools.HasQuizCntPrivilege(data.privileges)
|
privilege := wctools.HasQuizCntPrivilege(data.privileges)
|
||||||
if privilege != nil {
|
if privilege != nil {
|
||||||
err := w.ProcessMessageToClient(ctx, DepsProcessMsgToClient{
|
err := w.ProcessMessageToClient(ctx, DepsProcessMsgToClient{
|
||||||
quizConfig: data.quizConfig,
|
QuizConfig: data.quizConfig,
|
||||||
questionsMap: data.questionsMap,
|
QuestionsMap: data.questionsMap,
|
||||||
account: data.account,
|
Account: data.account,
|
||||||
allAnswers: data.allAnswers,
|
AllAnswers: data.allAnswers,
|
||||||
answerContent: data.answerContent,
|
AnswerContent: data.answerContent,
|
||||||
answerTime: data.answerTime,
|
AnswerTime: data.answerTime,
|
||||||
quiz: data.quiz,
|
Quiz: data.quiz,
|
||||||
})
|
})
|
||||||
fmt.Println("PMC", err)
|
fmt.Println("PMC", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -296,7 +303,7 @@ type sendTaskRemindersDeps struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *SendToClient) checkAndSendTaskReminders(ctx context.Context, data sendTaskRemindersDeps) {
|
func (w *SendToClient) checkAndSendTaskReminders(ctx context.Context, data sendTaskRemindersDeps) {
|
||||||
err := w.processReminderToClient(ctx, data.account, data.config, data.quiz)
|
err := w.ProcessReminderToClient(ctx, data.account, data.config, data.quiz)
|
||||||
fmt.Println("PMC1", err)
|
fmt.Println("PMC1", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.reportError(err, "Error sending tasks reminder email")
|
w.reportError(err, "Error sending tasks reminder email")
|
||||||
@ -338,22 +345,22 @@ func (w *SendToClient) notificationCustomer(ctx context.Context, account model.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DepsProcessMsgToClient struct {
|
type DepsProcessMsgToClient struct {
|
||||||
quizConfig model.QuizConfig
|
QuizConfig model.QuizConfig
|
||||||
questionsMap map[uint64]string
|
QuestionsMap map[uint64]string
|
||||||
account model.Account
|
Account model.Account
|
||||||
allAnswers []model.ResultAnswer
|
AllAnswers []model.ResultAnswer
|
||||||
answerContent model.ResultContent
|
AnswerContent model.ResultContent
|
||||||
answerTime time.Time
|
AnswerTime time.Time
|
||||||
quiz *model.Quiz
|
Quiz *model.Quiz
|
||||||
}
|
}
|
||||||
|
|
||||||
// сделал экспортируемым для теста
|
// сделал экспортируемым для теста
|
||||||
func (w *SendToClient) ProcessMessageToClient(ctx context.Context, constructData DepsProcessMsgToClient) error {
|
func (w *SendToClient) ProcessMessageToClient(ctx context.Context, constructData DepsProcessMsgToClient) error {
|
||||||
leadTargetForAll, err := w.dal.AccountRepo.GetLeadTarget(ctx, constructData.quiz.AccountId, 0)
|
leadTargetForAll, err := w.dal.AccountRepo.GetLeadTarget(ctx, constructData.Quiz.AccountId, 0)
|
||||||
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
leadTargetForQuiz, err := w.dal.AccountRepo.GetLeadTarget(ctx, constructData.quiz.AccountId, int32(constructData.quiz.Id))
|
leadTargetForQuiz, err := w.dal.AccountRepo.GetLeadTarget(ctx, constructData.Quiz.AccountId, int32(constructData.Quiz.Id))
|
||||||
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -361,37 +368,38 @@ func (w *SendToClient) ProcessMessageToClient(ctx context.Context, constructData
|
|||||||
leadTargetForAll = append(leadTargetForAll, leadTargetForQuiz...)
|
leadTargetForAll = append(leadTargetForAll, leadTargetForQuiz...)
|
||||||
}
|
}
|
||||||
|
|
||||||
theme := constructData.quizConfig.Mailing.Theme
|
theme := constructData.QuizConfig.Mailing.Theme
|
||||||
constructData.quizConfig.Mailing.Theme = constructData.quizConfig.Mailing.Reply
|
constructData.QuizConfig.Mailing.Theme = constructData.QuizConfig.Mailing.Reply
|
||||||
|
|
||||||
data := senders.TemplateData{
|
data := senders.TemplateData{
|
||||||
QuizConfig: constructData.quizConfig.Mailing,
|
QuizConfig: constructData.QuizConfig.Mailing,
|
||||||
AnswerContent: constructData.answerContent,
|
AnswerContent: constructData.AnswerContent,
|
||||||
AllAnswers: constructData.allAnswers,
|
AllAnswers: constructData.AllAnswers,
|
||||||
QuestionsMap: constructData.questionsMap,
|
QuestionsMap: constructData.QuestionsMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
dayOfWeek := wctools.DaysOfWeek[constructData.answerTime.Format("Monday")]
|
dayOfWeek := wctools.DaysOfWeek[constructData.AnswerTime.Format("Monday")]
|
||||||
monthOfYear := wctools.MonthsOfYear[constructData.answerTime.Format("January")]
|
monthOfYear := wctools.MonthsOfYear[constructData.AnswerTime.Format("January")]
|
||||||
|
|
||||||
formattedTime := fmt.Sprintf("%s, %d %s %d г., %02d:%02d (UTC%s)",
|
formattedTime := fmt.Sprintf("%s, %d %s %d г., %02d:%02d (UTC%s)",
|
||||||
dayOfWeek,
|
dayOfWeek,
|
||||||
constructData.answerTime.Day(),
|
constructData.AnswerTime.Day(),
|
||||||
monthOfYear,
|
monthOfYear,
|
||||||
constructData.answerTime.Year(),
|
constructData.AnswerTime.Year(),
|
||||||
constructData.answerTime.Hour(),
|
constructData.AnswerTime.Hour(),
|
||||||
constructData.answerTime.Minute(),
|
constructData.AnswerTime.Minute(),
|
||||||
constructData.answerTime.Format("-07:00"),
|
constructData.AnswerTime.Format("-07:00"),
|
||||||
)
|
)
|
||||||
|
|
||||||
data.AnswerTime = formattedTime
|
data.AnswerTime = formattedTime
|
||||||
|
|
||||||
mapLeadTarget := make(map[string][]senders.LeadData) // ключ имя сендера, модель отправки
|
mapLeadTarget := make(map[string][]senders.LeadData) // ключ имя сендера, модель отправки
|
||||||
for _, leadTarget := range leadTargetForAll {
|
for _, leadTarget := range leadTargetForAll {
|
||||||
|
// todo как тг и ватсап подключим надо разграничивать шаблоны в зависимости от типа таргета
|
||||||
mapLeadTarget[string(leadTarget.Type)] = append(mapLeadTarget[string(leadTarget.Type)], senders.LeadData{
|
mapLeadTarget[string(leadTarget.Type)] = append(mapLeadTarget[string(leadTarget.Type)], senders.LeadData{
|
||||||
To: leadTarget.Target,
|
To: leadTarget.Target,
|
||||||
Subject: theme,
|
Subject: theme,
|
||||||
TemplateData: data,
|
TemplateData: data,
|
||||||
|
Template: toClientTemplate,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,20 +415,19 @@ func (w *SendToClient) ProcessMessageToClient(ctx context.Context, constructData
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SendToClient) processReminderToClient(ctx context.Context, account model.Account, quizConfig model.QuizConfig, quiz *model.Quiz) error {
|
func (w *SendToClient) ProcessReminderToClient(ctx context.Context, account model.Account, quizConfig model.QuizConfig, quiz *model.Quiz) error {
|
||||||
leadTargetForAll, err := w.dal.AccountRepo.GetLeadTarget(ctx, account.ID, 0)
|
leadTargetForAll, err := w.dal.AccountRepo.GetLeadTarget(ctx, account.UserID, 0)
|
||||||
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
leadTargetForQuiz, err := w.dal.AccountRepo.GetLeadTarget(ctx, account.ID, int32(quiz.Id))
|
leadTargetForQuiz, err := w.dal.AccountRepo.GetLeadTarget(ctx, account.UserID, int32(quiz.Id))
|
||||||
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
if err != nil && !errors.Is(err, pj_errors.ErrNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(leadTargetForQuiz) > 0 {
|
if len(leadTargetForQuiz) > 0 {
|
||||||
leadTargetForAll = append(leadTargetForAll, leadTargetForQuiz...)
|
leadTargetForAll = append(leadTargetForAll, leadTargetForQuiz...)
|
||||||
}
|
}
|
||||||
|
|
||||||
mapLeadTarget := make(map[string][]senders.LeadData)
|
mapLeadTarget := make(map[string][]senders.LeadData)
|
||||||
for _, leadTarget := range leadTargetForAll {
|
for _, leadTarget := range leadTargetForAll {
|
||||||
data := senders.TemplateData{
|
data := senders.TemplateData{
|
||||||
@ -436,7 +443,7 @@ func (w *SendToClient) processReminderToClient(ctx context.Context, account mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("PRTC", data, leadTarget.Target, quizConfig)
|
fmt.Println("PRTC", data, leadTarget.Target, quizConfig)
|
||||||
|
// todo как тг и ватсап подключим надо разграничивать шаблоны в зависимости от типа таргета
|
||||||
mapLeadTarget[string(leadTarget.Type)] = append(mapLeadTarget[string(leadTarget.Type)], senders.LeadData{
|
mapLeadTarget[string(leadTarget.Type)] = append(mapLeadTarget[string(leadTarget.Type)], senders.LeadData{
|
||||||
To: leadTarget.Target,
|
To: leadTarget.Target,
|
||||||
Subject: quizConfig.Mailing.Theme,
|
Subject: quizConfig.Mailing.Theme,
|
||||||
@ -444,7 +451,6 @@ func (w *SendToClient) processReminderToClient(ctx context.Context, account mode
|
|||||||
TemplateData: data,
|
TemplateData: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, sender := range w.leadSenders {
|
for _, sender := range w.leadSenders {
|
||||||
for _, sendData := range mapLeadTarget[sender.Name()] {
|
for _, sendData := range mapLeadTarget[sender.Name()] {
|
||||||
err := sender.SendLead(sendData)
|
err := sender.SendLead(sendData)
|
||||||
|
12
app/app.go
12
app/app.go
@ -132,13 +132,13 @@ func New(ctx context.Context, opts interface{}, ver appInit.Version) (appInit.Co
|
|||||||
SmtpApiUrl: options.SmtpApiUrl,
|
SmtpApiUrl: options.SmtpApiUrl,
|
||||||
})
|
})
|
||||||
|
|
||||||
tgSender, err := senders.NewTgSender(options.TgToken)
|
//tgSender, err := senders.NewTgSender(options.TgToken)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
fmt.Println(err)
|
// fmt.Println(err)
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
//}
|
||||||
mailSender := senders.NewMailLeadSender(mailClent)
|
mailSender := senders.NewMailLeadSender(mailClent)
|
||||||
leadSenders := []senders.LeadSender{mailSender, tgSender}
|
leadSenders := []senders.LeadSender{mailSender}
|
||||||
|
|
||||||
customerClient := customer_clients.NewCustomersClient(customer_clients.CustomersClientDeps{
|
customerClient := customer_clients.NewCustomersClient(customer_clients.CustomersClientDeps{
|
||||||
Logger: zapLogger,
|
Logger: zapLogger,
|
||||||
|
1
go.mod
1
go.mod
@ -9,6 +9,7 @@ require (
|
|||||||
github.com/gofiber/fiber/v2 v2.52.4
|
github.com/gofiber/fiber/v2 v2.52.4
|
||||||
github.com/golang/protobuf v1.5.4
|
github.com/golang/protobuf v1.5.4
|
||||||
github.com/minio/minio-go/v7 v7.0.69
|
github.com/minio/minio-go/v7 v7.0.69
|
||||||
|
github.com/pioz/faker v1.7.3
|
||||||
github.com/skeris/appInit v1.0.2
|
github.com/skeris/appInit v1.0.2
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf
|
github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf
|
||||||
|
6
go.sum
6
go.sum
@ -79,6 +79,8 @@ github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM
|
|||||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||||
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||||
|
github.com/pioz/faker v1.7.3 h1:Tez8Emuq0UN+/d6mo3a9m/9ZZ/zdfJk0c5RtRatrceM=
|
||||||
|
github.com/pioz/faker v1.7.3/go.mod h1:xSpay5w/oz1a6+ww0M3vfpe40pSIykeUPeWEc3TvVlc=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
@ -98,6 +100,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
|
github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
|
||||||
@ -172,13 +175,12 @@ gopkg.in/tucnak/telebot.v2 v2.5.0/go.mod h1:BgaIIx50PSRS9pG59JH+geT82cfvoJU/IaI5
|
|||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c h1:CWb4UcuNXhd1KTNOmy2U0TJO4+Qxgxrj5cwkyFqbgrk=
|
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c h1:CWb4UcuNXhd1KTNOmy2U0TJO4+Qxgxrj5cwkyFqbgrk=
|
||||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE=
|
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE=
|
||||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240624105135-6982631f2a4b h1:dNBWrclJAXP/JFRYQPXWAqmF/UihGxH4oZ9Vs0lfm40=
|
|
||||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240624105135-6982631f2a4b/go.mod h1:uOuosXduBzd2WbLH6TDZO7ME7ZextulA662oZ6OsoB0=
|
|
||||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240624132638-0bf45822a652 h1:QI+VRYE25xtYbUgaxOBL9sj0WIKacPXlD6YD7TNO5SM=
|
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240624132638-0bf45822a652 h1:QI+VRYE25xtYbUgaxOBL9sj0WIKacPXlD6YD7TNO5SM=
|
||||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240624132638-0bf45822a652/go.mod h1:uOuosXduBzd2WbLH6TDZO7ME7ZextulA662oZ6OsoB0=
|
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240624132638-0bf45822a652/go.mod h1:uOuosXduBzd2WbLH6TDZO7ME7ZextulA662oZ6OsoB0=
|
||||||
penahub.gitlab.yandexcloud.net/pena-services/customer v1.0.1-0.20240608222239-5c78187bf014 h1:ziG55nv824SGFZ02AfagKQC5D4ODirGXnpVPQTL6YFA=
|
penahub.gitlab.yandexcloud.net/pena-services/customer v1.0.1-0.20240608222239-5c78187bf014 h1:ziG55nv824SGFZ02AfagKQC5D4ODirGXnpVPQTL6YFA=
|
||||||
|
@ -11,15 +11,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed template/client_mail.tmpl
|
|
||||||
var toClientMailTemplate string
|
|
||||||
|
|
||||||
//go:embed template/client_tg.tmpl
|
|
||||||
var toClientTgTemplate string
|
|
||||||
|
|
||||||
//go:embed template/client_whatsapp.tmpl
|
|
||||||
var toClientWhatsAppTemplate string
|
|
||||||
|
|
||||||
type LeadSender interface {
|
type LeadSender interface {
|
||||||
SendLead(leadData LeadData) error
|
SendLead(leadData LeadData) error
|
||||||
Name() string
|
Name() string
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package senders
|
package senders
|
||||||
|
|
||||||
import "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/clients"
|
import (
|
||||||
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/clients"
|
||||||
|
)
|
||||||
|
|
||||||
type MailLeadSender struct {
|
type MailLeadSender struct {
|
||||||
client *clients.SmtpClient
|
client *clients.SmtpClient
|
||||||
@ -11,7 +13,7 @@ func NewMailLeadSender(client *clients.SmtpClient) *MailLeadSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MailLeadSender) SendLead(data LeadData) error {
|
func (m *MailLeadSender) SendLead(data LeadData) error {
|
||||||
err := m.SendMailWithAttachment(data.To.(string), data.Subject, toClientMailTemplate, data.TemplateData, nil)
|
err := m.SendMailWithAttachment(data.To.(string), data.Subject, data.Template, data.TemplateData, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,537 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Document</title>
|
|
||||||
<style>
|
|
||||||
/* Сброс стилей */
|
|
||||||
body,
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
p,
|
|
||||||
div,
|
|
||||||
img,
|
|
||||||
button,
|
|
||||||
table,
|
|
||||||
th,
|
|
||||||
td {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
|
|
||||||
font: inherit;
|
|
||||||
vertical-align: baseline;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
background-color: #f2f2f7;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
h1 {
|
|
||||||
font-size: 25px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
font-size: 20px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body style="background-color: #f2f2f7; font-family: Arial, sans-serif">
|
|
||||||
<table style="width: 100%; padding: 16px">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<img class="image" style="width: 103px; height: 40px" src="https://storage.yandexcloud.net/squizimages/logo-email-squiz.png" />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p style="text-align: end; color: #9a9aaf; font-size: 14px">Квиз для вашего бизнеса</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="height: 100%">
|
|
||||||
<h1
|
|
||||||
style="
|
|
||||||
font-size: 30px;
|
|
||||||
font-weight: 600;
|
|
||||||
margin-bottom: 13px;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
margin-bottom: 13px;
|
|
||||||
margin-top: 50px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Поступила новая заявка с квиза “{{.QuizConfig.Theme}}”!
|
|
||||||
</h1>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="height: 100%">
|
|
||||||
<p style="color: #9a9aaf; font-size: 20px; margin-bottom: 50px">
|
|
||||||
Время заявки: {{ .AnswerTime }}
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="height: 100%">
|
|
||||||
<a
|
|
||||||
style="
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
color: #f2f3f7;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 18px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 24px;
|
|
||||||
border-radius: 8px;
|
|
||||||
border: 1px solid #7e2aea;
|
|
||||||
background: #7e2aea;
|
|
||||||
padding: 10px 43px;
|
|
||||||
max-height: 63px;
|
|
||||||
margin-bottom: 50px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Посмотреть в личном кабинете
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="height: 100%">
|
|
||||||
<h1
|
|
||||||
style="font-size: 25px; font-weight: 600; margin-bottom: 15px; width: 100%; margin: 0; margin-bottom: 13px"
|
|
||||||
>
|
|
||||||
Контакты
|
|
||||||
</h1>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="padding: 0">
|
|
||||||
<table
|
|
||||||
style="
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 8px;
|
|
||||||
text-align: left;
|
|
||||||
max-width: 480px;
|
|
||||||
width: 100%;
|
|
||||||
padding: 16px;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Имя
|
|
||||||
</th>
|
|
||||||
<td>
|
|
||||||
<p
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Name}}
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ if .AnswerContent.Email }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Email
|
|
||||||
</th>
|
|
||||||
<td style="word-break: break-word">
|
|
||||||
<p
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #7e2aea;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Email }}
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Phone }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Телефон
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Phone }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if .AnswerContent.Telegram }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Telegram
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Telegram }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Wechat }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Wechat
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Wechat }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Viber }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Viber
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Viber }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Vk }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Vk
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Vk }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Skype }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Skype
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Skype }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Whatsup }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Whatsup
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Whatsup }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Messenger }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Messenger
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Messenger }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .AnswerContent.Address }}
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Адрес
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ .AnswerContent.Address }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{ range $key, $value := .AnswerContent.Custom }}
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #9a9aaf;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ $key }}
|
|
||||||
</th>
|
|
||||||
<td
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ $value }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="height: 100%">
|
|
||||||
<h1
|
|
||||||
style="font-size: 25px; font-weight: 600; margin-bottom: 15px; width: 100%; margin: 0; margin-bottom: 13px"
|
|
||||||
>
|
|
||||||
Ответы
|
|
||||||
</h1>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
{{ range .AllAnswers }}
|
|
||||||
{{ if index $.QuestionsMap .AnswerID }}
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="padding: 0">
|
|
||||||
<table
|
|
||||||
style="
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 8px;
|
|
||||||
text-align: left;
|
|
||||||
max-width: 480px;
|
|
||||||
width: 100%;
|
|
||||||
padding: 16px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<tr>
|
|
||||||
<th colspan="2">
|
|
||||||
<p
|
|
||||||
style="
|
|
||||||
text-align: start;
|
|
||||||
color: #4d4d4d;
|
|
||||||
font-size: 20px;
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: normal;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ index $.QuestionsMap .AnswerID }}
|
|
||||||
</p>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td style="color: #9a9aaf; font-size: 20px; font-style: normal; font-weight: 400; line-height: normal">
|
|
||||||
{{ renderImage .Content }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" style="text-align: center; padding: 0">
|
|
||||||
<a style="color: #7e2aea; font-size: 20px; font-style: normal; font-weight: 400; line-height: normal">
|
|
||||||
quiz.pena.digital
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -24,7 +24,7 @@ func NewTgSender(tgToken string) (*TgSender, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tg *TgSender) SendLead(data LeadData) error {
|
func (tg *TgSender) SendLead(data LeadData) error {
|
||||||
text, err := generateTextFromTemplate(data.TemplateData, toClientTgTemplate)
|
text, err := generateTextFromTemplate(data.TemplateData, data.Template)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"fmt"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/pioz/faker"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/clients"
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/clients"
|
||||||
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||||
|
"penahub.gitlab.yandexcloud.net/backend/quiz/worker.git/answerwc"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/quiz/worker.git/senders"
|
"penahub.gitlab.yandexcloud.net/backend/quiz/worker.git/senders"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -105,73 +111,102 @@ func TestProcessReminderToClient(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//func TestProcessMessageToClient(t *testing.T) {
|
func TestProcessMessageToClient(t *testing.T) {
|
||||||
// smtpData := clients.Deps{
|
smtpData := clients.Deps{
|
||||||
// SmtpHost: "connect.mailclient.bz",
|
SmtpApiUrl: "https://api.smtp.bz/v1/smtp/send",
|
||||||
// SmtpPort: "587",
|
SmtpHost: "connect.mailclient.bz",
|
||||||
// SmtpSender: "skeris@mailing.pena.digital",
|
SmtpPort: "587",
|
||||||
// ApiKey: "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev",
|
SmtpSender: "skeris@mailing.pena.digital",
|
||||||
// FiberClient: &fiber.Client{},
|
ApiKey: "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev",
|
||||||
// }
|
FiberClient: &fiber.Client{},
|
||||||
//
|
}
|
||||||
// mailClient := clients.NewSmtpClient(smtpData)
|
|
||||||
// mailSender := senders.NewMailLeadSender(mailClient)
|
mailClient := clients.NewSmtpClient(smtpData)
|
||||||
//
|
mailSender := senders.NewMailLeadSender(mailClient)
|
||||||
// deps := answerwc.DepsSendToClient{
|
|
||||||
// Redis: nil,
|
ctx := context.Background()
|
||||||
// Dal: nil,
|
|
||||||
// LeadSenders: []senders.LeadSender{mailSender},
|
repo, err := dal.New(ctx, "host=localhost port=35432 user=squiz password=Redalert2 dbname=squiz sslmode=disable", nil)
|
||||||
// CustomerService: nil,
|
assert.NoError(t, err)
|
||||||
// }
|
|
||||||
//
|
deps := answerwc.DepsSendToClient{
|
||||||
// errChan := make(chan<- error)
|
Redis: nil,
|
||||||
//
|
Dal: repo,
|
||||||
// w := answerwc.NewSendToClient(deps, errChan)
|
LeadSenders: []senders.LeadSender{mailSender},
|
||||||
//
|
CustomerService: nil,
|
||||||
// quizConfig := model.QuizConfig{
|
}
|
||||||
// Mailing: model.ResultInfo{
|
|
||||||
// Theme: faker.String(),
|
errChan := make(chan<- error)
|
||||||
// },
|
|
||||||
// }
|
w := answerwc.NewSendToClient(deps, errChan)
|
||||||
//
|
|
||||||
// questionsMap := map[uint64]string{
|
quizConfig := model.QuizConfig{
|
||||||
// 1: faker.String(),
|
Mailing: model.ResultInfo{
|
||||||
// 2: faker.String(),
|
Theme: faker.String(),
|
||||||
// }
|
},
|
||||||
//
|
}
|
||||||
// account := model.Account{
|
|
||||||
// Email: "pashamullin2001@gmail.com",
|
questionsMap := map[uint64]string{
|
||||||
// }
|
1: faker.String(),
|
||||||
//
|
2: faker.String(),
|
||||||
// allAnswers := []model.ResultAnswer{
|
}
|
||||||
// {
|
|
||||||
// Content: `{"Image":"https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg","Description":"Gekon"}`,
|
account := model.Account{
|
||||||
// AnswerID: 1,
|
UserID: "64f2cd7a7047f28fdabf6d9e",
|
||||||
// QuestionID: 1,
|
}
|
||||||
// },
|
|
||||||
// {
|
allAnswers := []model.ResultAnswer{
|
||||||
// AnswerID: 2,
|
{
|
||||||
// QuestionID: 2,
|
Content: `{"Image":"https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg","Description":"Gekon"}`,
|
||||||
// },
|
AnswerID: 1,
|
||||||
// }
|
QuestionID: 1,
|
||||||
//
|
},
|
||||||
// answerContent := model.ResultContent{
|
{
|
||||||
// Name: "Pasha",
|
Content: "",
|
||||||
// Phone: "+723456789",
|
AnswerID: 2,
|
||||||
// Email: "test@example.com",
|
QuestionID: 2,
|
||||||
// //Adress: "chtoto tam",
|
},
|
||||||
// Telegram: "@test",
|
}
|
||||||
// Wechat: "test_wechat",
|
|
||||||
// Viber: "+723456789",
|
answerContent := model.ResultContent{
|
||||||
// Vk: "test_vk",
|
Name: "Pasha",
|
||||||
// Skype: "test_skype",
|
Phone: "+723456789",
|
||||||
// Whatsup: "test_whatsup",
|
Email: "test@example.com",
|
||||||
// Messenger: "test_messenger",
|
//Adress: "chtoto tam",
|
||||||
// }
|
Telegram: "@test",
|
||||||
//
|
Wechat: "test_wechat",
|
||||||
// answerTime := time.Now()
|
Viber: "+723456789",
|
||||||
//
|
Vk: "test_vk",
|
||||||
// err := w.ProcessMessageToClient(quizConfig, questionsMap, account, allAnswers, answerContent, answerTime)
|
Skype: "test_skype",
|
||||||
//
|
Whatsup: "test_whatsup",
|
||||||
// assert.NoError(t, err)
|
Messenger: "test_messenger",
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
answerTime := time.Now()
|
||||||
|
|
||||||
|
err = w.ProcessMessageToClient(ctx, answerwc.DepsProcessMsgToClient{
|
||||||
|
QuizConfig: quizConfig,
|
||||||
|
QuestionsMap: questionsMap,
|
||||||
|
Account: account,
|
||||||
|
AllAnswers: allAnswers,
|
||||||
|
AnswerContent: answerContent,
|
||||||
|
AnswerTime: answerTime,
|
||||||
|
Quiz: &model.Quiz{
|
||||||
|
Id: 1212,
|
||||||
|
AccountId: "64f2cd7a7047f28fdabf6d9e",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
err = w.ProcessReminderToClient(ctx, account, model.QuizConfig{
|
||||||
|
Mailing: model.ResultInfo{
|
||||||
|
When: "email",
|
||||||
|
Theme: fmt.Sprintf("не удалось отправить заявку по опросу\"%s\"", "test"),
|
||||||
|
Reply: "noreply@pena.digital",
|
||||||
|
ReplName: "Reminder",
|
||||||
|
},
|
||||||
|
}, &model.Quiz{
|
||||||
|
Id: 1212,
|
||||||
|
AccountId: "64f2cd7a7047f28fdabf6d9e",
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user