Skip to content
Open
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
25 changes: 16 additions & 9 deletions exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ import (
)

type extCacheInstructions struct {
cacheBids, cacheVAST, returnCreative bool
cacheBids, cacheVAST bool
returnCreativeBids bool
returnCreativeVast bool
Comment on lines +50 to +52
Copy link

Choose a reason for hiding this comment

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

Massively not a concern but I'm curious why this and not e.g.

type extCacheInstructions struct {
	cacheBids          bool
	cacheVAST          bool
	returnCreativeBids bool
	returnCreativeVast bool
}

or

type extCacheInstructions struct {
	cacheBids, cacheVAST bool
	returnCreativeBids, returnCreativeVast bool
}

(but note that this is not a blocker)

}

// Exchange runs Auctions. Implementations must be threadsafe, and will be shared across many goroutines.
Expand Down Expand Up @@ -551,7 +553,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r *AuctionRequest, debugLog
e.bidValidationEnforcement.SetBannerCreativeMaxSize(r.Account.Validations)

// Build the response
bidResponse := e.buildBidResponse(ctx, liveAdapters, adapterBids, r.BidRequestWrapper, adapterExtra, auc, bidResponseExt, cacheInstructions.returnCreative, r.ImpExtInfoMap, r.PubID, errs, &seatNonBidBuilder)
bidResponse := e.buildBidResponse(ctx, liveAdapters, adapterBids, r.BidRequestWrapper, adapterExtra, auc, bidResponseExt, cacheInstructions, r.ImpExtInfoMap, r.PubID, errs, &seatNonBidBuilder)
bidResponse = adservertargeting.Apply(r.BidRequestWrapper, r.ResolvedBidRequest, bidResponse, r.QueryParams, bidResponseExt, r.Account.TruncateTargetAttribute)

bidResponse.Ext, err = encodeBidResponseExt(bidResponseExt)
Expand Down Expand Up @@ -993,7 +995,7 @@ func errsToBidderWarnings(errs []error) []openrtb_ext.ExtBidderMessage {
}

// This piece takes all the bids supplied by the adapters and crafts an openRTB response to send back to the requester
func (e *exchange) buildBidResponse(ctx context.Context, liveAdapters []openrtb_ext.BidderName, adapterSeatBids map[openrtb_ext.BidderName]*entities.PbsOrtbSeatBid, bidRequest *openrtb_ext.RequestWrapper, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, bidResponseExt *openrtb_ext.ExtBidResponse, returnCreative bool, impExtInfoMap map[string]ImpExtInfo, pubID string, errList []error, seatNonBidBuilder *SeatNonBidBuilder) *openrtb2.BidResponse {
func (e *exchange) buildBidResponse(ctx context.Context, liveAdapters []openrtb_ext.BidderName, adapterSeatBids map[openrtb_ext.BidderName]*entities.PbsOrtbSeatBid, bidRequest *openrtb_ext.RequestWrapper, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, bidResponseExt *openrtb_ext.ExtBidResponse, cacheInstructions extCacheInstructions, impExtInfoMap map[string]ImpExtInfo, pubID string, errList []error, seatNonBidBuilder *SeatNonBidBuilder) *openrtb2.BidResponse {
bidResponse := new(openrtb2.BidResponse)

bidResponse.ID = bidRequest.ID
Expand All @@ -1008,7 +1010,7 @@ func (e *exchange) buildBidResponse(ctx context.Context, liveAdapters []openrtb_
for a, adapterSeatBids := range adapterSeatBids {
//while processing every single bib, do we need to handle categories here?
if adapterSeatBids != nil && len(adapterSeatBids.Bids) > 0 {
sb := e.makeSeatBid(adapterSeatBids, a, adapterExtra, auc, returnCreative, impExtInfoMap, bidRequest, bidResponseExt, pubID, seatNonBidBuilder)
sb := e.makeSeatBid(adapterSeatBids, a, adapterExtra, auc, cacheInstructions, impExtInfoMap, bidRequest, bidResponseExt, pubID, seatNonBidBuilder)
seatBids = append(seatBids, *sb)
bidResponse.Cur = adapterSeatBids.Currency
}
Expand Down Expand Up @@ -1327,22 +1329,22 @@ func (e *exchange) makeExtBidResponse(adapterBids map[openrtb_ext.BidderName]*en

// Return an openrtb seatBid for a bidder
// buildBidResponse is responsible for ensuring nil bid seatbids are not included
func (e *exchange) makeSeatBid(adapterBid *entities.PbsOrtbSeatBid, adapter openrtb_ext.BidderName, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, returnCreative bool, impExtInfoMap map[string]ImpExtInfo, bidRequest *openrtb_ext.RequestWrapper, bidResponseExt *openrtb_ext.ExtBidResponse, pubID string, seatNonBidBuilder *SeatNonBidBuilder) *openrtb2.SeatBid {
func (e *exchange) makeSeatBid(adapterBid *entities.PbsOrtbSeatBid, adapter openrtb_ext.BidderName, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, cacheInstructions extCacheInstructions, impExtInfoMap map[string]ImpExtInfo, bidRequest *openrtb_ext.RequestWrapper, bidResponseExt *openrtb_ext.ExtBidResponse, pubID string, seatNonBidBuilder *SeatNonBidBuilder) *openrtb2.SeatBid {
seatBid := &openrtb2.SeatBid{
Seat: adapter.String(),
Group: 0, // Prebid cannot support roadblocking
}

var errList []error
seatBid.Bid, errList = e.makeBid(adapterBid.Bids, auc, returnCreative, impExtInfoMap, bidRequest, bidResponseExt, adapter, pubID, seatNonBidBuilder)
seatBid.Bid, errList = e.makeBid(adapterBid.Bids, auc, cacheInstructions, impExtInfoMap, bidRequest, bidResponseExt, adapter, pubID, seatNonBidBuilder)
if len(errList) > 0 {
adapterExtra[adapter].Errors = append(adapterExtra[adapter].Errors, errsToBidderErrors(errList)...)
}

return seatBid
}

func (e *exchange) makeBid(bids []*entities.PbsOrtbBid, auc *auction, returnCreative bool, impExtInfoMap map[string]ImpExtInfo, bidRequest *openrtb_ext.RequestWrapper, bidResponseExt *openrtb_ext.ExtBidResponse, adapter openrtb_ext.BidderName, pubID string, seatNonBidBuilder *SeatNonBidBuilder) ([]openrtb2.Bid, []error) {
func (e *exchange) makeBid(bids []*entities.PbsOrtbBid, auc *auction, cacheInstructions extCacheInstructions, impExtInfoMap map[string]ImpExtInfo, bidRequest *openrtb_ext.RequestWrapper, bidResponseExt *openrtb_ext.ExtBidResponse, adapter openrtb_ext.BidderName, pubID string, seatNonBidBuilder *SeatNonBidBuilder) ([]openrtb2.Bid, []error) {
result := make([]openrtb2.Bid, 0, len(bids))
errs := make([]error, 0, 1)

Expand Down Expand Up @@ -1401,8 +1403,13 @@ func (e *exchange) makeBid(bids []*entities.PbsOrtbBid, auc *auction, returnCrea
result = append(result, *bid.Bid)
resultBid := &result[len(result)-1]
resultBid.Ext = bidExtJSON
if !returnCreative {
resultBid.AdM = ""
if auc != nil {
_, hasCacheId := auc.cacheIds[bid.Bid]
_, hasVastCacheId := auc.vastCacheIds[bid.Bid]
if (hasVastCacheId && !cacheInstructions.returnCreativeVast) ||
(hasCacheId && !cacheInstructions.returnCreativeBids) {
resultBid.AdM = ""
}
}
}
}
Expand Down
Loading
Loading