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 054f138 commit 012c647
Show file tree
Hide file tree
Showing 2 changed files with 22 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 @@ -838,18 +838,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
3 changes: 2 additions & 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 All @@ -845,6 +845,7 @@ describe('Adagio bid adapter', () => {
expect(bidResponse.renderer.loaded).to.not.be.ok;
expect(bidResponse.width).to.equal(300);
expect(bidResponse.height).to.equal(250);
expect(bidResponse.vastUrl).to.match(/^data:text\/xml;/)
});
});
});
Expand Down

0 comments on commit 012c647

Please sign in to comment.