🐛 Fix edit question panic
This commit is contained in:
parent
d8dabd002b
commit
748f442cbc
@ -207,7 +207,11 @@ func editQuestion(c *fiber.Ctx) error {
|
|||||||
item.PublishedAt = data.PublishedAt
|
item.PublishedAt = data.PublishedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
body := models.PostQuestionBody{
|
var body models.PostQuestionBody
|
||||||
|
raw, _ := jsoniter.Marshal(item.Body)
|
||||||
|
_ = jsoniter.Unmarshal(raw, &body)
|
||||||
|
|
||||||
|
newBody := models.PostQuestionBody{
|
||||||
PostStoryBody: models.PostStoryBody{
|
PostStoryBody: models.PostStoryBody{
|
||||||
Thumbnail: data.Thumbnail,
|
Thumbnail: data.Thumbnail,
|
||||||
Title: data.Title,
|
Title: data.Title,
|
||||||
@ -215,15 +219,15 @@ func editQuestion(c *fiber.Ctx) error {
|
|||||||
Location: data.Location,
|
Location: data.Location,
|
||||||
Attachments: data.Attachments,
|
Attachments: data.Attachments,
|
||||||
},
|
},
|
||||||
Reward: item.Body["reward"].(float64),
|
Reward: body.Reward,
|
||||||
}
|
}
|
||||||
|
|
||||||
var bodyMapping map[string]any
|
var newBodyMapping map[string]any
|
||||||
rawBody, _ := jsoniter.Marshal(body)
|
rawBody, _ := jsoniter.Marshal(newBody)
|
||||||
_ = jsoniter.Unmarshal(rawBody, &bodyMapping)
|
_ = jsoniter.Unmarshal(rawBody, &newBodyMapping)
|
||||||
|
|
||||||
item.Alias = data.Alias
|
item.Alias = data.Alias
|
||||||
item.Body = bodyMapping
|
item.Body = newBodyMapping
|
||||||
item.Language = services.DetectLanguage(data.Content)
|
item.Language = services.DetectLanguage(data.Content)
|
||||||
item.Tags = data.Tags
|
item.Tags = data.Tags
|
||||||
item.Categories = data.Categories
|
item.Categories = data.Categories
|
||||||
|
Loading…
x
Reference in New Issue
Block a user