Skip to content

Commit

Permalink
make sure size mapping is applied to mediaTypes.banner.sizes as well (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich authored Jul 27, 2018
1 parent f435866 commit a441a81
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,16 @@ function getLabels(bidOrAdUnit, activeLabels) {

function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels}) {
return adUnits.reduce((result, adUnit) => {
let {active, sizes: filteredAdUnitSizes} = resolveStatus(getLabels(adUnit, labels), adUnit.sizes);
let bannerSizes = utils.deepAccess(adUnit, 'mediaTypes.banner.sizes');

let {active, sizes: filteredAdUnitSizes} = resolveStatus(
getLabels(adUnit, labels),
bannerSizes || adUnit.sizes
);

if (active) {
result.push(adUnit.bids.filter(bid => bid.bidder === bidderCode)
.reduce((bids, bid) => {
if (adUnit.mediaTypes) {
if (utils.isValidMediaTypes(adUnit.mediaTypes)) {
bid = Object.assign({}, bid, {mediaTypes: adUnit.mediaTypes});
} else {
utils.logError(
`mediaTypes is not correctly configured for adunit ${adUnit.code}`
);
}
}

const nativeParams =
adUnit.nativeParams || utils.deepAccess(adUnit, 'mediaTypes.native');
if (nativeParams) {
Expand All @@ -77,6 +72,22 @@ function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels}) {

let {active, sizes} = resolveStatus(getLabels(bid, labels), filteredAdUnitSizes);

if (adUnit.mediaTypes) {
if (utils.isValidMediaTypes(adUnit.mediaTypes)) {
if (bannerSizes) {
adUnit.mediaTypes.banner.sizes = sizes;
}

bid = Object.assign({}, bid, {
mediaTypes: adUnit.mediaTypes
});
} else {
utils.logError(
`mediaTypes is not correctly configured for adunit ${adUnit.code}`
);
}
}

if (active) {
bids.push(Object.assign({}, bid, {
adUnitCode: adUnit.code,
Expand Down

0 comments on commit a441a81

Please sign in to comment.