Skip to content

Commit

Permalink
Refactor and check app.publisher.domain for msn.com
Browse files Browse the repository at this point in the history
  • Loading branch information
bsardo committed Jul 26, 2024
1 parent 8ff11b6 commit bb20271
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions adapters/triplelift_native/triplelift_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ func processImp(imp *openrtb2.Imp, request *openrtb2.BidRequest) error {
// get the triplelift extension
var ext ExtImp
var tlext openrtb_ext.ExtImpTriplelift
var siteCopy openrtb2.Site
var extData ExtImpData

if request.Site != nil {
siteCopy = *request.Site
}

if err := json.Unmarshal(imp.Ext, &ext); err != nil {
return err
Expand All @@ -66,32 +60,32 @@ func processImp(imp *openrtb2.Imp, request *openrtb2.BidRequest) error {
if imp.Native == nil {
return fmt.Errorf("no native object specified")
}
if tlext.InvCode == "" {
return fmt.Errorf("no inv_code specified")
}

if ext.Data != nil {
extData = *ext.Data
}

if extData.TagCode != "" {
if siteCopy.Publisher != nil && siteCopy.Publisher.Domain == "msn.com" {
imp.TagID = extData.TagCode
} else {
imp.TagID = tlext.InvCode
}
if ext.Data != nil && len(ext.Data.TagCode) > 0 && (msnInSite(request) || msnInApp(request)) {
imp.TagID = ext.Data.TagCode
} else {
imp.TagID = tlext.InvCode
}

// floor is optional
if tlext.Floor == nil {
return nil
}
imp.BidFloor = *tlext.Floor
// no error

return nil
}

// msnInApp returns whether msn.com is in request.app.publisher.domain
func msnInApp(request *openrtb2.BidRequest) bool {
return request.App != nil && request.App.Publisher != nil && request.App.Publisher.Domain == "msn.com"
}

// msnInSite returns whether msn.com is in request.site.publisher.domain
func msnInSite(request *openrtb2.BidRequest) bool {
return request.Site != nil && request.Site.Publisher != nil && request.Site.Publisher.Domain == "msn.com"
}

// Returns the effective publisher ID
func effectivePubID(pub *openrtb2.Publisher) string {
if pub != nil {
Expand Down

0 comments on commit bb20271

Please sign in to comment.