Skip to content

Commit

Permalink
Get image ID from APIURL instead of ID. Removed unused fields from sc…
Browse files Browse the repository at this point in the history
…hema.
  • Loading branch information
vstanchev committed Jan 25, 2022
1 parent 09f2232 commit 6af9f47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
8 changes: 4 additions & 4 deletions pkg/mapper/mapper.go
Expand Up @@ -221,15 +221,15 @@ func (h *Handler) populateContentRelatedFields(model *schema.IndexModel, enriche

log := h.log.WithTransactionID(tid).WithUUID(enrichedContent.UUID)

if len(enrichedContent.InternalContent.MainImage.Members) == 0 || enrichedContent.InternalContent.MainImage.Members[0].ID == "" {
log.Warnf("Main image is not present or with empty ID.")
if len(enrichedContent.InternalContent.MainImage.Members) == 0 || enrichedContent.InternalContent.MainImage.Members[0].APIURL == "" {
log.Warnf("Main image is not present or with empty apiUrl.")
} else {
uris := strings.Split(enrichedContent.InternalContent.MainImage.Members[0].ID, "/")
uris := strings.Split(enrichedContent.InternalContent.MainImage.Members[0].APIURL, "/")
if len(uris) > 0 {
imageUUID := uris[len(uris)-1]
*model.ThumbnailURL = strings.Replace(imageServiceURL, imagePlaceholder, imageUUID, -1)
} else {
log.Warnf("Couldn't get image UUID from ID %q", enrichedContent.InternalContent.MainImage.Members[0].ID)
log.Warnf("Couldn't get image UUID from apiUrl %q", enrichedContent.InternalContent.MainImage.Members[0].APIURL)
}
}
}
Expand Down
14 changes: 1 addition & 13 deletions pkg/schema/schema.go
Expand Up @@ -161,17 +161,5 @@ type ImageSet struct {
}

type Member struct {
ID string `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
BinaryURL string `json:"binaryUrl"`
Description string `json:"description"`
CanBeSyndicated string `json:"canBeSyndicated"`
CanBeDistributed string `json:"canBeDistributed"`
RightsGroup string `json:"rightsGroup"`
Copyright struct {
Notice string `json:"notice"`
} `json:"copyright"`
MaxDisplayWidth string `json:"maxDisplayWidth"`
MinDisplayWidth string `json:"minDisplayWidth"`
APIURL string `json:"apiUrl"`
}

0 comments on commit 6af9f47

Please sign in to comment.