Merge branch 'fixMail' into 'staging'
Fix mail See merge request backend/quiz/worker!6
This commit is contained in:
commit
6375bbb24d
@ -73,7 +73,7 @@ func RenderImage(content string) template.HTML {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return SplitContent(content)
|
return SplitContent(content)
|
||||||
} else {
|
} else {
|
||||||
builder.WriteString(fmt.Sprintf("<td>%s<br><img class=\"image\" style=\"width:100%%; max-width:250px; max-height:250px\" src=\"%s\"/></td>", res.Description, res.Image))
|
builder.WriteString(fmt.Sprintf("<tr><td>%s<br><img class=\"image\" style=\"width:100%%; max-width:250px; max-height:250px\" src=\"%s\"/></td></tr>", res.Description, res.Image))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ func SplitContent(content string) template.HTML {
|
|||||||
|
|
||||||
return template.HTML(fmt.Sprintf(`<a href="%s" download>%s</a>`, url, filename))
|
return template.HTML(fmt.Sprintf(`<a href="%s" download>%s</a>`, url, filename))
|
||||||
}
|
}
|
||||||
return template.HTML(content)
|
return template.HTML(strings.ReplaceAll(content, "\n", "<br>"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func sanitizeHTMLData(data TemplateData) TemplateData {
|
func sanitizeHTMLData(data TemplateData) TemplateData {
|
||||||
|
17
tests/img_contents.json
Normal file
17
tests/img_contents.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[
|
||||||
|
{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/cq64n9vot84c73evddbg","Description":"Вариант 1"}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/cq64navot84c73evddcg","Description":"Вариант 2"}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmkvot84c739fusn0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmm7ot84c739fuso0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmn7ot84c739fusp0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmo7ot84c739fusq0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmp7ot84c739fusr0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmqfot84c739fuss0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmrnot84c739fust0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalmsnot84c739fusu0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln27ot84c739fusv0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln3fot84c739fut00","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln47ot84c739fut10","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln57ot84c739fut20","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln6fot84c739fut30","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln7fot84c739fut40","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln8fot84c739fut50","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaln9fot84c739fut60","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnafot84c739fut70","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnb7ot84c739fut80","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalncfot84c739fut90","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalndnot84c739futa0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnenot84c739futb0","Description":""},
|
||||||
|
{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnfnot84c739futc0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalngvot84c739futd0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalni7ot84c739fute0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnj7ot84c739futf0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnjvot84c739futg0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnkvot84c739futh0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnlnot84c739futi0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnn7ot84c739futj0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalno7ot84c739futk0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnp7ot84c739futl0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnq7ot84c739futm0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnr7ot84c739futn0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalns7ot84c739futo0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnt7ot84c739futp0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalnu7ot84c739futq0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo07ot84c739futr0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo1fot84c739futs0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo2fot84c739futt0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo37ot84c739futu0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo47ot84c739futv0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo57ot84c739fuu00","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo67ot84c739fuu10","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo6vot84c739fuu20","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo87ot84c739fuu30","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalo97ot84c739fuu40","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaloa7ot84c739fuu50","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalob7ot84c739fuu60","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalobvot84c739fuu70","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalocnot84c739fuu80","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalodfot84c739fuu90","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csaloefot84c739fuua0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalof7ot84c739fuub0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalofvot84c739fuuc0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalogvot84c739fuud0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalohvot84c739fuue0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalot7ot84c739fuuf0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalou7ot84c739fuug0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalouvot84c739fuuh0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp07ot84c739fuui0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp17ot84c739fuuj0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp27ot84c739fuuk0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp37ot84c739fuul0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp4fot84c739fuum0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp5vot84c739fuun0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp6not84c739fuuo0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp7fot84c739fuup0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp8fot84c739fuuq0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalp9vot84c739fuur0","Description":""}
|
||||||
|
,{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpanot84c739fuus0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpbfot84c739fuut0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpc7ot84c739fuuu0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpd7ot84c739fuuv0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpenot84c739fuv00","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpffot84c739fuv10","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpgfot84c739fuv20","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalph7ot84c739fuv30","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalphvot84c739fuv40","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpinot84c739fuv50","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpjnot84c739fuv60","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpkfot84c739fuv70","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpl7ot84c739fuv80","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalplvot84c739fuv90","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpn7ot84c739fuva0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpnvot84c739fuvb0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpofot84c739fuvc0","Description":""},{"Image":"https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/33ec973f-b4bd-4215-bb13-b98914161908/csalpp7ot84c739fuvd0","Description":""}]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -8,11 +8,14 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/pioz/faker"
|
"github.com/pioz/faker"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"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/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/answerwc"
|
"penahub.gitlab.yandexcloud.net/backend/quiz/worker/answerwc"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/quiz/worker/senders"
|
"penahub.gitlab.yandexcloud.net/backend/quiz/worker/senders"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -161,39 +164,29 @@ func TestProcessMessageToClient(t *testing.T) {
|
|||||||
UserID: "64f2cd7a7047f28fdabf6d9e",
|
UserID: "64f2cd7a7047f28fdabf6d9e",
|
||||||
}
|
}
|
||||||
|
|
||||||
f := model.ImageContent{
|
file, err := os.Open("img_contents.json")
|
||||||
Image: "https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg",
|
if err != nil {
|
||||||
Description: "Gekon",
|
fmt.Println("Failed to open file", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
bytes, err := ioutil.ReadAll(file)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed to read file", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s := model.ImageContent{
|
var items []model.ImageContent
|
||||||
Image: "https://otvet.imgsmail.ru/download/259979446_0cec59a5be8fdd4b6f48cb11e4d79e03_800.jpg",
|
err = json.Unmarshal(bytes, &items)
|
||||||
Description: "Born To Trall",
|
if err != nil {
|
||||||
|
fmt.Println("Failed to unmarshal JSON:", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
th := model.ImageContent{
|
fmt.Println(len(items))
|
||||||
Image: "https://miro.medium.com/v2/resize:fit:600/1*i2skbfmDsHayHhqPfwt6pA.png",
|
|
||||||
Description: "Gopher",
|
|
||||||
}
|
|
||||||
|
|
||||||
fo := model.ImageContent{
|
|
||||||
Image: "https://aqua-tver.su/sites/default/files/product/terra-BrachypelmaAlbopilosum.png",
|
|
||||||
Description: "Pawuk",
|
|
||||||
}
|
|
||||||
|
|
||||||
fj, _ := json.Marshal(f)
|
|
||||||
sj, _ := json.Marshal(s)
|
|
||||||
thj, _ := json.Marshal(th)
|
|
||||||
foj, _ := json.Marshal(fo)
|
|
||||||
|
|
||||||
fmt.Println(quizConfig)
|
|
||||||
|
|
||||||
allAnswers := []model.ResultAnswer{
|
allAnswers := []model.ResultAnswer{
|
||||||
{
|
|
||||||
Content: fmt.Sprintf("`%s`,`%s`,`%s`,`%s`", fj, sj, thj, foj),
|
|
||||||
AnswerID: 1,
|
|
||||||
QuestionID: 1,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Content: "",
|
Content: "",
|
||||||
AnswerID: 2,
|
AnswerID: 2,
|
||||||
@ -201,7 +194,29 @@ func TestProcessMessageToClient(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
println(allAnswers[0].Content)
|
answersIMG := model.ResultAnswer{
|
||||||
|
Content: "",
|
||||||
|
AnswerID: 1,
|
||||||
|
QuestionID: 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
var imageLinks []string
|
||||||
|
|
||||||
|
for _, item := range items {
|
||||||
|
|
||||||
|
str, err := json.Marshal(item)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("error marshal item to str:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
imageLinks = append(imageLinks, fmt.Sprintf("`%s`", string(str)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(len(imageLinks))
|
||||||
|
|
||||||
|
answersIMG.Content = strings.Join(imageLinks, ",")
|
||||||
|
|
||||||
|
allAnswers = append(allAnswers, answersIMG)
|
||||||
|
|
||||||
answerContent := model.ResultContent{
|
answerContent := model.ResultContent{
|
||||||
Name: "Pasha",
|
Name: "Pasha",
|
||||||
@ -245,3 +260,35 @@ func TestProcessMessageToClient(t *testing.T) {
|
|||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//func TestManyImg(t *testing.T) {
|
||||||
|
// smtpData := clients.Deps{
|
||||||
|
// SmtpApiUrl: "https://api.smtp.bz/v1/smtp/send",
|
||||||
|
// SmtpHost: "connect.mailclient.bz",
|
||||||
|
// SmtpPort: "587",
|
||||||
|
// SmtpSender: "skeris@mailing.pena.digital",
|
||||||
|
// ApiKey: "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev",
|
||||||
|
// FiberClient: &fiber.Client{},
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// mailClient := clients.NewSmtpClient(smtpData)
|
||||||
|
// mailSender := senders.NewMailLeadSender(mailClient)
|
||||||
|
// tgSender, err := senders.NewTgSender("6712573453:AAFqTOsgwe_j48ZQ1GzWKQDT5Nwr-SAWjz8")
|
||||||
|
// assert.NoError(t, err)
|
||||||
|
//
|
||||||
|
// ctx := context.Background()
|
||||||
|
//
|
||||||
|
// repo, err := dal.New(ctx, "host=localhost port=35432 user=squiz password=Redalert2 dbname=squiz sslmode=disable", nil)
|
||||||
|
// assert.NoError(t, err)
|
||||||
|
//
|
||||||
|
// deps := answerwc.DepsSendToClient{
|
||||||
|
// Redis: nil,
|
||||||
|
// Dal: repo,
|
||||||
|
// LeadSenders: []senders.LeadSender{mailSender, tgSender},
|
||||||
|
// CustomerService: nil,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// errChan := make(chan<- error)
|
||||||
|
//
|
||||||
|
// w := answerwc.NewSendToClient(deps, errChan)
|
||||||
|
//}
|
||||||
|
@ -147,7 +147,8 @@ func ToJSON(data interface{}) (string, error) {
|
|||||||
func CleanNullContent(answers []model.ResultAnswer) []model.ResultAnswer {
|
func CleanNullContent(answers []model.ResultAnswer) []model.ResultAnswer {
|
||||||
var results []model.ResultAnswer
|
var results []model.ResultAnswer
|
||||||
for _, answer := range answers {
|
for _, answer := range answers {
|
||||||
answer.Content = strings.ReplaceAll(strings.ReplaceAll(answer.Content, "`,`", "`<br>`"),"\n","<br>")
|
// пока закоментил так как разделитель у нас используется
|
||||||
|
//answer.Content = strings.ReplaceAll(strings.ReplaceAll(answer.Content, "`,`", "`<br>`"),"\n","<br>")
|
||||||
if answer.Content != "" {
|
if answer.Content != "" {
|
||||||
results = append(results, answer)
|
results = append(results, answer)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user