Skip to content

Commit

Permalink
consumable: Correct width and height reported in response. (#1459)
Browse files Browse the repository at this point in the history
Prebid Server now responds with the width and height specified in
the Bid Response from Consumable. Previously it would reuse the width
and height specified in the Bid Request. That older behaviour was
ported from an older version of the prebid.js adapter but is no longer
valid.
  • Loading branch information
djcsdy committed Aug 27, 2020
1 parent ceaf883 commit 1c9b521
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions adapters/consumable/consumable.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type decision struct {
CreativeID string `json:"creativeId,omitempty"`
Contents []contents `json:"contents"`
ImpressionUrl *string `json:"impressionUrl,omitempty"`
Width uint64 `json:"width,omitempty"` // Consumable extension, not defined by Adzerk
Height uint64 `json:"height,omitempty"` // Consumable extension, not defined by Adzerk
}

type contents struct {
Expand Down Expand Up @@ -241,23 +243,13 @@ func (a *ConsumableAdapter) MakeBids(
for impID, decision := range serverResponse.Decisions {

if decision.Pricing != nil && decision.Pricing.ClearPrice != nil {

imp := getImp(impID, internalRequest.Imp)
if imp == nil {
errors = append(errors, &errortypes.BadServerResponse{
Message: fmt.Sprintf(
"ignoring bid id=%s, request doesn't contain any impression with id=%s", internalRequest.ID, impID),
})
continue
}

bid := openrtb.Bid{}
bid.ID = internalRequest.ID
bid.ImpID = impID
bid.Price = *decision.Pricing.ClearPrice
bid.AdM = retrieveAd(decision)
bid.W = imp.Banner.Format[0].W // TODO: Review to check if this is correct behaviour
bid.H = imp.Banner.Format[0].H
bid.W = decision.Width
bid.H = decision.Height
bid.CrID = strconv.FormatInt(decision.AdID, 10)
bid.Exp = 30 // TODO: Check this is intention of TTL

Expand All @@ -279,15 +271,6 @@ func (a *ConsumableAdapter) MakeBids(
return bidderResponse, errors
}

func getImp(impId string, imps []openrtb.Imp) *openrtb.Imp {
for _, imp := range imps {
if imp.ID == impId {
return &imp
}
}
return nil
}

func extractExtensions(impression openrtb.Imp) (*adapters.ExtImpBidder, *openrtb_ext.ExtImpConsumable, []error) {
var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(impression.Ext, &bidderExt); err != nil {
Expand Down

0 comments on commit 1c9b521

Please sign in to comment.