new rows in answer was added

This commit is contained in:
Pavel 2024-03-14 16:13:17 +03:00
parent 6b80eeaaa3
commit 27382cd6d2
3 changed files with 16 additions and 1 deletions

2
go.mod

@ -10,7 +10,7 @@ require (
github.com/skeris/appInit v1.0.2
github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf
go.uber.org/zap v1.26.0
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240314111040-7ed859ef7876
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240314130853-653404d89b86
)
require (

2
go.sum

@ -193,5 +193,7 @@ penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240313164312-456
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240313164312-4560248259a0/go.mod h1:JgbH8cdAJBr3jx3BuY5nnuTyMdZ1XkRxo8a3w4Y3C0Y=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240314111040-7ed859ef7876 h1:875+tdI7KuftCn9hZer2p9vq88FX0gbAaHOeCy1n6T4=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240314111040-7ed859ef7876/go.mod h1:okduDAq0NVVDcM+TMyrd4mVXzBMeTzYI2B2/yi1sL1Y=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240314130853-653404d89b86 h1:XbYHPBbGoC3qycikcukM4zFKZIoR2lYGfJUyFANtwLs=
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240314130853-653404d89b86/go.mod h1:okduDAq0NVVDcM+TMyrd4mVXzBMeTzYI2B2/yi1sL1Y=
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240313165712-63460dc78d4f h1:bb6dpmEKUOA6XjNyW66A8lPNRl4pISrZ2q/7J0C3mkk=
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240313165712-63460dc78d4f/go.mod h1:1L60BR27jRadx5JtRKZHYPM5Lilz5Yg+geFSgY7eCnM=

@ -233,6 +233,13 @@ func (s *Service) PutAnswersOnePiece(c *fiber.Ctx) error {
errs []error
)
deviceType := c.Get("DeviceType")
device := c.Get("Device")
os := c.Get("OS")
browser := c.Get("Browser")
ip := c.IP()
fingerprint := c.Cookies(fingerprintCookie)
if err := json.Unmarshal([]byte(answersStr[0]), &answersRaw); err != nil {
return c.Status(fiber.StatusBadRequest).SendString("not valid answers string")
}
@ -255,6 +262,12 @@ func (s *Service) PutAnswersOnePiece(c *fiber.Ctx) error {
fileIDMap := make(map[uint64]string)
for _, ans := range answersRaw {
ans.DeviceType = deviceType
ans.Fingerprint = fingerprint
ans.Device = device
ans.OS = os
ans.Browser = browser
ans.IP = ip
if strings.HasPrefix(ans.Content, filePrefix) {
filekey := strings.TrimPrefix(ans.Content, filePrefix)
filenameparts := strings.Split(filekey, ".")