From 519cb0817edfa11dcc4636698ec997d4671dd32d Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 10 Apr 2023 10:32:07 -0700 Subject: [PATCH 1/3] OpenXOrtb: fix multiformat requests --- modules/openxOrtbBidAdapter.js | 2 +- test/spec/modules/openxOrtbBidAdapter_spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/openxOrtbBidAdapter.js b/modules/openxOrtbBidAdapter.js index fbdf96fb72a..445246812f6 100644 --- a/modules/openxOrtbBidAdapter.js +++ b/modules/openxOrtbBidAdapter.js @@ -29,7 +29,7 @@ const converter = ortbConverter({ }, imp(buildImp, bidRequest, context) { const imp = buildImp(bidRequest, context); - if (bidRequest.mediaTypes[VIDEO]?.context === 'outstream') { + if (imp.video && bidRequest.mediaTypes[VIDEO]?.context === 'outstream') { imp.video.placement = imp.video.placement || 4; } mergeDeep(imp, { diff --git a/test/spec/modules/openxOrtbBidAdapter_spec.js b/test/spec/modules/openxOrtbBidAdapter_spec.js index efa205808c3..ca4fd62c2af 100644 --- a/test/spec/modules/openxOrtbBidAdapter_spec.js +++ b/test/spec/modules/openxOrtbBidAdapter_spec.js @@ -300,6 +300,17 @@ describe('OpenxRtbAdapter', function () { }); context('common requests checks', function() { + it('should be able to handle multiformat requests', () => { + const multiformat = utils.deepClone(bidRequestsWithMediaTypes[0]); + multiformat.mediaTypes.video = { + context: 'outstream', + playerSize: [640, 480] + } + const requests = spec.buildRequests([multiformat], mockBidderRequest); + const outgoingFormats = requests.flatMap(rq => rq.data.imp.flatMap(imp => ['banner', 'video'].filter(k => imp[k] != null))); + expect(outgoingFormats).to.have.members(['banner', 'video']) + }) + it('should send bid request to openx url via POST', function () { const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); expect(request[0].url).to.equal(REQUEST_URL); From 195f3b11bdc72971edbf9ccbeb229fd8549d9d55 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 10 Apr 2023 10:41:07 -0700 Subject: [PATCH 2/3] pay attention to feature tags --- test/spec/modules/openxOrtbBidAdapter_spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/openxOrtbBidAdapter_spec.js b/test/spec/modules/openxOrtbBidAdapter_spec.js index ca4fd62c2af..951399457c3 100644 --- a/test/spec/modules/openxOrtbBidAdapter_spec.js +++ b/test/spec/modules/openxOrtbBidAdapter_spec.js @@ -308,7 +308,8 @@ describe('OpenxRtbAdapter', function () { } const requests = spec.buildRequests([multiformat], mockBidderRequest); const outgoingFormats = requests.flatMap(rq => rq.data.imp.flatMap(imp => ['banner', 'video'].filter(k => imp[k] != null))); - expect(outgoingFormats).to.have.members(['banner', 'video']) + const expected = FEATURES.VIDEO ? ['banner', 'video'] : ['banner'] + expect(outgoingFormats).to.have.members(expected); }) it('should send bid request to openx url via POST', function () { From 6f6e39c63f216215142d16b6e43ee4d1b67f5592 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 10 Apr 2023 10:49:52 -0700 Subject: [PATCH 3/3] refactor & cleanup --- modules/openxOrtbBidAdapter.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/openxOrtbBidAdapter.js b/modules/openxOrtbBidAdapter.js index 445246812f6..5afee034d5f 100644 --- a/modules/openxOrtbBidAdapter.js +++ b/modules/openxOrtbBidAdapter.js @@ -29,9 +29,6 @@ const converter = ortbConverter({ }, imp(buildImp, bidRequest, context) { const imp = buildImp(bidRequest, context); - if (imp.video && bidRequest.mediaTypes[VIDEO]?.context === 'outstream') { - imp.video.placement = imp.video.placement || 4; - } mergeDeep(imp, { tagid: bidRequest.params.unit, ext: { @@ -132,15 +129,20 @@ const converter = ortbConverter({ } }, video(orig, imp, bidRequest, context) { - // `orig` is the video imp processor, which looks at bidRequest.mediaTypes[VIDEO] - // to populate imp.video - // alter its input `bidRequest` to also pick up parameters from `bidRequest.params` - let videoParams = bidRequest.mediaTypes[VIDEO]; - if (videoParams) { - videoParams = Object.assign({}, videoParams, bidRequest.params.video); - bidRequest = {...bidRequest, mediaTypes: {[VIDEO]: videoParams}} + if (FEATURES.VIDEO) { + // `orig` is the video imp processor, which looks at bidRequest.mediaTypes[VIDEO] + // to populate imp.video + // alter its input `bidRequest` to also pick up parameters from `bidRequest.params` + let videoParams = bidRequest.mediaTypes[VIDEO]; + if (videoParams) { + videoParams = Object.assign({}, videoParams, bidRequest.params.video); + bidRequest = {...bidRequest, mediaTypes: {[VIDEO]: videoParams}} + } + orig(imp, bidRequest, context); + if (imp.video && videoParams?.context === 'outstream') { + imp.video.placement = imp.video.placement || 4; + } } - orig(imp, bidRequest, context); } } }