Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huaweiads: Remove empty image assets from response #3308

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Comment on lines +1181 to +1183
Copy link
Contributor

@onkarvhanumante onkarvhanumante Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmetfaruk59 could you help to explain how this change bind the number of main image objects from huaweiads instead of all main image objects in the request

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @onkarvhanumante. Previously all assets for main image type in the request were included in the response. Now only the main images returned from the huaweiads service are returned as a response. in the mentioned condition block, imgIndex is for making sure that all returned ads from huaweiads are binded to response and the type of the asset is main image type3. after all image assets from the service is binded then "continue" for other image main assets in the request
Previous:
request: "{assets:[
{required:0,title:{len:90}},
{required:0,img:{type:1,w:20,wmin:20,h:20,hmin:20}},
{required:0,img:{type:3,w:300,wmin:300,h:250,hmin:250}},
{required:0,img:{type:3,w:640,wmin:640,h:360,hmin:360}},
{required:0,img:{type:3,w:1312,wmin:1080,h:607,hmin:768}},
...
...
]}
response
assets:[
{id:0,title:{text:"Jewel Blast Legend",len:18}},
{id:2,img:{type:1,url:"image1.png",w:20,h:20}},
{id:2,img:{type:3,url:"image2.png",w:1080,h:607}},
{id:3,img:{type:3,url: " " ,w:300,h:250}},
{id:4,img:{type:3,url: " " ,w:320,h:250}},
{id:5,img:{type:3,url: "" ,w:1312,h:768}},
.
.
.
]

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
Loading