Skip to content

Commit

Permalink
Generate bidResponse.vastUrl based on vastXml dataUri encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
osazos committed Nov 27, 2020
1 parent 8cddac3 commit 0a4c752
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
32 changes: 20 additions & 12 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,18 +837,26 @@ export const spec = {
const bidReq = (find(bidRequest.data.adUnits, bid => bid.bidId === bidObj.requestId));

if (bidReq) {
if (bidObj.mediaType === VIDEO && utils.deepAccess(bidReq, 'mediaTypes.video.context') === OUTSTREAM) {
bidObj.renderer = Renderer.install({
id: bidObj.requestId,
adUnitCode: bidObj.adUnitCode,
url: bidObj.urlRenderer || RENDERER_URL,
config: {
...utils.deepAccess(bidReq, 'mediaTypes.video'),
...utils.deepAccess(bidObj, 'outstream', {})
}
});

bidObj.renderer.setRender(_renderer);
if (bidObj.mediaType === VIDEO) {
const mediaTypeContext = utils.deepAccess(bidReq, 'mediaTypes.video.context');
// Adagio SSP returns a `vastXml` only. No `vastUrl` nor `videoCacheKey`.
if (!bidObj.vastUrl && bidObj.vastXml) {
bidObj.vastUrl = 'data:text/xml;charset=utf-8;base64,' + btoa(bidObj.vastXml.replace(/\\"/g, '"'));
}

if (mediaTypeContext === OUTSTREAM) {
bidObj.renderer = Renderer.install({
id: bidObj.requestId,
adUnitCode: bidObj.adUnitCode,
url: bidObj.urlRenderer || RENDERER_URL,
config: {
...utils.deepAccess(bidReq, 'mediaTypes.video'),
...utils.deepAccess(bidObj, 'outstream', {})
}
});

bidObj.renderer.setRender(_renderer);
}
}

bidObj.site = bidReq.params.site;
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ describe('Adagio bid adapter', () => {
};

const serverResponseWithOutstream = utils.deepClone(serverResponse);
serverResponseWithOutstream.body.bids[0].ad = 'https://foo.bar/vast.xml';
serverResponseWithOutstream.body.bids[0].vastXml = '<VAST version="4.0"><Ad></Ad></VAST>';
serverResponseWithOutstream.body.bids[0].mediaType = 'video';
serverResponseWithOutstream.body.bids[0].outstream = {
bvwUrl: 'https://foo.baz',
Expand Down

0 comments on commit 0a4c752

Please sign in to comment.