Skip to content

Commit

Permalink
Huawei Ads: fix cta text empty and fill rate issue (#3070)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetfaruk59 authored Sep 7, 2023
1 parent 9eea8d0 commit d6bca29
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 28 deletions.
18 changes: 7 additions & 11 deletions adapters/huaweiads/huaweiads.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ type metaData struct {
ApkInfo apkInfo `json:"apkInfo"`
Duration int64 `json:"duration"`
MediaFile mediaFile `json:"mediaFile"`
Cta string `json:"cta"`
}

type imageInfo struct {
Expand Down Expand Up @@ -535,8 +536,7 @@ func getNativeFormat(adslot30 *adslot30, openRTBImp *openrtb2.Imp) error {
// only compute the main image number, type = native1.ImageAssetTypeMain
var numMainImage = 0
var numVideo = 0
var width int64
var height int64

for _, asset := range nativePayload.Assets {
// Only one of the {title,img,video,data} objects should be present in each object.
if asset.Video != nil {
Expand All @@ -547,19 +547,10 @@ func getNativeFormat(adslot30 *adslot30, openRTBImp *openrtb2.Imp) error {
if asset.Img != nil {
if asset.Img.Type == native1.ImageAssetTypeMain {
numMainImage++
if asset.Img.H != 0 && asset.Img.W != 0 {
width = asset.Img.W
height = asset.Img.H
} else if asset.Img.WMin != 0 && asset.Img.HMin != 0 {
width = asset.Img.WMin
height = asset.Img.HMin
}
}
continue
}
}
adslot30.W = width
adslot30.H = height

var detailedCreativeTypeList = make([]string, 0, 2)
if numVideo >= 1 {
Expand Down Expand Up @@ -1169,6 +1160,11 @@ func (a *adapter) extractAdmNative(adType int32, content *content, bidType openr
dataObject.Label = "desc"
dataObject.Value = getDecodeValue(content.MetaData.Description)
}

if asset.Data.Type == native1.DataAssetTypeCTAText {
dataObject.Type = native1.DataAssetTypeCTAText
dataObject.Value = getDecodeValue(content.MetaData.Cta)
}
responseAsset.Data = &dataObject
}
var id = asset.ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@
"detailedCreativeTypeList": [
"903"
],
"h": 200,
"test": 1,
"w": 200
"test": 1
}
],
"device": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"id": "test-imp-id",
"native": {
"request": "{\"context\":2,\"contextsubtype\":20,\"plcmttype\":1,\"plcmtcnt\":1,\"seq\":0,\"aurlsupport\":0,\"durlsupport\":0,\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}],\"privacy\":0,\"assets\":[{\"id\":100,\"title\":{\"len\":90},\"required\":1},{\"id\":103,\"img\":{\"type\":3,\"wmin\":200,\"hmin\":200},\"required\":1},{\"id\":105,\"data\":{\"type\":2,\"len\":90},\"required\":1}],\"ver\":\"1.2\"}",
"request": "{\"context\":2,\"contextsubtype\":20,\"plcmttype\":1,\"plcmtcnt\":1,\"seq\":0,\"aurlsupport\":0,\"durlsupport\":0,\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}],\"privacy\":0,\"assets\":[{\"id\":101,\"title\":{\"len\":90},\"required\":1},{\"id\":102,\"img\":{\"type\":3,\"wmin\":200,\"hmin\":200},\"required\":1},{\"id\":103,\"data\":{\"type\":2,\"len\":90},\"required\":1},{\"id\":105,\"data\":{\"type\":12,\"len\":90}}],\"ver\":\"1.2\"}",
"ver": "1.2"
},
"ext": {
Expand Down Expand Up @@ -93,9 +93,7 @@
"detailedCreativeTypeList": [
"901"
],
"h": 200,
"test": 1,
"w": 200
"test": 1
}
],
"device": {
Expand Down Expand Up @@ -166,6 +164,7 @@
"appId": "101219405",
"appPromotionChannel": "401721412",
"clickUrl": "https://ads.huawei.com/usermgtportal/home/index.html#/",
"cta": "install",
"duration": 6038,
"description": "",
"icon": [
Expand Down Expand Up @@ -300,7 +299,7 @@
"huaweiads"
],
"crid": "58022259",
"adm": "{\"ver\":\"1.2\",\"assets\":[{\"id\":100,\"title\":{\"text\":\"/test/\",\"len\":6}},{\"id\":103,\"img\":{\"type\":3,\"url\":\"http://image.jpg\",\"w\":720,\"h\":1280}},{\"id\":105,\"data\":{\"label\":\"desc\",\"value\":\"\"}}],\"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\":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\"}]}",
"id": "test-imp-id",
"impid": "test-imp-id",
"price": 2.8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
"detailedCreativeTypeList": [
"904"
],
"h": 200,
"test": 1,
"w": 200
"test": 1
}
],
"device": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@
"detailedCreativeTypeList": [
"904"
],
"h": 200,
"test": 1,
"w": 200
"test": 1
}
],
"device": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@
"test": 1,
"detailedCreativeTypeList": [
"903"
],
"h": 200,
"w": 200
]
}
],
"device": {
Expand Down

0 comments on commit d6bca29

Please sign in to comment.