fix button in mail

This commit is contained in:
skeris 2024-10-10 21:48:16 +03:00
parent 07f08aad55
commit 1921d1aa92
4 changed files with 10 additions and 5 deletions

@ -80,6 +80,7 @@
<tr> <tr>
<td colspan="2" style="height: 100%"> <td colspan="2" style="height: 100%">
<a <a
href="https://quiz.pena.digital/results/{{ .QuizID }}"
style=" style="
display: flex; display: flex;
justify-content: center; justify-content: center;

@ -155,7 +155,7 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
return return
} }
result, err := w.processAnswerWithPrivileges(ctx, quiz.Name, quizConfig, questionsMap, privileges, account, sortedallAnswers, answerContent, answer.CreatedAt) result, err := w.processAnswerWithPrivileges(ctx, quiz.Name, quizConfig, questionsMap, privileges, account, sortedallAnswers, answerContent, answer.CreatedAt, answer.QuizId)
fmt.Println("ANS8", err, result, privileges) fmt.Println("ANS8", err, result, privileges)
if err != nil { if err != nil {
w.reportError(err, "Error process answer with privileges") w.reportError(err, "Error process answer with privileges")
@ -174,7 +174,7 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
func (w *SendToClient) processAnswerWithPrivileges(ctx context.Context, quizName string, quizConfig model.QuizConfig, func (w *SendToClient) processAnswerWithPrivileges(ctx context.Context, quizName string, quizConfig model.QuizConfig,
questionsMap map[uint64]string, privileges []model.ShortPrivilege, account model.Account, allAnswers []model.ResultAnswer, questionsMap map[uint64]string, privileges []model.ShortPrivilege, account model.Account, allAnswers []model.ResultAnswer,
answerContent model.ResultContent, answerTime time.Time) (bool, error) { answerContent model.ResultContent, answerTime time.Time, quizID uint64) (bool, error) {
err := w.notificationCustomer(account, privileges) err := w.notificationCustomer(account, privileges)
fmt.Println("ANS81", err) fmt.Println("ANS81", err)
@ -183,7 +183,7 @@ func (w *SendToClient) processAnswerWithPrivileges(ctx context.Context, quizName
} }
if wctools.HasUnlimitedPrivilege(privileges) { if wctools.HasUnlimitedPrivilege(privileges) {
err := w.ProcessMessageToClient(quizConfig, questionsMap, account, allAnswers, answerContent, answerTime) err := w.ProcessMessageToClient(quizConfig, questionsMap, account, allAnswers, answerContent, answerTime, quizID)
if err != nil { if err != nil {
return false, err return false, err
} }
@ -191,7 +191,7 @@ func (w *SendToClient) processAnswerWithPrivileges(ctx context.Context, quizName
} }
privilege := wctools.HasQuizCntPrivilege(privileges) privilege := wctools.HasQuizCntPrivilege(privileges)
if privilege != nil { if privilege != nil {
err := w.ProcessMessageToClient(quizConfig, questionsMap, account, allAnswers, answerContent, answerTime) err := w.ProcessMessageToClient(quizConfig, questionsMap, account, allAnswers, answerContent, answerTime, quizID)
fmt.Println("PMC", err) fmt.Println("PMC", err)
if err != nil { if err != nil {
return true, err return true, err
@ -306,7 +306,7 @@ func (w *SendToClient) notificationCustomer(account model.Account, privileges []
} }
// сделал экспортируемым для теста // сделал экспортируемым для теста
func (w *SendToClient) ProcessMessageToClient(quizConfig model.QuizConfig, questionsMap map[uint64]string, account model.Account, allAnswers []model.ResultAnswer, answerContent model.ResultContent, answerTime time.Time) error { func (w *SendToClient) ProcessMessageToClient(quizConfig model.QuizConfig, questionsMap map[uint64]string, account model.Account, allAnswers []model.ResultAnswer, answerContent model.ResultContent, answerTime time.Time, quizID uint64) error {
theme := quizConfig.Mailing.Theme theme := quizConfig.Mailing.Theme
quizConfig.Mailing.Theme = quizConfig.Mailing.Reply quizConfig.Mailing.Theme = quizConfig.Mailing.Reply
@ -315,6 +315,7 @@ func (w *SendToClient) ProcessMessageToClient(quizConfig model.QuizConfig, quest
AnswerContent: answerContent, AnswerContent: answerContent,
AllAnswers: allAnswers, AllAnswers: allAnswers,
QuestionsMap: questionsMap, QuestionsMap: questionsMap,
QuizID: quizID,
} }
dayOfWeek := wctools.DaysOfWeek[answerTime.Format("Monday")] dayOfWeek := wctools.DaysOfWeek[answerTime.Format("Monday")]

@ -26,6 +26,7 @@ type Client struct {
type EmailTemplateData struct { type EmailTemplateData struct {
QuizConfig model.ResultInfo QuizConfig model.ResultInfo
QuizID uint64
AnswerContent model.ResultContent AnswerContent model.ResultContent
AllAnswers []model.ResultAnswer AllAnswers []model.ResultAnswer
QuestionsMap map[uint64]string QuestionsMap map[uint64]string
@ -123,6 +124,7 @@ func generateTextFromTemplate(data EmailTemplateData, tpl string) (string, error
AllAnswers: data.AllAnswers, AllAnswers: data.AllAnswers,
QuestionsMap: data.QuestionsMap, QuestionsMap: data.QuestionsMap,
AnswerTime: data.AnswerTime, AnswerTime: data.AnswerTime,
QuizID: data.QuizID,
}); err != nil { }); err != nil {
return "", fmt.Errorf("error executing template: %w", err) return "", fmt.Errorf("error executing template: %w", err)
} }

@ -99,6 +99,7 @@ func sanitizeHTMLData(data EmailTemplateData) EmailTemplateData {
AllAnswers: stripHTMLResultAnswers(data.AllAnswers), AllAnswers: stripHTMLResultAnswers(data.AllAnswers),
QuestionsMap: stripHTMLResultMap(data.QuestionsMap), QuestionsMap: stripHTMLResultMap(data.QuestionsMap),
AnswerTime: StripHTML(data.AnswerTime), AnswerTime: StripHTML(data.AnswerTime),
QuizID: data.QuizID,
} }
return sanitized return sanitized
} }