Skip to content

Commit

Permalink
Update convert_up.go
Browse files Browse the repository at this point in the history
  • Loading branch information
patmmccann authored Feb 19, 2025
1 parent db094fd commit b591ca3
Showing 1 changed file with 42 additions and 43 deletions.
85 changes: 42 additions & 43 deletions openrtb_ext/convert_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,51 +147,50 @@ func moveUSPrivacyFrom25To26(r *RequestWrapper) {

// moveEIDFrom25To26 modifies the request to move the OpenRTB 2.5 external identifiers
// (req.user.ext.eids) to the OpenRTB 2.6 location (req.user.eids). If the OpenRTB 2.6
// location is already present the OpenRTB 2.5 external identifiers are appended for
// location is already present the OpenRTB 2.5 external identifiers are appended for
// sources not already in the eids array
func moveEIDFrom25To26(r *RequestWrapper) {
// Read 2.5 location
userExt, _ := r.GetUserExt()
eids25 := userExt.GetEid()

// Clear 2.5 location
userExt.SetEid(nil)

// If there's no eids25, there's nothing to move or merge
if eids25 == nil || len(*eids25) == 0 {
return
}

// If there's no 2.6 location, simply set eids
if r.User.EIDs == nil {
r.User.EIDs = *eids25
return
}

// If 2.6 location is present, append only new eids based on 'source'
existingEIDs := r.User.EIDs
for _, eid25 := range *eids25 {
// We only compare if both 'source' fields are non-nil.
// Adjust logic if you need to handle nil sources differently.
if eid25.Source == nil {
// If your spec allows a nil source and you want to handle it,
// you may choose to always append or skip. Example: always append:
existingEIDs = append(existingEIDs, eid25)
continue
}

found := false
for _, eid26 := range existingEIDs {
if eid26.Source != nil && *eid25.Source == *eid26.Source {
found = true
break
}
}
if !found {
existingEIDs = append(existingEIDs, eid25)
}
}
r.User.EIDs = existingEIDs
// Read 2.5 location
userExt, _ := r.GetUserExt()
eids25 := userExt.GetEid()

// Clear 2.5 location
userExt.SetEid(nil)

// If there's no eids25, there's nothing to move or merge
if eids25 == nil || len(*eids25) == 0 {
return
}

// If there's no 2.6 location, simply set eids
if r.User.EIDs == nil {
r.User.EIDs = *eids25
return
}

// If 2.6 location is present, append only new eids based on 'source'
existingEIDs := r.User.EIDs
for _, eid25 := range *eids25 {
// We only compare if both 'source' fields are non-nil.
// Adjust this if you need special handling for nil sources.
if eid25.Source == nil {

Check failure on line 176 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate-merge

invalid operation: eid25.Source == nil (mismatched types string and untyped nil)

Check failure on line 176 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.22.x, ubuntu-20.04)

invalid operation: eid25.Source == nil (mismatched types string and untyped nil)

Check failure on line 176 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.23.x, ubuntu-20.04)

invalid operation: eid25.Source == nil (mismatched types string and untyped nil)
// Example: always append if source is nil:
existingEIDs = append(existingEIDs, eid25)
continue
}

found := false
for _, eid26 := range existingEIDs {
if eid26.Source != nil && *eid25.Source == *eid26.Source {

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate-merge

invalid operation: eid26.Source != nil (mismatched types string and untyped nil)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate-merge

invalid operation: cannot indirect eid25.Source (variable of type string)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate-merge

invalid operation: cannot indirect eid26.Source (variable of type string)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.22.x, ubuntu-20.04)

invalid operation: eid26.Source != nil (mismatched types string and untyped nil)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.22.x, ubuntu-20.04)

invalid operation: cannot indirect eid25.Source (variable of type string)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.22.x, ubuntu-20.04)

invalid operation: cannot indirect eid26.Source (variable of type string)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.23.x, ubuntu-20.04)

invalid operation: eid26.Source != nil (mismatched types string and untyped nil)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.23.x, ubuntu-20.04)

invalid operation: cannot indirect eid25.Source (variable of type string)

Check failure on line 184 in openrtb_ext/convert_up.go

View workflow job for this annotation

GitHub Actions / validate (1.23.x, ubuntu-20.04)

invalid operation: cannot indirect eid26.Source (variable of type string)
found = true
break
}
}
if !found {
existingEIDs = append(existingEIDs, eid25)
}
}
r.User.EIDs = existingEIDs
}

// moveRewardedFromPrebidExtTo26 modifies the impression to move the Prebid specific
Expand Down

0 comments on commit b591ca3

Please sign in to comment.