Skip to content

Commit

Permalink
bid.mtype takes precedence to bid.ext.prebid.type
Browse files Browse the repository at this point in the history
  • Loading branch information
vsolovei committed Mar 6, 2023
1 parent c67d486 commit 0214cba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
13 changes: 10 additions & 3 deletions exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -1314,9 +1314,16 @@ func buildStoredAuctionResponse(storedAuctionResponses map[string]json.RawMessag
//set imp id from request
for i := range seat.Bid {
seat.Bid[i].ImpID = impId
bidType, err := getMediaTypeForBid(seat.Bid[i])
if err != nil {
return nil, nil, nil, err
mType := seat.Bid[i].MType
var bidType openrtb_ext.BidType
if mType != 0 {
bidType = openrtb_ext.BidTypes()[mType-1]
} else {
var err error
bidType, err = getMediaTypeForBid(seat.Bid[i])
if err != nil {
return nil, nil, nil, err
}
}
bidsToAdd = append(bidsToAdd, &entities.PbsOrtbBid{Bid: &seat.Bid[i], BidType: bidType})
}
Expand Down
21 changes: 21 additions & 0 deletions exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4125,6 +4125,27 @@ func TestBuildStoredAuctionResponses(t *testing.T) {
},
},
},
{
desc: "Single imp with single stored response bid with bid.mtype",
in: testIn{
StoredAuctionResponses: map[string]json.RawMessage{
"impression-id": json.RawMessage(`[{"bid": [{"id": "bid_id", "mtype": 2, "ext": {"prebid": {"type": "native"}}}],"seat": "appnexus"}]`),
},
},
expected: testResults{
adapterBids: map[openrtb_ext.BidderName]*entities.PbsOrtbSeatBid{
openrtb_ext.BidderName("appnexus"): {
Bids: []*entities.PbsOrtbBid{
{
Bid: &openrtb2.Bid{ID: "bid_id", ImpID: "impression-id", MType: 2, Ext: []byte(`{"prebid": {"type": "native"}}`)},
BidType: openrtb_ext.BidTypeVideo,
},
},
},
},
liveAdapters: []openrtb_ext.BidderName{openrtb_ext.BidderName("appnexus")},
},
},
}
for _, test := range testCases {

Expand Down

0 comments on commit 0214cba

Please sign in to comment.