Skip to content

Commit

Permalink
【MediaGoBidderAdapter】notify server if the page is secure and check m…
Browse files Browse the repository at this point in the history
…atch size (#5753)

* notify server if the page is secure

* remove undefined initial

Co-authored-by: fangsimin@baidu.com <fangsimin@baidu.com>
  • Loading branch information
SylviaF and fangsimin@baidu.com authored Sep 18, 2020
1 parent cd4d0d8 commit 89d829f
Showing 1 changed file with 41 additions and 28 deletions.
69 changes: 41 additions & 28 deletions modules/mediagoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
} from '../src/adapters/bidderFactory.js';

const BIDDER_CODE = 'mediago';
// const PROTOCOL = window.document.location.protocol;
const PROTOCOL = window.document.location.protocol;
const IS_SECURE = (PROTOCOL === 'https:') ? 1 : 0;
const ENDPOINT_URL =
// ((PROTOCOL === 'https:') ? 'https' : 'http') +
'https://rtb-us.mediago.io/api/bid?tn=';
Expand Down Expand Up @@ -163,8 +164,9 @@ function transformSizes(requestSizes) {
*/
function getItems(validBidRequests, bidderRequest) {
let items = [];
items = validBidRequests.map((req, i) => {
let ret = {};
for (let i in validBidRequests) {
let req = validBidRequests[i];
let ret;
let mediaTypes = getProperty(req, 'mediaTypes');

let sizes = transformSizes(getProperty(req, 'sizes'));
Expand All @@ -178,27 +180,33 @@ function getItems(validBidRequests, bidderRequest) {
}
}

// if (mediaTypes.native) {}
// banner广告类型
if (mediaTypes.banner) {
let id = '' + (i + 1);
ret = {
id: id,
// bidFloor: 0, // todo
banner: {
h: matchSize.height,
w: matchSize.width,
pos: 1,
}
};
itemMaps[id] = {
req,
ret
};
// Continue only if there is a matching size
if (matchSize) {
// banner广告类型
if (mediaTypes.banner) {
let id = '' + (+i + 1);
ret = {
id: id,
// bidFloor: 0, // todo
banner: {
h: matchSize.height,
w: matchSize.width,
pos: 1,
},
secure: IS_SECURE // for server-side to check if it's secure page
};
itemMaps[id] = {
req,
ret
};
}
}

return ret;
});
if (ret) {
items.push(ret);
}
}

return items;
}

Expand Down Expand Up @@ -288,12 +296,17 @@ export const spec = {
buildRequests: function(validBidRequests, bidderRequest) {
let payload = getParam(validBidRequests, bidderRequest);

const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: ENDPOINT_URL + globals['token'],
data: payloadString,
};
// request ad only if there is a matching size
if (payload) {
const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: ENDPOINT_URL + globals['token'],
data: payloadString,
};
} else {
return null;
}
},

/**
Expand Down

0 comments on commit 89d829f

Please sign in to comment.