add images

This commit is contained in:
2026-07-24 00:49:37 +07:00
parent ea236027db
commit 871331f14d
3 changed files with 8 additions and 3 deletions
@@ -25,7 +25,7 @@ func mapScenario(
o *repos.Scenario,
domain string,
) (*Scenario, error) {
story, err := mapStory(o.Scenario)
story, err := mapStory(o.Scenario, domain)
if err != nil {
return nil, err
}
@@ -44,11 +44,16 @@ func mapScenario(
}, nil
}
func mapStory(o string) (*storytelling.Story, error) {
func mapStory(o string, domain string) (*storytelling.Story, error) {
res := &storytelling.Story{}
if err := json.Unmarshal([]byte(o), res); err != nil {
return nil, err
}
for _, place := range res.Places {
if place.Image != "" {
place.Image = domain + place.Image
}
}
return res, nil
}
@@ -131,7 +131,7 @@ func (s *ScenarioService) getStory(ctx context.Context, id int) (*storytelling.S
if err != nil {
return nil, err
}
return mapStory(storyString)
return mapStory(storyString, s.domain)
}
func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storytelling.Story) error {