Skip to content

Commit

Permalink
Huaweiads: Remove empty image assets from response (#3308)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetfaruk59 authored Nov 23, 2023
1 parent 54039e9 commit 6f5b03e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
5 changes: 4 additions & 1 deletion adapters/huaweiads/huaweiads.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func getNativeFormat(adslot30 *adslot30, openRTBImp *openrtb2.Imp) error {
}

//popular size for native ads
popularSizes := []map[string]int64{{"w": 225, "h": 150}, {"w": 300, "h": 250}, {"w": 320, "h": 250}, {"w": 640, "h": 360}, {"w": 720, "h": 1280}, {"w": 1080, "h": 170}, {"w": 1080, "h": 430}, {"w": 1080, "h": 432}, {"w": 1080, "h": 504}, {"w": 1080, "h": 607}, {"w": 1080, "h": 1620}, {"w": 1200, "h": 627}, {"w": 1280, "h": 720}, {"w": 1312, "h": 768}, {"w": 1920, "h": 1080}}
popularSizes := []map[string]int64{{"w": 225, "h": 150}, {"w": 300, "h": 250}, {"w": 320, "h": 250}, {"w": 640, "h": 360}, {"w": 1080, "h": 170}, {"w": 1080, "h": 430}, {"w": 1080, "h": 432}, {"w": 1080, "h": 504}, {"w": 1080, "h": 607}, {"w": 1080, "h": 1620}, {"w": 1200, "h": 627}, {"w": 1280, "h": 720}, {"w": 1312, "h": 768}, {"w": 1920, "h": 1080}}

// only compute the main image number, type = native1.ImageAssetTypeMain
var numMainImage = 0
Expand Down Expand Up @@ -1178,6 +1178,9 @@ func (a *adapter) extractAdmNative(adType int32, content *content, bidType openr
}
responseAsset.Video = &videoObject
} else if asset.Img != nil {
if len(content.MetaData.ImageInfo) == imgIndex && asset.Img.Type == native1.ImageAssetTypeMain {
continue
}
var imgObject nativeResponse.Image
imgObject.URL = ""
imgObject.Type = asset.Img.Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"901",
"905"
],
"format":[{"w":225,"h":150},{"w":300,"h":250},{"w":320,"h":250},{"w":640,"h":360},{"w":720,"h":1280},{"w":1080,"h":170},{"w":1080,"h":430},{"w":1080,"h":432},{"w":1080,"h":504},{"w":1080,"h":607},{"w":1080,"h":1620},{"w":1200,"h":627},{"w":1280,"h":720},{"w":1312,"h":768},{"w":1920,"h":1080}],
"format":[{"w":225,"h":150},{"w":300,"h":250},{"w":320,"h":250},{"w":640,"h":360},{"w":1080,"h":170},{"w":1080,"h":430},{"w":1080,"h":432},{"w":1080,"h":504},{"w":1080,"h":607},{"w":1080,"h":1620},{"w":1200,"h":627},{"w":1280,"h":720},{"w":1312,"h":768},{"w":1920,"h":1080}],
"test": 1
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@
"w": 640,
"h": 360
},
{
"w": 720,
"h": 1280
},
{
"w": 1080,
"h": 170
Expand Down Expand Up @@ -244,11 +240,11 @@
"imageInfo": [
{
"checkSha256Flag": 0,
"height": 1280,
"height": 150,
"imageType": "img",
"sha256": "8baa56fdb2702b9fb044d95b328936160cd245764375cdb25a4ab504f4ae2e19",
"url": "http://image.jpg",
"width": 720
"width": 225
}
],
"label": "%E6%89%8B%E6%9C%BA%E6%B7%98%E5%AE%9D",
Expand Down Expand Up @@ -362,12 +358,12 @@
"huaweiads"
],
"crid": "58022259",
"adm": "{\"ver\":\"1.2\",\"assets\":[{\"id\":101,\"title\":{\"text\":\"/test/\",\"len\":6}},{\"id\":102,\"img\":{\"type\":3,\"url\":\"http://image.jpg\",\"w\":720,\"h\":1280}},{\"id\":103,\"data\":{\"label\":\"desc\",\"value\":\"\"}},{\"id\":105,\"data\":{\"type\":12,\"value\":\"install\"}}],\"link\":{\"url\":\"https://ads.huawei.com/usermgtportal/home/index.html#/\",\"clicktrackers\":[\"http://test/click\"]},\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://test/imp\"}]}",
"adm": "{\"ver\":\"1.2\",\"assets\":[{\"id\":101,\"title\":{\"text\":\"/test/\",\"len\":6}},{\"id\":102,\"img\":{\"type\":3,\"url\":\"http://image.jpg\",\"w\":225,\"h\":150}},{\"id\":103,\"data\":{\"label\":\"desc\",\"value\":\"\"}},{\"id\":105,\"data\":{\"type\":12,\"value\":\"install\"}}],\"link\":{\"url\":\"https://ads.huawei.com/usermgtportal/home/index.html#/\",\"clicktrackers\":[\"http://test/click\"]},\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://test/imp\"}]}",
"id": "test-imp-id",
"impid": "test-imp-id",
"price": 2.8,
"h": 1280,
"w": 720
"h": 150,
"w": 225
},
"type": "native"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@
"w": 640,
"h": 360
},
{
"w": 720,
"h": 1280
},
{
"w": 1080,
"h": 170
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@
"w": 640,
"h": 360
},
{
"w": 720,
"h": 1280
},
{
"w": 1080,
"h": 170
Expand Down

0 comments on commit 6f5b03e

Please sign in to comment.