Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Fixes audienceNetwork adapter ignoring banner.format sizes. (prebid#1164
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hhhjort authored and SyntaxNode committed Jan 14, 2020
1 parent 1ca35c6 commit 0f114fe
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"mockBidRequest": {
"id": "test-req-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 640,
"h": 480
},
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"publisherid": "123",
"placementid": "456"
}
}
}
],
"site": {
"domain": "prebid.org",
"page": "prebid.org"
},
"device": {
"ip": "152.193.6.74"
},
"user": {
"id": "db089de9-a62e-4861-a881-0ff15e052516",
"buyeruid": "v4_bidder_token"
},
"tmax": 500
},
"httpcalls": [
{
"expectedRequest": {
"uri": "https://an.facebook.com/placementbid.ortb",
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json;charset=utf-8"
],
"X-Fb-Pool-Routing-Token": [
"v4_bidder_token"
]
},
"body": {
"id": "test-req-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"w": -1,
"h": 250
},
"tagid": "123_456"
}
],
"ext": {
"appnexus": {
"hb_source": 5
},
"prebid": {}
},
"site": {
"domain": "prebid.org",
"page": "prebid.org",
"publisher": {
"id": "123"
}
},
"device": {
"ip": "152.193.6.74"
},
"user": {
"id": "db089de9-a62e-4861-a881-0ff15e052516",
"buyeruid": "v4_bidder_token"
},
"tmax": 500,
"ext": {
"authentication_id": "b2f9edfd707106adb6b692520081ad7e2a345444af1a895310228297a1b6247e",
"platformid": "test-platform-id"
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-req-id",
"seatbid": [
{
"bid": [
{
"id": "987",
"impid": "test-imp-id",
"price": 1.000000,
"adm": "{\"type\":\"ID\",\"bid_id\":\"987\",\"placement_id\":\"123_456\",\"resolved_placement_id\":\"123_456\",\"sdk_version\":\"5.5.0\",\"device_id\":\"abc\",\"template\":1,\"payload\":null,\"bid_time_token\":\"v4_bidder_token=\"}",
"nurl": "https://www.facebook.com/audiencenetwork/nurl/?partner=test-platform-id&app=def&placement=456&auction=123&impression=123&request=123478&bid=987&ortb_loss_code=0&clearing_price=${AUCTION_PRICE}&app_version=iOS-1.0",
"lurl": "https://www.facebook.com/audiencenetwork/nurl/?partner=test-platform-id&app=def&placement=456&auction=123&impression=123&request=123478&bid=987&ortb_loss_code=${AUCTION_LOSS}&clearing_price=${AUCTION_PRICE}&app_version=iOS-1.0",
"burl": "https://www.facebook.com/audiencenetwork/burl/?partner=test-platform-id&app=def&placement=456&auction=123&impression=123&request=123478&bid=987&clearing_price=${AUCTION_PRICE}"
}
]
}
],
"bidid": "654",
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "987",
"impid": "test-imp-id",
"price": 1,
"adm": "{\"type\":\"ID\",\"bid_id\":\"987\",\"placement_id\":\"123_456\",\"resolved_placement_id\":\"123_456\",\"sdk_version\":\"5.5.0\",\"device_id\":\"abc\",\"template\":1,\"payload\":null,\"bid_time_token\":\"v4_bidder_token=\"}",
"adid": "987",
"crid": "987",
"nurl": "https://www.facebook.com/audiencenetwork/nurl/?partner=test-platform-id&app=def&placement=456&auction=123&impression=123&request=123478&bid=987&ortb_loss_code=0&clearing_price=${AUCTION_PRICE}&app_version=iOS-1.0",
"lurl": "https://www.facebook.com/audiencenetwork/nurl/?partner=test-platform-id&app=def&placement=456&auction=123&impression=123&request=123478&bid=987&ortb_loss_code=${AUCTION_LOSS}&clearing_price=${AUCTION_PRICE}&app_version=iOS-1.0",
"burl": "https://www.facebook.com/audiencenetwork/burl/?partner=test-platform-id&app=def&placement=456&auction=123&impression=123&request=123478&bid=987&clearing_price=${AUCTION_PRICE}"
},
"type": "banner"
}
]
}
]
}
13 changes: 11 additions & 2 deletions adapters/audienceNetwork/facebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,17 @@ func (this *FacebookAdapter) modifyImp(out *openrtb.Imp) error {
}

if out.Banner.H == nil {
return &errortypes.BadInput{
Message: fmt.Sprintf("imp #%s: banner height required", out.ID),
for _, f := range out.Banner.Format {
if _, ok := supportedBannerHeights[f.H]; ok {
h := f.H
out.Banner.H = &h
break
}
}
if out.Banner.H == nil {
return &errortypes.BadInput{
Message: fmt.Sprintf("imp #%s: banner height required", out.ID),
}
}
}

Expand Down

0 comments on commit 0f114fe

Please sign in to comment.