diff --git a/internal/senders/common.go b/internal/senders/common.go
index 7d7469c..eea4fc5 100644
--- a/internal/senders/common.go
+++ b/internal/senders/common.go
@@ -30,7 +30,7 @@ type TemplateData struct {
AllAnswers []model.ResultAnswer
QuestionsMap map[uint64]string
AnswerTime string
- QuizID int64
+ QuizID int64
}
func generateTextFromTemplate(data TemplateData, tpl string) (string, error) {
@@ -65,7 +65,7 @@ func RenderImage(content string) template.HTML {
contents := strings.Split(content, "`,`")
var builder strings.Builder
- content = strings.ReplaceAll(content, "\n","
")
+ content = strings.ReplaceAll(content, "\n", "
")
for i, cnt := range contents {
if i == 0 {
cnt = strings.TrimPrefix(cnt, "`")
@@ -79,7 +79,15 @@ func RenderImage(content string) template.HTML {
if err != nil {
return SplitContent(content)
} else {
- builder.WriteString(fmt.Sprintf("
%s
 | ", res.Description, strings.Replace(res.Image, "http", "https", 1)))
+ imgURL := res.Image
+ if strings.HasPrefix(imgURL, "http://") {
+ imgURL = strings.Replace(imgURL, "http://", "https://", 1)
+ }
+ builder.WriteString(
+ fmt.Sprintf(`
+ %s  | `,
+ res.Description, imgURL, res.Description))
+
}
}
diff --git a/tests/smtp_test.go b/tests/smtp_test.go
index 31474a5..80e10c9 100644
--- a/tests/smtp_test.go
+++ b/tests/smtp_test.go
@@ -62,10 +62,10 @@ func TestProcessMessageToSMTP(t *testing.T) {
Messenger: "test_messenger",
},
AllAnswers: []model.ResultAnswer{
- {AnswerID: 1, QuestionID: 1, Content: "https://www.google.com/search?sca_esv=c51a80de1a7d45f0&sxsrf=ACQVn08xG-a0eH1Vds246-fONoSvvjzVMw:1707762485524&q=ku,n&tbm=isch&source=lnms&sa=X&ved=2ahUKEwi7ub2Ct6aEAxVVb_UHHQIQBVoQ0pQJegQIDRAB&biw=1536&bih=703&dpr=1.25#imgrc=0PWwTuuH2uBQ3M|html", CreatedAt: time.Now()},
- {AnswerID: 2, QuestionID: 2, Content: "From a friend", CreatedAt: time.Now()},
+ {AnswerID: 1, QuestionID: 1, Content: "`{\"Image\":\"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/e0927ded-5c4c-4d45-a5ba-c2e938362ffa/co0sejfg4n3c73d5umd0\",\"Description\":\"Да\"}`", CreatedAt: time.Now()},
+ {AnswerID: 2, QuestionID: 2, Content: "`ыв`,`вв`", CreatedAt: time.Now()},
{AnswerID: 3, QuestionID: 3, Content: "From a friend", CreatedAt: time.Now()},
- {AnswerID: 4, QuestionID: 4, Content: `{"Image":"https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg","Description":"Gekon"}`, CreatedAt: time.Now()},
+ {AnswerID: 4, QuestionID: 4, Content: `{"Image":"static.tildacdn.com/tild6335-6331-4539-a664-376366653534/_problembocom.jpg","Description":"Gekon"}`, CreatedAt: time.Now()},
},
QuestionsMap: map[uint64]string{
1: "?",