Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 40 additions & 22 deletions adapters/rtbhouse/rtbhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ func (adapter *RTBHouseAdapter) MakeRequests(
var publisherId string

for _, imp := range openRTBRequest.Imp {
rtbhouseExt, err := getImpressionExt(imp)
var impExtMap map[string]interface{}
err := jsonutil.Unmarshal(imp.Ext, &impExtMap)
if err != nil {
return nil, []error{&errortypes.BadInput{
Message: "Bidder extension not provided or can't be unmarshalled",
}}
}

rtbhouseExt, err := getImpressionExt(imp.Ext)
if err != nil {
return nil, []error{err}
}
Expand Down Expand Up @@ -100,9 +108,13 @@ func (adapter *RTBHouseAdapter) MakeRequests(
imp.BidFloor = bidFloor
}

// remove PAAPI signals from imp.Ext. RTB House pauses PAAPI support,
// the bidder should not get any PAAPI signals
newImpExt, err := clearAuctionEnvironment(&imp)
if imp.TagID == "" {
imp.TagID = getTagIDFromImpExt(impExtMap, imp.ID)
}

// remove PAAPI signals
clearAuctionEnvironment(impExtMap)
newImpExt, err := jsonutil.Marshal(impExtMap)
if err != nil {
errs = append(errs, err)
return nil, errs
Expand Down Expand Up @@ -199,32 +211,39 @@ func setPublisherID(request *openrtb2.BidRequest, publisherId string) error {
return nil
}

func clearAuctionEnvironment(imp *openrtb2.Imp) (json.RawMessage, error) {
var objmap map[string]interface{}
err := json.Unmarshal(imp.Ext, &objmap)
if err != nil {
return nil, err
}

func clearAuctionEnvironment(impExtMap map[string]interface{}) {
keysToDelete := []string{"ae", "igs", "paapi"}
for _, key := range keysToDelete {
_, exists := objmap[key]
if exists {
delete(objmap, key)
}
delete(impExtMap, key)
}
}

newImpExt, err := json.Marshal(objmap)
if err != nil {
return nil, err
func getTagIDFromImpExt(impExtMap map[string]interface{}, impID string) string {
if gpid, ok := impExtMap["gpid"].(string); ok && gpid != "" {
return gpid
}

return newImpExt, nil
dataMap, hasData := impExtMap["data"].(map[string]interface{})
if hasData {
// imp.ext.data.adserver.adslot
if adserver, ok := dataMap["adserver"].(map[string]interface{}); ok {
if adslot, ok := adserver["adslot"].(string); ok && adslot != "" {
return adslot
}
}

if pbAdSlot, ok := dataMap["pbadslot"].(string); ok && pbAdSlot != "" {
return pbAdSlot
}
}

// imp.ID as fallback
return impID
}

func getImpressionExt(imp openrtb2.Imp) (*openrtb_ext.ExtImpRTBHouse, error) {
func getImpressionExt(impExt json.RawMessage) (*openrtb_ext.ExtImpRTBHouse, error) {
var bidderExt adapters.ExtImpBidder
if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil {
if err := jsonutil.Unmarshal(impExt, &bidderExt); err != nil {
return nil, &errortypes.BadInput{
Message: "Bidder extension not provided or can't be unmarshalled",
}
Expand All @@ -236,7 +255,6 @@ func getImpressionExt(imp openrtb2.Imp) (*openrtb_ext.ExtImpRTBHouse, error) {
Message: "Error while unmarshaling bidder extension",
}
}

return &rtbhouseExt, nil
}

Expand Down
3 changes: 2 additions & 1 deletion adapters/rtbhouse/rtbhousetest/exemplary/ae-igs-removal.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
],
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
Expand All @@ -50,7 +51,7 @@
},
"someOtherField": "should-remain"
},
"id": "test-imp-id"
"tagid": "test-imp-id"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"publisherId": "app-publisher-123"
}
},
"id": "test-imp-id"
"id": "test-imp-id",
"tagid": "test-imp-id"
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion adapters/rtbhouse/rtbhousetest/exemplary/app_banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
},
"ext": {
"bidder": {}
}
},
"tagid": "test-imp-id"
}]
},
"impIDs":["test-imp-id"]
Expand Down
3 changes: 2 additions & 1 deletion adapters/rtbhouse/rtbhousetest/exemplary/app_native.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
},
"ext": {
"bidder": {}
}
},
"tagid": "test-native-imp"
}
],
"app": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
},
"ext": {
"bidder": {}
}
},
"tagid": "test-imp-id"
}]
},
"impIDs":["test-imp-id"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"bidfloor": 3.00
}
},
"id": "test-imp-id"
"id": "test-imp-id",
"tagid": "test-imp-id"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"bidfloor": 2
}
},
"id": "test-imp-id"
"id": "test-imp-id",
"tagid": "test-imp-id"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"publisherId": "12345"
}
},
"id": "test-imp-id"
"id": "test-imp-id",
"tagid": "test-imp-id"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"publisherId": "12345"
}
},
"id": "test-imp-id"
"id": "test-imp-id",
"tagid": "test-imp-id"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"publisherId": "new-publisher-123"
}
},
"id": "test-imp-id"
"id": "test-imp-id",
"tagid": "test-imp-id"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"publisherId": "first-publisher"
}
},
"id": "test-imp-id-1"
"id": "test-imp-id-1",
"tagid": "test-imp-id-1"
},
{
"banner": {
Expand All @@ -76,7 +77,8 @@
"publisherId": "second-publisher"
}
},
"id": "test-imp-id-2"
"id": "test-imp-id-2",
"tagid": "test-imp-id-2"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
},
"ext": {
"bidder": {}
}
},
"tagid": "test-native-imp"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
},
"ext": {
"bidder": {}
}
},
"tagid": "test-native-imp"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"publisherId": "12345"
}
},
"id": "test-imp-id"
"id": "test-imp-id",
"tagid": "test-imp-id"
}
],
"site": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
},
"ext": {
"bidder": {}
}
},
"tagid": "test-imp-id"
}]
},
"impIDs":["test-imp-id"]
Expand Down
3 changes: 2 additions & 1 deletion adapters/rtbhouse/rtbhousetest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
},
"ext": {
"bidder": {}
}
},
"tagid": "test-imp-id"
}]
},
"impIDs":["test-imp-id"]
Expand Down
Loading
Loading