Skip to content

Commit

Permalink
UOE-5250: prebid-server upgrade to Prebid 0.116.0 (#58)
Browse files Browse the repository at this point in the history
* adding yieldmo vendor id to usersync (prebid#1166)

* Add SmartRTB adapter (prebid#1071)

* Added new adapter for CPMStar ad network banners and video (prebid#1159)

* Update the Conversant sync pixel (prebid#1161)

* Add imp.ext.is_rewarded_inventory flag for rewarded video in Rubicon (prebid#1170)

* [currencies] fix GetInfo() null ref issue (prebid#1169)

This CL fixes the null ref on `RateConverter.GetInfo()` when rates
are nil. Issue: prebid#1136

* Fix triplelift User Sync (prebid#1173)

* Enhance Message For Cache Errors (prebid#1175)

* Fix PubMatic Usersync URL (prebid#1178)

Co-authored-by: pm-isha-bharti <isha.bharti@pubmatic.com>

* [Synacormedia] Add tagId bidder parameter (prebid#1165)

* Remove all non-secure calls from eplanning adapter (prebid#1179)

* Expose Cache HTTP Settings (prebid#1184)

* Adding bid rejection messages to debug response (prebid#1181)

* Adds timeout notifications for Facebook (prebid#1182)

* VIS.X: added app type support (prebid#1194)

* Add Adoppler bidder support. (prebid#1186)

* Add Adoppler bidder support.

* Address code review comments. Use JSON-templates for testing.

* Fix misprint; Add url.PathEscape call for adunit URL parameter.

* Adding support for deal prefixes (prebid#1183)

* updating default hard-coded list of certs (prebid#1201)

Co-authored-by: Shalmali Patil <shalmali.patil@pubmatic.com>

* add admixer adapter (prebid#1195)

* Adding copying of gdpr consent string to openrtb bid request (prebid#1189)

* Adding copying of gdpr consent string to openrtb bid request

* Updated video request to use OpenRTB Video and User objects

* Fixing unit test failure message

* Updates from code review comments

* Updating unit test initialization

* Updated mimes array construction

* fix conversant sync pixel (prebid#1208)

* openx adapter: forward bid response currency in openx adapter if set (prebid#1211)

it was always set to the default USD before

* add ucfunnel adapter (prebid#1192)

* Update required params for TheMediaGrid adapter (prebid#1188)

* add zeroclickfraud adapter (prebid#1207)

* add zeroclickfraud adapter

* fixes for PR

* fix casing of Zeroclickfraud

* Fix Adform's parameters regex (prebid#1214)

* Added adform info file

* Added Adform adapter and bidder

* Updates from master

* Removed usersyncInfo from Adform adapter. Inverted Imp type check.

* Removed excessive loop

* Updated with the last master

* Create readme file for adform

* Fix Adform's parameters regex

Motivation: catastrophic backtracking during regex execution

Details:
- https://regex101.com/r/NNQrWq/1
- string to check "url_domain:keskustelu.suomi24.fi,url_path:/matkailu/matkakohteet/aasia,layout:lg,categories:Matkailu,main_category:Matkailu"

Co-authored-by: v.statkevich <v.statkevich@adform.com>
Co-authored-by: Olga Linkevich <o.linkevich@adform.com>

* If Device.UA is not present in request body, init it with user-agent from header (prebid#1219)

* If Device.UA is not present in request body, init it with user-agent from request header if it's present

* Moved User-Agent handler to parseVideoRequest func and added unit test

* Minor clean up

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* Queued request timeout (prebid#1217)

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* docs: adding currency support section (prebid#1199)

* Add ValueImpression Adapter (prebid#1204)

* Kidoz adapter (prebid#1210)

Co-authored-by: Ryan Haksi <ryan.haksi@freshgrade.com>

* Update auction.md (prebid#1224)

Fix type

* Update auction.md (prebid#1225)

Fix typo.

* Added logging to cache for video endpoint (prebid#1220)

* WIP added logging to cache for video endpoint

* Updating cache call to use TTL from config

* Updates from initial feedback
* Log now includes HTTP headers
* Fixed caching to use a new cache entry rather than appending to the
VAST
* Added feature where is query is set, the test flag is set in the
request

* Updated recorded response and handleError

* Updates from code review comments

* Changed recorded output to be only the debug ext
* Removed extra marhal calls
* Changed cache to be an endpoint dependency
* Added debugLog struct to hold all debug related info
* Numerous smaller changes

* Further code cleanup and added unit tests for debug changes

* Added missing error checks

* Added unit test for error case

* added VISX vendor ID for usersyncing (prebid#1229)

Co-authored-by: Aadesh Patel <aadesh.patel@xandr.com>

* First pass at phase 1 TCF 2.0 support (prebid#1228)

* First pass at phase 1 TCF 2.0 support

* minor fixes

* Update go-gdpr library and fix stuff

* Fixes for PR comments

* Updated price granularity unmarshal to accept empty values and ranges (prebid#1230)

* Update vendorID for TheMediaGrid s2s Bid Adapter (prebid#1232)

* treat 204 from FAN as a no bids response (prebid#1233)

Co-authored-by: Aadesh Patel <aadesh.patel@xandr.com>

* AMP CCPA Fix (prebid#1187)

* Update rubicon.md (prebid#1234)

* adding schain interface (prebid#1203)

* added Rewarded Video section (prebid#1200)

also edited all examples so they include the full openRTB context

* nanointeractive adapter (prebid#1213)

* nanointeractive adapter

* nanointeractive adapter, changes after review

* nanointeractive adapter

* nanointeractive adapter, changes after review

* formatting

* Typos Fix (prebid#1236)

* Fix Typo

* Fixed More Typos

* Moved hb_pc_cat_dur modification to be before caching (prebid#1250)

* replacing info@prebid.org maintainer email addrs (prebid#1256)

* aligning maintainer info (prebid#1258)

* Add kidoz bidder info (prebid#1257)

got this info from email communication with kidoz

* Add Cropping of BAdv for Rubicon Adapter (prebid#1254)

* Add Cropping of BAdv for Rubicon Adapter

BAdv size is limited to 50

* Fix after review

Co-authored-by: Harbar Dmytro <dharbar@rubiconproject.com>

* Added metrics support to endpoint aspect (prebid#1226)

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* Prebid Server adapter for Telaria (prebid#1231)

* TELARIA adapter. First Pass

* Some refactoring

* added the json files

* fixed some tests and added the bidder info

* fixed some tests and added the bidder info

* added default user sync ur;

* - Handling gzipped responses from our server

* - more refactoring.

* added the proper user sync default URL

* changed the urls from dev to prod

* changed up the required fields. Now AdCode in the Imp.Ext isn't required but Bid.SeatCode is required

* change in the return type after decompressing

* some refactoring

* change in our config url

* using pbs.yml to switch between our production and test URLs

* setting default endpoint

* - fixed the issue that was preventing telaria test cases to run.
- added more test cases

* - Modifications as per the changes requested by the maintainers.

* Moved the seat code to imp.ext

* Moved the seat code to imp.ext

* Added 'Telaria: ' prefix for error messages

* - Fixes for race conditions. Was modifying the original request object instead of a copy

* cosmetic changes.

* added params_test.go

Co-authored-by: Vinay Prasad <vprasad@telaria.com>

* #615 Beachfront URLs from config (prebid#1238)

* Add nil check errors when setting native asset types (prebid#1260)

* Bugfix: no bids from bidder handling (prebid#1252)

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* Add missing categories to AppNexus -> IAB mapping file. (prebid#1264)

* Add missing categories to AppNexus -> IAB mapping file.

* Remove entry for category 38 which was set to a primary IAB category instead of a sub-category.

* Fix order of category 22

* Yieldone s2s Bid Adapter (prebid#1242)

* Added new Yieldone Bid s2s Adapter

* Update endpoint for yieldone bid adapter

* Fixes after review for Yieldone Bid s2s Adapter

* Fix typeo in Yieldone s2s Bid Adapter

* Fix: URL de sync (prebid#1261)

* populate the app ID in the FAN timeout notif url with the publisher ID (prebid#1265)

and the auction with the request ID

Co-authored-by: Aadesh Patel <aadesh.patel@xandr.com>

* Added header User Agent decoding (prebid#1268)

* Added header User Agent decoding

* Added header User Agent decoding: unit tests

* Added header User Agent decoding: unit tests

* Added check UA is encoded to avoid `+` converted to space

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* Ad Generation Adapter Integration. (prebid#1253)

* AdGeneration Integration.

* update AdGeneration adapter.
fix: some methods of the adgAdapter replace to functions.
fix: unmarshal functions return a pointer.
fix: header is defined once.
fix: return when imps is appended

* update AdGeneration Adapter.

add: Added a comment in usersync.
add: Added a test for parameters whose ID does not exist in params_test.
change: Change to query creation by net/url. Added getRawQuery Test.
fix: Changed variable names related to bidRequest.

* Fix Go 1.14 Error Message Changes (prebid#1271)

* NinthDecimal Adapter (prebid#1249)

Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>

* * Add PubMatic bidder doc file (prebid#1255)

* Add app video capability to PubMatic bidder info file

* Appnexus adapter: Add category mapping for government. (prebid#1278)

* Update a Freewheel mapping to Gaming category. (prebid#1280)

* Add AJA adapter (prebid#1269)

* OpenX adapter: Pass gdpr and gdpr_consent to user sync endpoint (prebid#1282)

I've also updated the test to avoid any confusion.

* OpenX adapter: Enable video for app (prebid#1281)

* fix conversant sync pixel (prebid#1284)

* Add AdOcean adapter (prebid#1273)

* [ADOCEAN-20132] AdOcean adapter

* [ADOCEAN-20132] AdOcean adapter - support for gdpr

* [ADOCEAN-20132] AdOcean adapter - tests

* [ADOCEAN-20132] AdOcean adapter - user sync

* [ADOCEAN-20132] AdOcean adapter - formatting

* [ADOCEAN-20132] AdOcean adapter - send uuid to emitter

* [ADOCEAN-20132] adocean adapter - return nil if there is no creative

* [ADOCEAN-20132] AdOcean adapter - add version parameter

* [ADOCEAN-20132] AdOcean adapter - optimization

* [ADOCEAN-20132] AdOcean adapter - add to syncer_test.go

* [ADOCEAN-20132] AdOcean adapter - changes after review:
* remove whitespaces in js code on adapter initialization instead on every request
* check if request.Site is not nil
* reuse newUri variable

* [ADOCEAN-20132] AdOcean adapter - changes after review:
* do not terminate the auction on a single faulty bid

* [ADOCEAN-20132] AdOcean adapter - changes after review:
* remove unnecessary input parameters check
* small optimization

* LunaMedia Adapter (prebid#1285)

Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>

* [Sharethrough] Add CCPA support (prebid#1263)

* Handle gzip responses from ad server correctly

* Bump to version 8

* [Go Modules] Add proxy (prebid#1079)

* Add SSL cert for accessing stored request API (prebid#1087)

* [misspell] fix a misspell (prebid#1102)

* update static bidder params for rubicon video to follow the json marshalling names (prebid#1100)

* Switching yieldmo auction endpoint from http to https (prebid#1103)

* Add Datablocks Adapter (prebid#1095)

* datablocks bid adapter

* ttx

* add test json

* add coverage

* redo ttx

* formatted

* better error handling

* additional tests and recomended fixes

* Adding translatecategories flag to includebrandcategory (prebid#1098)

* Making IAB category translation optional with translatecategories boolean in request

* Updating exchange unit tests to remove extra bids

* Updates from code review comments

* Removed comment about default TranslateCategories value
* Changed translateCat to translateCategories in tests
* Combined helper functions in exchange_test related to TranslateCategories

* Bid floor (prebid#1085)

* Currency handling fix (prebid#1097)

* facebook adapter refactor (prebid#1064)

* Kubient adapter (prebid#1094)

* [synacormedia] Update user sync url to be https (prebid#1115)

This detail was missed while setting up the adapter, but we would like to use https for the user sync.

* Remove Go 1.11 Build Target (prebid#1109)

* Set "Secure" on Same SIte cookies (prebid#1119)

* TripleliftNative Adapter (prebid#1114)

* ignore swp files

* start small

* start really small

* add a user sync

* justify

* triplelift adapter

* add our endpoint

* fix syntax

* config stuff

* compiler fixes

* more config

* add params

* making progress

* make our ext more exty

* start making responses

* more logic

* fix compilation errors

* can we just nil this out?

* augment our json

* radically simplify our json

* fix errs

* infer the bid type

* fix syntax

* fix comilation errors

* rename

* fix compilation error

* config stuff

* simplify params

* more config stuff

* fixes

* revert this

* fix up the extension

* getting closer

* add a test

* update config

* update bidder params

* add the floor here, too

* add a usersync test

* validation, ws, and a test

* update tests

* fix test

* update email

* why not

* change email

* preprocess requests

* do some parsing

* take care of some errors

* floor is optional

* ws

* remove native

* everything is either banner or video

* this should be a float

* floor to floor

* fix compilation errors

* add some tests

* more tests

* more tests

* simplify

* more progress

* format

* ws

* rm

* don't need this

* fix test

* fix test

* don't ignore swap

* change line back

* report an error if there are no valid impressions for triplelift

* check for either a Banner or Video object on the impression

* more tests

* mv

* more tests

* update triplelift end point

* send native

* ws

* start changing tests

* fix more tests

* update config

* add redirect to triplelift usersync

* fix supplier id in triplelift_test

* update tl usersync endpoint and test

* fix tl supplier id in test json

* update usersync test template

* adjust inconsistency with test and sync url

* mv

* update packages

* mv

* mv

* update

* fix compilation errors

* rename

* rename some stuff

* rename

* rename

* fix some compilation errors

* ws

* ws

* add the extra info

* add some extra info

* add some files back

* ws and such

* updates

* ws

* fix compilation error

* mv

* rename

* Revert "rename"

This reverts commit 1b77c72.

* Revert "mv"

This reverts commit 52a134d.

* it builds

* cp a file

* cp another file

* fix a test

* fix test

* add the extra info

* ws

* add some logic

* edit comment

* it compiles

* this is now public

* call this

* add the function

* return nil

* seems to be working

* ws

* seems to be working

* ws

* mv

* starting to work

* ws

* add a new function

* ws

* fix tests

* bug fix

* update some stuff

* revert

* take out prints

* fix up diff

* fix up diff

* update ws

* fix

* ws

* omit the triplelift endppint

* Revert "omit the triplelift endppint"

This reverts commit 7abc3e4.

* populate the endpoint through the extinfo

* ws

* set disabled to be default

* ws

* update types

* fixing tests

* making progres

* fix tests

* fix tests

* more fixes for tests

* fixed tests

* just use a comment

* get rid of endpoint

* restore endpoint

* add some errors around unmarshalling

* ws

* ws

* use the literal

* ws

* ws

* update json

* simplify

* ws

* restore tests

* fail fast when grabbing invcode

* use the right type

* use a different error type

* bump code coverage

* add a new test

* change error type

* ws

* break out test into its own function

* JSON block that has a full data-center specific URL cache info (prebid#1104)

* Update Dockerfile and Makefile  (prebid#1099)

* Add option for running tests as part of the docker image building

* Update Makefile

- Add ability to execute adapter specific tests
- Execute targets for "all" rather than just printing the target name and usage
- Remove use of non-existing "install" target from .PHONY targets
- Remove "build" as a dependency for "image"

* enable app requests for audience network (prebid#1122)

* [docs] fix markdown title (prebid#1124)

* Prometheus Refactor (prebid#1108)

* update default sync url (prebid#1127)

* Update sync url for BidderGrid adapter (prebid#1120)

* [SonarCloud] Legacy auction endpoint (prebid#1017)

* [currency converter] allow to deduce reverse rate (prebid#1126)

This CL allows the currency rate currency to deduce a currency rate even
if not directly defined in the table but the reverse rate is present.

E.q.

USD => EUR is 1.0897
EUR => USD is not set

Old behavior when asking rate from EUR to USD will not be found,
New behavior is using the known reverse rate to deduce the rate.

Rate for 2 USD will be 2 * (1 / 1.0897)

* Updated handleError arguments to be pointers for video endpoint (prebid#1128)

* Updated handleError arguments to be pointers for video endpoint

* Removing unneeded pointer to http.ResponseWriter

* Adding units test for update to handleError

* Revert changes to GetExtCacheData() made in prebid#1104 (prebid#1130) (prebid#1131)

* Better native request validation (prebid#1132)

* require the caller to define native assets[...].ID (prebid#1123)

* require the caller to define native assets[...].ID

* Update assets-with-partial-ids.json

* CCPA Phase 1: AMP Endpoint (prebid#1125)

* facebook: removed Auth-Token from header (replaced by authentication_id in the request body) (prebid#1113)

* Setuid Fix (prebid#1121)

* Update http refresh to use url builder. Fixes prebid#1065 (prebid#1133)

* Add mapping of user.ext.eids[] for LiveIntent in Rubicon bidder (prebid#1089)

* support facebook app_secret config param (prebid#1139)

* CCPA Phase 1: Cookie Sync (prebid#1135)

* null check banner.h (prebid#1142)

* Add Pubnative Adapter (prebid#1134)

* Adding the passing of CCPA value to the bid request for video endpoint (prebid#1143)

* first draft (prebid#1137)

* CCPA Phase 2: Enforcement (prebid#1138)

* Gamoshi Adapter: Update cookie sync (prebid#1146)

* Simplify static/bidder-params/triplelift_native.json (prebid#1152)

* Added US Privacy support in TheMediaGrid server adapter (prebid#1147)

* Add TheMediaGrid server adapter

* Add video support in TheMediaGrid s2s adapter

* Update sync url for TheMediaGrid s2s adapter

* Added CCPA support for TheMediaGrid s2s adapter

* Fix sync url for TheMediaGrid adapter

* CCPA User Sync Updates (prebid#1153)

* Marsmedia - add new bidder (prebid#1118)

* Add Applogy adapter (prebid#1151)

* enforce video.size_id for video imps in rubicon adapter (prebid#1101)

* Updated PubMatic endpoint to use https (prebid#1155)

* Update Example AppNexus Placement ID (prebid#1160)

* Fix Currency Converter Doesn't Output CUR (prebid#1154)

* Add custom JSON req/resp data to the analytics logging… (prebid#1145)

* Add custom JSON req/resp data to the analytics logging for the /openrtb2/video endpoint.

* Add calls in unit tests to cover logging and jsonify of video object.

* CCPA User Sync URL Updates (prebid#1157)

* Fixes audienceNetwork adapter ignoring banner.format sizes. (prebid#1164)

* adding yieldmo vendor id to usersync (prebid#1166)

* Add SmartRTB adapter (prebid#1071)

* Added new adapter for CPMStar ad network banners and video (prebid#1159)

* Update the Conversant sync pixel (prebid#1161)

* Add imp.ext.is_rewarded_inventory flag for rewarded video in Rubicon (prebid#1170)

* [currencies] fix GetInfo() null ref issue (prebid#1169)

This CL fixes the null ref on `RateConverter.GetInfo()` when rates
are nil. Issue: prebid#1136

* Fix triplelift User Sync (prebid#1173)

* Enhance Message For Cache Errors (prebid#1175)

* Fix PubMatic Usersync URL (prebid#1178)

Co-authored-by: pm-isha-bharti <isha.bharti@pubmatic.com>

* [Synacormedia] Add tagId bidder parameter (prebid#1165)

* Remove all non-secure calls from eplanning adapter (prebid#1179)

* Expose Cache HTTP Settings (prebid#1184)

* Adding bid rejection messages to debug response (prebid#1181)

* Adds timeout notifications for Facebook (prebid#1182)

* VIS.X: added app type support (prebid#1194)

* Add Adoppler bidder support. (prebid#1186)

* Add Adoppler bidder support.

* Address code review comments. Use JSON-templates for testing.

* Fix misprint; Add url.PathEscape call for adunit URL parameter.

* Adding support for deal prefixes (prebid#1183)

* updating default hard-coded list of certs (prebid#1201)

Co-authored-by: Shalmali Patil <shalmali.patil@pubmatic.com>

* add admixer adapter (prebid#1195)

* Adding copying of gdpr consent string to openrtb bid request (prebid#1189)

* Adding copying of gdpr consent string to openrtb bid request

* Updated video request to use OpenRTB Video and User objects

* Fixing unit test failure message

* Updates from code review comments

* Updating unit test initialization

* Updated mimes array construction

* fix conversant sync pixel (prebid#1208)

* openx adapter: forward bid response currency in openx adapter if set (prebid#1211)

it was always set to the default USD before

* add ucfunnel adapter (prebid#1192)

* Update required params for TheMediaGrid adapter (prebid#1188)

* add zeroclickfraud adapter (prebid#1207)

* add zeroclickfraud adapter

* fixes for PR

* fix casing of Zeroclickfraud

* Fix Adform's parameters regex (prebid#1214)

* Added adform info file

* Added Adform adapter and bidder

* Updates from master

* Removed usersyncInfo from Adform adapter. Inverted Imp type check.

* Removed excessive loop

* Updated with the last master

* Create readme file for adform

* Fix Adform's parameters regex

Motivation: catastrophic backtracking during regex execution

Details:
- https://regex101.com/r/NNQrWq/1
- string to check "url_domain:keskustelu.suomi24.fi,url_path:/matkailu/matkakohteet/aasia,layout:lg,categories:Matkailu,main_category:Matkailu"

Co-authored-by: v.statkevich <v.statkevich@adform.com>
Co-authored-by: Olga Linkevich <o.linkevich@adform.com>

* If Device.UA is not present in request body, init it with user-agent from header (prebid#1219)

* If Device.UA is not present in request body, init it with user-agent from request header if it's present

* Moved User-Agent handler to parseVideoRequest func and added unit test

* Minor clean up

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* Queued request timeout (prebid#1217)

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* docs: adding currency support section (prebid#1199)

* Add ValueImpression Adapter (prebid#1204)

* Kidoz adapter (prebid#1210)

Co-authored-by: Ryan Haksi <ryan.haksi@freshgrade.com>

* Update auction.md (prebid#1224)

Fix type

* Update auction.md (prebid#1225)

Fix typo.

* Added logging to cache for video endpoint (prebid#1220)

* WIP added logging to cache for video endpoint

* Updating cache call to use TTL from config

* Updates from initial feedback
* Log now includes HTTP headers
* Fixed caching to use a new cache entry rather than appending to the
VAST
* Added feature where is query is set, the test flag is set in the
request

* Updated recorded response and handleError

* Updates from code review comments

* Changed recorded output to be only the debug ext
* Removed extra marhal calls
* Changed cache to be an endpoint dependency
* Added debugLog struct to hold all debug related info
* Numerous smaller changes

* Further code cleanup and added unit tests for debug changes

* Added missing error checks

* Added unit test for error case

* added VISX vendor ID for usersyncing (prebid#1229)

Co-authored-by: Aadesh Patel <aadesh.patel@xandr.com>

* First pass at phase 1 TCF 2.0 support (prebid#1228)

* First pass at phase 1 TCF 2.0 support

* minor fixes

* Update go-gdpr library and fix stuff

* Fixes for PR comments

* Updated price granularity unmarshal to accept empty values and ranges (prebid#1230)

* Update vendorID for TheMediaGrid s2s Bid Adapter (prebid#1232)

* treat 204 from FAN as a no bids response (prebid#1233)

Co-authored-by: Aadesh Patel <aadesh.patel@xandr.com>

* AMP CCPA Fix (prebid#1187)

* Update rubicon.md (prebid#1234)

* adding schain interface (prebid#1203)

* added Rewarded Video section (prebid#1200)

also edited all examples so they include the full openRTB context

* nanointeractive adapter (prebid#1213)

* nanointeractive adapter

* nanointeractive adapter, changes after review

* nanointeractive adapter

* nanointeractive adapter, changes after review

* formatting

* Typos Fix (prebid#1236)

* Fix Typo

* Fixed More Typos

* Moved hb_pc_cat_dur modification to be before caching (prebid#1250)

* Handle CCPA + enable gzip response

[#169984259]

* Addressing review (#273)

[#169984259]

* Remove custom gzip logic  (#280)

* Getting rid of custom gzip logic

[#169984259]

* Restore prod ad server url

[#169984259]

Co-authored-by: Benjamin <b.chastanier@criteo.com>
Co-authored-by: guscarreon <guscarreon@gmail.com>
Co-authored-by: Aadesh <aadeshp95@gmail.com>
Co-authored-by: Winston-Yieldmo <46379634+Winston-Yieldmo@users.noreply.github.com>
Co-authored-by: htang555 <htang555@gmail.com>
Co-authored-by: Cameron Rice <37162584+camrice@users.noreply.github.com>
Co-authored-by: ah-tappx <46002207+ah-tappx@users.noreply.github.com>
Co-authored-by: hhhjort <31041505+hhhjort@users.noreply.github.com>
Co-authored-by: Marsel <taipovm@gmail.com>
Co-authored-by: Corey Kress <coreykre@buffalo.edu>
Co-authored-by: Scott Kay <noreply@syntaxnode.com>
Co-authored-by: Kevin Kerr <kkerr@triplelift.com>
Co-authored-by: Mansi Nahar <mansinahar@users.noreply.github.com>
Co-authored-by: Benjamin <benjamin.chastanier@gmail.com>
Co-authored-by: TheMediaGrid <44166371+TheMediaGrid@users.noreply.github.com>
Co-authored-by: Austin Bischoff <Austinb@users.noreply.github.com>
Co-authored-by: rpanchyk <rpanchyk@users.noreply.github.com>
Co-authored-by: Florian Hartwig <florian.hartwig@pubnative.net>
Co-authored-by: Salomon Rada <salomon@gamoshi.com>
Co-authored-by: vladi-mmg <vladi@m-m-g.com>
Co-authored-by: Aleksei Lin <aleksey@incsw.in>
Co-authored-by: PubMatic-OpenWrap <UOEDev@pubmatic.com>
Co-authored-by: jmaynardxandr <46759873+jmaynardxandr@users.noreply.github.com>
Co-authored-by: evanmsmrtb <evanm@smrtb.com>
Co-authored-by: CPMStar <josh@cpmstar.com>
Co-authored-by: johnwier <49074029+johnwier@users.noreply.github.com>
Co-authored-by: pm-isha-bharti <isha.bharti@pubmatic.com>
Co-authored-by: Seba Perez <sperez@est.frba.utn.edu.ar>
Co-authored-by: Michael Kuryshev <mk0x9@users.noreply.github.com>
Co-authored-by: Viacheslav Chimishuk <vchimishuk@yandex.ru>
Co-authored-by: Shalmali Patil <shalmali.patil@pubmatic.com>
Co-authored-by: DmitryStashkevich <34479135+DmitryStashkevich@users.noreply.github.com>
Co-authored-by: vstatkevich <v.statkevich@gmail.com>
Co-authored-by: v.statkevich <v.statkevich@adform.com>
Co-authored-by: Olga Linkevich <o.linkevich@adform.com>
Co-authored-by: Veronika Solovei <kalypsonika@gmail.com>
Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>
Co-authored-by: bretg <bgorsline@gmail.com>
Co-authored-by: thuyhq <61451682+thuyhq@users.noreply.github.com>
Co-authored-by: rhaksi-kidoz <61601767+rhaksi-kidoz@users.noreply.github.com>
Co-authored-by: Ryan Haksi <ryan.haksi@freshgrade.com>
Co-authored-by: ACannuniRP <57228257+ACannuniRP@users.noreply.github.com>
Co-authored-by: Aadesh Patel <aadesh.patel@xandr.com>
Co-authored-by: Rade Popovic <32302052+nanointeractive@users.noreply.github.com>

* Remove Outdated GDPR AMP Special Case (prebid#1283)

* Stricter Privacy Scrubbing (prebid#1286)

* Stricter Privacy Scrubbing

* Update Unit Test Style

* Fixed Whitespace

* Add Adapter Orbidder (prebid#1275)

Co-authored-by: Volk, Rainer <Rainer.Volk@otto.de>
Co-authored-by: RainerVolk4014 <53347752+RainerVolk4014@users.noreply.github.com>
Co-authored-by: rvolk <>
Co-authored-by: Hendrik Iseke <hendrik.iseke@gmx.de>
Co-authored-by: hendrikiseke1979 <53309111+hendrikiseke1979@users.noreply.github.com>

* Added OpenX Bidder adapter documentation (prebid#1291)

* OpenX adapter: Pass rewarded video flag (prebid#1290)

* Bugfix for missing fields in imp.video (prebid#1297)

Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>

* Add cpmOverride (prebid#1289)

* Add cpmOverride

Enabled `request.ext.rubicon.debug.cpmOverride` and `request.imp[].ext.rubicon.debug.cpmOverride` processing.
Updates tests

* Remove unnecessary error checks and add shallow copy

* Fixed same pointer

* Add Beintoo adapter (prebid#1274)

* Add Beintoo adapter

* Yeahmobi adapter (prebid#1279)

Co-authored-by: junping.zhao <junping.zhao@yeahmobi.com>

* advangelists: Vendor id update (prebid#1307)

Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>

* Consumable: Support GDPR and US Privacy consent (prebid#1300)

* Restore the AMP privacy exception as an option. (prebid#1311)

* Restore the AMP privacy exception as an option.

* Adds missing test case

* More PR feedback

* Remove unused constant

* Comment tweak

* consumable: Correct GDPR vendor ID to 591. (prebid#1309)

fixes prebid#1299.

* VIS.X: fix bid.ID, bid.CrID and set default currency value (prebid#1296)

* Fix debug log error messages (prebid#1270)

* Fixing missing error messages for debug logging

* Updated formatting of debug log message

* Updated unit tests for debug log to have test flag enabled

* Cleaned up debug log implementation

* Updates from review comments

* Cleaned up field and function names
* Added replacer for <> characters
* Added cache string unit test

* Moved regex from function to struct field

* Moved debug regex to endpoint deps

* Moving regex initialization to NewVideoEndpoint

* MobileFuse Adapter (prebid#1303)

Co-authored-by: Dan Barnett <danb@mobilefuse.com>

* eplanning: Support for apps (prebid#1306)

* Introduce Adhese adapter (prebid#1292)

Co-authored-by: Mateusz <mateusz@adhese.eu>

* privacy: Potential JSON injection (prebid#1304)

* Updating bidder params for Advangelists (prebid#1316)

* Updating placement info on bidder params

Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>

* Change placement of cpmoverride for Rubicon (prebid#1310)

* increasing the stale period to 2 months (prebid#1305)

* Add Go 1.14 Build Target (prebid#1314)

* Privacy: Remove user.ext.eids (prebid#1294)

* Privacy: Remove user.ext.eids

* Extract To A Method

* Minor Refactor + More Tests

* Performance Tweak

* Removed some redundant methods (prebid#1320)

* TELARIA adapter. First Pass

* Some refactoring

* added the json files

* fixed some tests and added the bidder info

* fixed some tests and added the bidder info

* added default user sync ur;

* - Handling gzipped responses from our server

* - more refactoring.

* added the proper user sync default URL

* changed the urls from dev to prod

* changed up the required fields. Now AdCode in the Imp.Ext isn't required but Bid.SeatCode is required

* change in the return type after decompressing

* some refactoring

* change in our config url

* using pbs.yml to switch between our production and test URLs

* setting default endpoint

* - fixed the issue that was preventing telaria test cases to run.
- added more test cases

* - Modifications as per the changes requested by the maintainers.

* Moved the seat code to imp.ext

* Moved the seat code to imp.ext

* Added 'Telaria: ' prefix for error messages

* - Fixes for race conditions. Was modifying the original request object instead of a copy

* cosmetic changes.

* added params_test.go

* Removed some redundant methods.

* Removed a comment

Co-authored-by: Vinay Prasad <vprasad@telaria.com>

* Beachfront: GDPR id (issue 1301) and documentation updates (prebid#1321)

* Defined cookie sync URL in config, cleared deprecated comment in usersync

* Update beachfront.md

* editing documentation

* updated gdpr id - issue 1301

* Add Yieldlab Adapter (prebid#1287)

Co-authored-by: Mirko Feddern <mirkorean@users.noreply.github.com>
Signed-off-by: Alex Klinkert <alex@klinkert.io>

Co-authored-by: Alexander Pinnecke <alexander.pinnecke@googlemail.com>
Co-authored-by: Alex Klinkert <alex@klinkert.io>
Co-authored-by: Mirko Feddern <mirkorean@users.noreply.github.com>

* Update adtelligent ortb endpoint (prebid#1318)

* Change on eplanning endpoint (prebid#1327)

* Enable full TCF2 support (prebid#1302)

* New config options

* Enble TCF2 fields and logic

* Resolves some PR comments

* More tests

* gofmt

* Added enforcement tests for split GDPR/GDPRGeo

* Testing tweaks

* No longer ignore enforce purpose 1 on allowSync()

* Removes Purpose 4

* Change on eplanning endpoint (hostname) (prebid#1328)

* Districtm Dmx: new adapter  (prebid#1209)

Co-authored-by: steve-a-districtm <steve@districtm.net>

* Fix sync url for Yieldone s2s Bid Adapter (prebid#1336)

* Fix typo in Yieldone sync url

* CCPA Video Bug (prebid#1333)

* Add Pubnative bidder documentation (prebid#1340)

* Timeout notification monitoring and debugging (prebid#1322)

* Add Adtarget server adapter (prebid#1319)

* Add Adtarget server adapter

* Suggested changes for Adtarget

* Update Auction OpenRTB Sample (prebid#1342)

* Update Auction OpenRTB Sample

* Removed Extra "Or"

* Triplelift: Add SRA Support (prebid#1347)

* Privacy: Limit Ad Tracking (prebid#1334)

* Avoid overriding AMP request original size with mutli-size (prebid#1352)

* Extra logging for timeout notifications (prebid#1349)

* Consumable: Correct bid type, should always be "banner". (prebid#1359)

* Build With Go 1.14 (prebid#1350)

* Category mapping changes from product team. (prebid#1348)

* Adds Avocet adapter (prebid#1354)

* AdOcean adapter - Support for sizes defined in prebid configuration. (prebid#1339)

support for multiple sizes

bump version to 1.1.0

* Log account id and all bidder names when recovering from OpenRTB auction bidder… (prebid#1358)

* Updating imports for prebid v0.116.0

* prebid_0.116.0 : Fixing merging issue for

Co-authored-by: Winston-Yieldmo <46379634+Winston-Yieldmo@users.noreply.github.com>
Co-authored-by: evanmsmrtb <evanm@smrtb.com>
Co-authored-by: CPMStar <josh@cpmstar.com>
Co-authored-by: johnwier <49074029+johnwier@users.noreply.github.com>
Co-authored-by: rpanchyk <rpanchyk@users.noreply.github.com>
Co-authored-by: Benjamin <benjamin.chastanier@gmail.com>
Co-authored-by: Kevin Kerr <kkerr@triplelift.com>
Co-authored-by: Scott Kay <noreply@syntaxnode.com>
Co-authored-by: pm-isha-bharti <isha.bharti@pubmatic.com>
Co-authored-by: Corey Kress <coreykre@buffalo.edu>
Co-authored-by: Seba Perez <sperez@est.frba.utn.edu.ar>
Co-authored-by: Cameron Rice <37162584+camrice@users.noreply.github.com>
Co-authored-by: hhhjort <31041505+hhhjort@users.noreply.github.com>
Co-authored-by: Michael Kuryshev <mk0x9@users.noreply.github.com>
Co-authored-by: Viacheslav Chimishuk <vchimishuk@yandex.ru>
Co-authored-by: Shalmali Patil <shalmali.patil@pubmatic.com>
Co-authored-by: DmitryStashkevich <34479135+DmitryStashkevich@users.noreply.github.com>
Co-authored-by: guscarreon <guscarreon@gmail.com>
Co-authored-by: TheMediaGrid <44166371+TheMediaGrid@users.noreply.github.com>
Co-authored-by: htang555 <htang555@gmail.com>
Co-authored-by: vstatkevich <v.statkevich@gmail.com>
Co-authored-by: v.statkevich <v.statkevich@adform.com>
Co-authored-by: Olga Linkevich <o.linkevich@adform.com>
Co-authored-by: Veronika Solovei <kalypsonika@gmail.com>
Co-authored-by: Veronika Solovei <veronika.solovei@xandr.com>
Co-authored-by: bretg <bgorsline@gmail.com>
Co-authored-by: thuyhq <61451682+thuyhq@users.noreply.github.com>
Co-authored-by: rhaksi-kidoz <61601767+rhaksi-kidoz@users.noreply.github.com>
Co-authored-by: Ryan Haksi <ryan.haksi@freshgrade.com>
Co-authored-by: ACannuniRP <57228257+ACannuniRP@users.noreply.github.com>
Co-authored-by: Aadesh <aadeshp95@gmail.com>
Co-authored-by: Aadesh Patel <aadesh.patel@xandr.com>
Co-authored-by: Rade Popovic <32302052+nanointeractive@users.noreply.github.com>
Co-authored-by: Dmitriy <DimaGarbar49@gmail.com>
Co-authored-by: Harbar Dmytro <dharbar@rubiconproject.com>
Co-authored-by: Telaria Engineering <36203956+telariaEng@users.noreply.github.com>
Co-authored-by: Vinay Prasad <vprasad@telaria.com>
Co-authored-by: Krzysztof Desput <dowlander@gmail.com>
Co-authored-by: Mansi Nahar <mansinahar@users.noreply.github.com>
Co-authored-by: jmaynardxandr <46759873+jmaynardxandr@users.noreply.github.com>
Co-authored-by: hbanalytics <55453525+hbanalytics@users.noreply.github.com>
Co-authored-by: chino117 <chino117@hotmail.com>
Co-authored-by: Ad Generation <AdGeneration@users.noreply.github.com>
Co-authored-by: trchandraprakash <47793448+trchandraprakash@users.noreply.github.com>
Co-authored-by: Chandra Prakash <chandra.prakash@advangelists.com>
Co-authored-by: Mike Chowla <mchowla@gmail.com>
Co-authored-by: Taiki Sakamoto <godgourd@gmail.com>
Co-authored-by: Laurentiu Badea <laurb9@users.noreply.github.com>
Co-authored-by: Marcin Muras <47107445+mmuras@users.noreply.github.com>
Co-authored-by: Mathieu Pheulpin <mpheulpin@sharethrough.com>
Co-authored-by: Benjamin <b.chastanier@criteo.com>
Co-authored-by: ah-tappx <46002207+ah-tappx@users.noreply.github.com>
Co-authored-by: Marsel <taipovm@gmail.com>
Co-authored-by: Austin Bischoff <Austinb@users.noreply.github.com>
Co-authored-by: Florian Hartwig <florian.hartwig@pubnative.net>
Co-authored-by: Salomon Rada <salomon@gamoshi.com>
Co-authored-by: vladi-mmg <vladi@m-m-g.com>
Co-authored-by: Aleksei Lin <aleksey@incsw.in>
Co-authored-by: Arne Schulz <arne.schulz@otto.de>
Co-authored-by: Volk, Rainer <Rainer.Volk@otto.de>
Co-authored-by: RainerVolk4014 <53347752+RainerVolk4014@users.noreply.github.com>
Co-authored-by: Hendrik Iseke <hendrik.iseke@gmx.de>
Co-authored-by: hendrikiseke1979 <53309111+hendrikiseke1979@users.noreply.github.com>
Co-authored-by: Jimmy Tu <jimee02@users.noreply.github.com>
Co-authored-by: ddantuonobeintoo <58686785+ddantuonobeintoo@users.noreply.github.com>
Co-authored-by: zhaojp <327199034@qq.com>
Co-authored-by: junping.zhao <junping.zhao@yeahmobi.com>
Co-authored-by: Daniel Cassidy <mail@danielcassidy.me.uk>
Co-authored-by: dtbarne <7635750+dtbarne@users.noreply.github.com>
Co-authored-by: Dan Barnett <danb@mobilefuse.com>
Co-authored-by: Sander <sander@adhese.eu>
Co-authored-by: Mateusz <mateusz@adhese.eu>
Co-authored-by: Jim Naumann <muncha@users.noreply.github.com>
Co-authored-by: Mirko Feddern <3244291+mirkorean@users.noreply.github.com>
Co-authored-by: Alexander Pinnecke <alexander.pinnecke@googlemail.com>
Co-authored-by: Alex Klinkert <alex@klinkert.io>
Co-authored-by: Mirko Feddern <mirkorean@users.noreply.github.com>
Co-authored-by: Gena <wertixvost@gmail.com>
Co-authored-by: Steve Alliance <steve.alliance@gmail.com>
Co-authored-by: steve-a-districtm <steve@districtm.net>
Co-authored-by: Artur Aleksanyan <artur.aleksanyan89@gmail.com>
Co-authored-by: Brandon Ling <51931757+blingster7@users.noreply.github.com>
Co-authored-by: Richard Lee <14349+dlackty@users.noreply.github.com>
Co-authored-by: Simon Critchley <sicritchley@gmail.com>
Co-authored-by: Brian Sardo <1168933+bsardo@users.noreply.github.com>
  • Loading branch information
Show file tree
Hide file tree
Showing 722 changed files with 36,057 additions and 3,346 deletions.
12 changes: 7 additions & 5 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 7
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
pulls:
daysUntilStale: 7
daysUntilClose: 30
issues:
daysUntilStale: 30
daysUntilClose: 60
# Items with these labels will never be considered stale
exemptLabels:
- pinned
- security
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ debug
pbs.*
inventory_url.yaml

# generated log files during tests
analytics/config/testFiles/
analytics/filesystem/testFiles/

# autogenerated version file
# static/version.txt

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go

go:
- '1.12'
- '1.13'
- '1.14.2'

go_import_path: github.com/PubMatic-OpenWrap/prebid-server

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y wget
RUN cd /tmp && \
wget https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz && \
tar -xf go1.12.7.linux-amd64.tar.gz && \
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz && \
tar -xf go1.14.2.linux-amd64.tar.gz && \
mv go /usr/local
RUN mkdir -p /app/prebid-server/
WORKDIR /app/prebid-server/
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/PubMatic-OpenWrap/prebid-server.svg?branch=master)](https://travis-ci.org/PubMatic-OpenWrap/prebid-server)
[![Build Status](https://travis-ci.org/prebid/prebid-server.svg?branch=master)](https://travis-ci.org/prebid/prebid-server)
[![Go Report Card](https://goreportcard.com/badge/github.com/PubMatic-OpenWrap/prebid-server?style=flat-square)](https://goreportcard.com/report/github.com/PubMatic-OpenWrap/prebid-server)

# Prebid Server
Expand All @@ -18,9 +18,10 @@ For more information, see:

## Installation

First install [Go 1.12](https://golang.org/doc/install) latest version.
First install [Go](https://golang.org/doc/install) version 1.13 or newer.

Note that prebid-server is using [Go modules](https://blog.golang.org/using-go-modules).
If using Go version <1.13 and are inside GOPATH `GO111MODULE` needs to be set to `GO111MODULE=on`.
We officially support the most recent two major versions of the Go runtime. However, if you'd like to use a version <1.13 and are inside GOPATH `GO111MODULE` needs to be set to `GO111MODULE=on`.

Download and prepare Prebid Server:

Expand Down
4 changes: 2 additions & 2 deletions adapters/adapterstest/test_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func diffErrorLists(t *testing.T, description string, actual []error, expected [
t.Helper()

if len(expected) != len(actual) {
t.Fatalf("%s had wrong error count. Expected %d, got %d", description, len(expected), len(actual))
t.Fatalf("%s had wrong error count. Expected %d, got %d (%v)", description, len(expected), len(actual), actual)
}
for i := 0; i < len(actual); i++ {
if expected[i].Comparison == "literal" {
Expand Down Expand Up @@ -301,7 +301,7 @@ func diffJson(t *testing.T, description string, actual []byte, expected []byte)
if diff.Modified() {
var left interface{}
if err := json.Unmarshal(actual, &left); err != nil {
t.Fatalf("%s json did not match, but unmarhsalling failed. %v", description, err)
t.Fatalf("%s json did not match, but unmarshalling failed. %v", description, err)
}
printer := formatter.NewAsciiFormatter(left, formatter.AsciiFormatterConfig{
ShowArrayIndex: true,
Expand Down
260 changes: 260 additions & 0 deletions adapters/adgeneration/adgeneration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
package adgeneration

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"

"github.com/PubMatic-OpenWrap/openrtb"
"github.com/PubMatic-OpenWrap/prebid-server/adapters"
"github.com/PubMatic-OpenWrap/prebid-server/errortypes"
"github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext"
)

type AdgenerationAdapter struct {
endpoint string
version string
defaultCurrency string
}

// Server Responses
type adgServerResponse struct {
Locationid string `json:"locationid"`
Dealid string `json:"dealid"`
Ad string `json:"ad"`
Beacon string `json:"beacon"`
Beaconurl string `json:"beaconurl"`
Cpm float64 `jsons:"cpm"`
Creativeid string `json:"creativeid"`
H uint64 `json:"h"`
W uint64 `json:"w"`
Ttl uint64 `json:"ttl"`
Vastxml string `json:"vastxml,omitempty"`
LandingUrl string `json:"landing_url"`
Scheduleid string `json:"scheduleid"`
Results []interface{} `json:"results"`
}

func (adg *AdgenerationAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
numRequests := len(request.Imp)
var errs []error

if numRequests == 0 {
errs = append(errs, &errortypes.BadInput{
Message: "No impression in the bid request",
})
return nil, errs
}

headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")

bidRequestArray := make([]*adapters.RequestData, 0, numRequests)

for index := 0; index < numRequests; index++ {
bidRequestUri, err := adg.getRequestUri(request, index)
if err != nil {
errs = append(errs, err)
return nil, errs
}
bidRequest := &adapters.RequestData{
Method: "GET",
Uri: bidRequestUri,
Body: nil,
Headers: headers,
}
bidRequestArray = append(bidRequestArray, bidRequest)
}

return bidRequestArray, errs
}

func (adg *AdgenerationAdapter) getRequestUri(request *openrtb.BidRequest, index int) (string, error) {
imp := request.Imp[index]
adgExt, err := unmarshalExtImpAdgeneration(&imp)
if err != nil {
return "", &errortypes.BadInput{
Message: err.Error(),
}
}
uriObj, err := url.Parse(adg.endpoint)
if err != nil {
return "", &errortypes.BadInput{
Message: err.Error(),
}
}
v := adg.getRawQuery(adgExt.Id, request, &imp)
uriObj.RawQuery = v.Encode()
return uriObj.String(), err
}

func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb.BidRequest, imp *openrtb.Imp) *url.Values {
v := url.Values{}
v.Set("posall", "SSPLOC")
v.Set("id", id)
v.Set("sdktype", "0")
v.Set("hb", "true")
v.Set("t", "json3")
v.Set("currency", adg.getCurrency(request))
v.Set("sdkname", "prebidserver")
v.Set("adapterver", adg.version)
adSize := getSizes(imp)
if adSize != "" {
v.Set("size", adSize)
}
if request.Site != nil && request.Site.Page != "" {
v.Set("tp", request.Site.Page)
}
return &v
}

func unmarshalExtImpAdgeneration(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdgeneration, error) {
var bidderExt adapters.ExtImpBidder
var adgExt openrtb_ext.ExtImpAdgeneration
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return nil, err
}
if err := json.Unmarshal(bidderExt.Bidder, &adgExt); err != nil {
return nil, err
}
if adgExt.Id == "" {
return nil, errors.New("No Location ID in ExtImpAdgeneration.")
}
return &adgExt, nil
}

func getSizes(imp *openrtb.Imp) string {
if imp.Banner == nil || len(imp.Banner.Format) == 0 {
return ""
}
var sizeStr string
for _, v := range imp.Banner.Format {
sizeStr += strconv.FormatUint(v.W, 10) + "×" + strconv.FormatUint(v.H, 10) + ","
}
if len(sizeStr) > 0 && strings.LastIndex(sizeStr, ",") == len(sizeStr)-1 {
sizeStr = sizeStr[:len(sizeStr)-1]
}
return sizeStr
}

func (adg *AdgenerationAdapter) getCurrency(request *openrtb.BidRequest) string {
if len(request.Cur) <= 0 {
return adg.defaultCurrency
} else {
for _, c := range request.Cur {
if adg.defaultCurrency == c {
return c
}
}
return request.Cur[0]
}
}

func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if response.StatusCode == http.StatusNoContent {
return nil, nil
}
if response.StatusCode == http.StatusBadRequest {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),
}}
}
if response.StatusCode != http.StatusOK {
return nil, []error{&errortypes.BadServerResponse{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),
}}
}
var bidResp adgServerResponse
err := json.Unmarshal(response.Body, &bidResp)
if err != nil {
return nil, []error{err}
}
if len(bidResp.Results) <= 0 {
return nil, nil
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)
var impId string
var bitType openrtb_ext.BidType
var adm string
for _, v := range internalRequest.Imp {
adgExt, err := unmarshalExtImpAdgeneration(&v)
if err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: err.Error(),
},
}
}
if adgExt.Id == bidResp.Locationid {
impId = v.ID
bitType = openrtb_ext.BidTypeBanner
adm = createAd(&bidResp, impId)
bid := openrtb.Bid{
ID: bidResp.Locationid,
ImpID: impId,
AdM: adm,
Price: bidResp.Cpm,
W: bidResp.W,
H: bidResp.H,
CrID: bidResp.Creativeid,
DealID: bidResp.Dealid,
}

bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: bitType,
})
return bidResponse, nil
}
}
return nil, nil
}

func createAd(body *adgServerResponse, impId string) string {
ad := body.Ad
if body.Vastxml != "" {
ad = "<body><div id=\"apvad-" + impId + "\"></div><script type=\"text/javascript\" id=\"apv\" src=\"https://cdn.apvdr.com/js/VideoAd.min.js\"></script>" + insertVASTMethod(impId, body.Vastxml) + "</body>"
}
ad = appendChildToBody(ad, body.Beacon)
unwrappedAd := removeWrapper(ad)
if unwrappedAd != "" {
return unwrappedAd
}
return ad
}

func insertVASTMethod(bidId string, vastxml string) string {
rep := regexp.MustCompile(`/\r?\n/g`)
var replacedVastxml = rep.ReplaceAllString(vastxml, "")
return "<script type=\"text/javascript\"> (function(){ new APV.VideoAd({s:\"" + bidId + "\"}).load('" + replacedVastxml + "'); })(); </script>"
}

func appendChildToBody(ad string, data string) string {
rep := regexp.MustCompile(`<\/\s?body>`)
return rep.ReplaceAllString(ad, data+"</body>")
}

func removeWrapper(ad string) string {
bodyIndex := strings.Index(ad, "<body>")
lastBodyIndex := strings.LastIndex(ad, "</body>")
if bodyIndex == -1 || lastBodyIndex == -1 {
return ""
}

str := strings.TrimSpace(strings.Replace(strings.Replace(ad[bodyIndex:lastBodyIndex], "<body>", "", 1), "</body>", "", 1))
return str
}

func NewAdgenerationAdapter(endpoint string) *AdgenerationAdapter {
return &AdgenerationAdapter{
endpoint,
"1.0.0",
"JPY",
}
}
Loading

0 comments on commit 14da3a2

Please sign in to comment.