Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #2315 sizeMapping not working with s2s requests #2332

Merged
merged 2 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ const LEGACY_PROTOCOL = {
buildRequest(s2sBidRequest, adUnits) {
// pbs expects an ad_unit.video attribute if the imp is video
adUnits.forEach(adUnit => {
adUnit.sizes = adUnit.sizesS2S;
delete adUnit.sizesS2S;
const videoMediaType = utils.deepAccess(adUnit, 'mediaTypes.video');
if (videoMediaType) {
adUnit.video = Object.assign({}, videoMediaType);
Expand Down
13 changes: 12 additions & 1 deletion src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function getAdUnitCopyForPrebidServer(adUnits) {
let adUnitsCopy = utils.deepClone(adUnits);

adUnitsCopy.forEach((adUnit) => {
adUnit.sizes = transformHeightWidth(adUnit);
adUnit.sizesS2S = transformHeightWidth(adUnit);
Copy link
Member

Choose a reason for hiding this comment

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

can we just move this function into prebidServerBidAdapter instead of adding a temporary sizesS2S?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep - I'll move the function over and make other adjustments.


// filter out client side bids
adUnit.bids = adUnit.bids.filter((bid) => {
Expand Down Expand Up @@ -281,6 +281,17 @@ exports.callBids = (adUnits, bidRequests, addBidResponse, doneCb) => {
const s2sAdapter = _bidderRegistry[_s2sConfig.adapter];
let tid = serverBidRequests[0].tid;
let adUnitsS2SCopy = serverBidRequests[0].adUnitsS2SCopy;
adUnitsS2SCopy.forEach((adUnitCopy) => {
let validBids = adUnitCopy.bids.filter((bid) => {
return serverBidRequests.find(request => {
return request.bidderCode === bid.bidder &&
request.bids.find((reqBid) => reqBid.adUnitCode === adUnitCopy.code);
});
});
adUnitCopy.bids = validBids;
});

adUnitsS2SCopy = adUnitsS2SCopy.filter(adUnitCopy => adUnitCopy.bids.length > 0);

if (s2sAdapter) {
let s2sBidRequest = {tid, 'ad_units': adUnitsS2SCopy};
Expand Down