Skip to content

Commit

Permalink
Merge pull request #38 from Financial-Times/fix/UPPSF-1328-thumbnail-…
Browse files Browse the repository at this point in the history
…url-spark-es

Fix/uppsf 1328 thumbnail url spark es
  • Loading branch information
rnov committed May 14, 2020
2 parents 5015804 + 0856a38 commit d98e3ed
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 56 deletions.
17 changes: 16 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
- run:
name: External dependencies
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
GO111MODULE=off go get -u github.com/mattn/goveralls
GO111MODULE=off go get -u github.com/jstemmer/go-junit-report
GO111MODULE=off go get -u github.com/myitcv/gobin
Expand All @@ -31,6 +33,8 @@ jobs:
- run:
name: Go build
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
go generate ./cmd/content-rw-elasticsearch
go build -mod=readonly -v ./cmd/content-rw-elasticsearch
- run:
Expand All @@ -53,20 +57,24 @@ jobs:
- setup_remote_docker
- run:
name: Build Dockerfile
command: docker build .
command: docker build --build-arg GITHUB_USERNAME="$GITHUB_USERNAME" --build-arg GITHUB_TOKEN="$GITHUB_TOKEN" .
dredd:
working_directory: /go/src/github.com/Financial-Times/content-rw-elasticsearch
docker:
- image: golang:1
environment:
GOPATH: /go
ELASTICSEARCH_SAPI_ENDPOINT: http://localhost:9000
GITHUB_USERNAME: ${GITHUB_USERNAME}
GITHUB_TOKEN: ${GITHUB_TOKEN}
- image: peteclarkft/ersatz:stable
steps:
- checkout
- run:
name: Download dredd
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
curl -sL https://deb.nodesource.com/setup_11.x | bash -
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs=11.\*
npm install -g --unsafe-perm --loglevel warn --user 0 --no-progress dredd@11.2.19
Expand All @@ -80,6 +88,8 @@ jobs:
- run:
name: Go Build
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
go generate ./cmd/content-rw-elasticsearch
go build -mod=readonly -v ./cmd/content-rw-elasticsearch
- run:
Expand All @@ -91,6 +101,11 @@ jobs:
- image: circleci/golang:1
steps:
- checkout
- run:
name: Github private config
command: |
GOPRIVATE="github.com/Financial-Times"
git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
- snyk/scan:
monitor-on-build: false
severity-threshold: medium
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ ENV ORG_PATH="github.com/Financial-Times"
ENV SRC_FOLDER="${GOPATH}/src/${ORG_PATH}/${PROJECT}"
ENV BUILDINFO_PACKAGE="${ORG_PATH}/service-status-go/buildinfo."

ARG GITHUB_USERNAME
ARG GITHUB_TOKEN

COPY . ${SRC_FOLDER}
WORKDIR ${SRC_FOLDER}

# Install statik cli tool in GOPATH in order to successfully execute the go generate command
RUN GO111MODULE=off go get -u github.com/myitcv/gobin \
RUN echo "machine github.com login $GITHUB_USERNAME password $GITHUB_TOKEN" > ~/.netrc \
&& GOPRIVATE="github.com/Financial-Times" \
&& GO111MODULE=off go get -u github.com/myitcv/gobin \
# Get statik version from go.mod of the project
&& STATIK_VERSION="$(go list -mod=readonly -m all | grep statik | cut -d ' ' -f2)" \
&& gobin github.com/rakyll/statik@${STATIK_VERSION} \
Expand Down
37 changes: 34 additions & 3 deletions cmd/content-rw-elasticsearch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ import (
"os"
"time"

cli "github.com/jawher/mow.cli"

"github.com/Financial-Times/go-logger/v2"
"github.com/Financial-Times/message-queue-gonsumer/consumer"
"github.com/Financial-Times/upp-go-sdk/pkg/api"
"github.com/Financial-Times/upp-go-sdk/pkg/internalcontent"

"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/concept"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/config"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/es"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/health"
pkghttp "github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/http"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/mapper"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/message"
"github.com/Financial-Times/go-logger/v2"
"github.com/Financial-Times/message-queue-gonsumer/consumer"
"github.com/jawher/mow.cli"
)

func main() {
Expand Down Expand Up @@ -111,6 +115,27 @@ func main() {
EnvVar: "BASE_API_URL",
})

internalContentAPIURL := app.String(cli.StringOpt{
Name: "internal-content-api-url",
Value: "http://internal-content-api:8080",
Desc: "URL of the API uses to retrieve lists data from",
EnvVar: "INTERNAL_CONTENT_API_URL",
})

apiBasicAuthUsername := app.String(cli.StringOpt{
Name: "api-basic-auth-user",
Value: "",
Desc: "API Basic Auth username",
EnvVar: "API_BASIC_USER",
})

apiBasicAuthPassword := app.String(cli.StringOpt{
Name: "api-basic-auth-pass",
Value: "",
Desc: "API Basic Auth password",
EnvVar: "API_BASIC_PASS",
})

queueConfig := consumer.QueueConfig{
Addrs: []string{*kafkaProxyAddress},
Group: *kafkaConsumerGroup,
Expand Down Expand Up @@ -140,11 +165,17 @@ func main() {

concordanceAPIService := concept.NewConcordanceAPIService(*publicConcordancesEndpoint, httpClient)

// initialize apiClient
internalAPIConfig := api.NewConfig(*internalContentAPIURL, *apiBasicAuthUsername, *apiBasicAuthPassword)
internalContentAPIClient := api.NewClient(*internalAPIConfig, httpClient)
internalContentClient := internalcontent.NewContentClient(internalContentAPIClient, internalcontent.URLInternalContent)

mapperHandler := mapper.NewMapperHandler(
concordanceAPIService,
*baseAPIUrl,
appConfig,
log,
internalContentClient,
)

handler := message.NewMessageHandler(
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/Financial-Times/message-queue-gonsumer v0.0.0-20180518165041-cd41937c7566
github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d
github.com/Financial-Times/transactionid-utils-go v0.2.0
github.com/Financial-Times/uuid-utils-go v0.0.0-20170516110427-e22658edd0f1
github.com/Financial-Times/upp-go-sdk v0.0.7
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.6.2
Expand All @@ -19,8 +19,7 @@ require (
github.com/smartystreets/go-aws-auth v0.0.0-20170504205021-8ef1316913ee
github.com/smartystreets/gunit v1.1.3 // indirect
github.com/spf13/viper v1.6.2
github.com/stretchr/testify v1.2.2
github.com/willf/bitset v1.1.2 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e // indirect
gopkg.in/olivere/elastic.v2 v2.0.61
)
13 changes: 9 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d
github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d/go.mod h1:7zULC9rrq6KxFkpB3Y5zNVaEwrf1g2m3dvXJBPDXyvM=
github.com/Financial-Times/transactionid-utils-go v0.2.0 h1:YcET5Hd1fUGWWpQSVszYUlAc15ca8tmjRetUuQKRqEQ=
github.com/Financial-Times/transactionid-utils-go v0.2.0/go.mod h1:tPAcAFs/dR6Q7hBDGNyUyixHRvg/n9NW/JTq8C58oZ0=
github.com/Financial-Times/uuid-utils-go v0.0.0-20170516110427-e22658edd0f1 h1:FXM7cqqPyGh2QZ8BRJA16Gr65/+/91KEFSPKyRM+Nd8=
github.com/Financial-Times/uuid-utils-go v0.0.0-20170516110427-e22658edd0f1/go.mod h1:i62wLwNq+NmRCQpZS5BLTKsOVYsTOxs9bSx7FgtxXwM=
github.com/Financial-Times/upp-go-sdk v0.0.7 h1:SzF7gvABbYuHGjNl4Macv4fHF1CSrUBByQSHogiQk9I=
github.com/Financial-Times/upp-go-sdk v0.0.7/go.mod h1:1/Dnsqf8FQ0yOHKG8d/eM3X7rCeqDK4pouCFtp9pdmo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand All @@ -27,6 +27,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/davecgh/go-spew v0.0.0-20170829195320-a47672248388/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
Expand All @@ -50,6 +51,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
Expand Down Expand Up @@ -134,17 +136,18 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E=
github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v0.0.0-20170809224252-890a5c3458b4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/willf/bitset v1.1.2 h1:qRQzojujJ9p4JrdmSxeu3hn348shKWovBYAQth9NoTg=
github.com/willf/bitset v1.1.2/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down Expand Up @@ -185,6 +188,7 @@ golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand All @@ -205,6 +209,7 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ env:
KAFKA_TOPIC: ForcedCombinedPostPublicationEvents
KAFKA_CONCURRENT_PROCESSING: true
PUBLIC_CONCORDANCES_ENDPOINT: http://public-concordances-api:8080
INTERNAL_CONTENT_API_URL: http://internal-content-api:8080
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ env:
KAFKA_TOPIC: CombinedPostPublicationEvents
KAFKA_CONCURRENT_PROCESSING: false
PUBLIC_CONCORDANCES_ENDPOINT: http://public-concordances-api:8080
INTERNAL_CONTENT_API_URL: http://internal-content-api:8080
2 changes: 2 additions & 0 deletions helm/content-rw-elasticsearch/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ spec:
key: aws.secret_access_key
- name: PUBLIC_CONCORDANCES_ENDPOINT
value: "{{ .Values.env.PUBLIC_CONCORDANCES_ENDPOINT }}"
- name: INTERNAL_CONTENT_API_URL
value: "{{ .Values.env.INTERNAL_CONTENT_API_URL }}"
- name: "BASE_API_URL"
valueFrom:
configMapKeyRef:
Expand Down
1 change: 1 addition & 0 deletions helm/content-rw-elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ env:
KAFKA_TOPIC: ""
KAFKA_CONCURRENT_PROCESSING: ""
PUBLIC_CONCORDANCES_ENDPOINT: ""
INTERNAL_CONTENT_API_URL: ""
54 changes: 27 additions & 27 deletions pkg/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package mapper
import (
"encoding/base64"
"errors"
"fmt"
"strings"
"time"

"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/config"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/schema"

"fmt"
"github.com/Financial-Times/go-logger/v2"
"github.com/Financial-Times/upp-go-sdk/pkg/internalcontent"

"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/concept"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/config"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/html"
"github.com/Financial-Times/go-logger/v2"
"github.com/Financial-Times/uuid-utils-go"
"github.com/Financial-Times/content-rw-elasticsearch/v2/pkg/schema"
)

const (
Expand All @@ -33,20 +32,22 @@ const (
)

type Handler struct {
ConceptReader concept.Reader
BaseAPIURL string
Config config.AppConfig
log *logger.UPPLogger
ConceptReader concept.Reader
BaseAPIURL string
Config config.AppConfig
log *logger.UPPLogger
internalClient *internalcontent.ContentClient
}

var errNoAnnotation = errors.New("no annotation to be processed")

func NewMapperHandler(reader concept.Reader, baseAPIURL string, appConfig config.AppConfig, logger *logger.UPPLogger) *Handler {
func NewMapperHandler(reader concept.Reader, baseAPIURL string, appConfig config.AppConfig, logger *logger.UPPLogger, internalClient *internalcontent.ContentClient) *Handler {
return &Handler{
ConceptReader: reader,
BaseAPIURL: baseAPIURL,
Config: appConfig,
log: logger,
ConceptReader: reader,
BaseAPIURL: baseAPIURL,
Config: appConfig,
log: logger,
internalClient: internalClient,
}
}

Expand Down Expand Up @@ -218,21 +219,20 @@ func (h *Handler) populateContentRelatedFields(model *schema.IndexModel, enriche
if contentType != config.BlogType && enrichedContent.Content.MainImage != "" {
model.ThumbnailURL = new(string)

var imageID *uuidutils.UUID

// Generate the actual image UUID from the received image set UUID
imageSetUUID, err := uuidutils.NewUUIDFromString(enrichedContent.Content.MainImage)
if err == nil {
imageID, err = uuidutils.NewUUIDDeriverWith(uuidutils.IMAGE_SET).From(imageSetUUID)
}

log := h.log.WithTransactionID(tid).WithUUID(enrichedContent.UUID)
if err != nil {
log.WithError(err).Warnf("Couldn't generate image uuid for the image set with uuid %s: image field won't be populated.", enrichedContent.Content.MainImage)

ic, err := h.internalClient.GetContent(enrichedContent.UUID, true)
if err != nil || len(ic.MainImage.Members) == 0 || ic.MainImage.Members[0].APIURL == "" {
log.WithError(err).Warnf("Couldn't get image UUID from %s", internalcontent.URLInternalContent)
} else {
*model.ThumbnailURL = strings.Replace(imageServiceURL, imagePlaceholder, imageID.String(), -1)
uris := strings.Split(ic.MainImage.Members[0].APIURL, "/")
if len(uris) > 0 {
imageUUID := uris[len(uris)-1]
*model.ThumbnailURL = strings.Replace(imageServiceURL, imagePlaceholder, imageUUID, -1)
} else {
log.WithError(err).Warnf("Couldn't get image UUID from %s", internalcontent.URLInternalContent)
}
}

}

if contentType == config.VideoType && len(enrichedContent.Content.DataSources) > 0 {
Expand Down
Loading

0 comments on commit d98e3ed

Please sign in to comment.