-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smaato: Send imp.ext object entirely #3995
Merged
bsardo
merged 3 commits into
prebid:master
from
smaato:feature/PREB-42_O_add_gpid_support
Dec 10, 2024
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ import ( | |
"github.com/prebid/prebid-server/v2/util/timeutil" | ||
) | ||
|
||
const clientVersion = "prebid_server_1.1" | ||
const clientVersion = "prebid_server_1.2" | ||
|
||
type adMarkupType string | ||
|
||
|
@@ -471,14 +471,13 @@ func setImpForAdspace(imp *openrtb2.Imp) error { | |
return &errortypes.BadInput{Message: "Missing adspaceId parameter."} | ||
} | ||
|
||
impExt, err := makeImpExt(&imp.Ext) | ||
err = removeBidderNodeFromImpExt(imp) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if imp.Banner != nil || imp.Video != nil || imp.Native != nil { | ||
imp.TagID = adSpaceID | ||
imp.Ext = impExt | ||
return nil | ||
} | ||
|
||
|
@@ -490,15 +489,17 @@ func setImpForAdBreak(imps []openrtb2.Imp) error { | |
return &errortypes.BadInput{Message: "No impressions in bid request."} | ||
} | ||
|
||
adBreakID, err := jsonparser.GetString(imps[0].Ext, "bidder", "adbreakId") | ||
firstImp := imps[0] | ||
adBreakID, err := jsonparser.GetString(firstImp.Ext, "bidder", "adbreakId") | ||
if err != nil { | ||
return &errortypes.BadInput{Message: "Missing adbreakId parameter."} | ||
} | ||
|
||
impExt, err := makeImpExt(&imps[0].Ext) | ||
err = removeBidderNodeFromImpExt(&firstImp) | ||
if err != nil { | ||
return err | ||
} | ||
ext := firstImp.Ext | ||
|
||
for i := range imps { | ||
imps[i].TagID = adBreakID | ||
|
@@ -512,33 +513,33 @@ func setImpForAdBreak(imps []openrtb2.Imp) error { | |
imps[i].Video = &videoCopy | ||
} | ||
|
||
imps[0].Ext = impExt | ||
imps[0].Ext = ext | ||
|
||
return nil | ||
} | ||
|
||
func makeImpExt(impExtRaw *json.RawMessage) (json.RawMessage, error) { | ||
var impExt openrtb_ext.ExtImpExtraDataSmaato | ||
|
||
if err := json.Unmarshal(*impExtRaw, &impExt); err != nil { | ||
return nil, &errortypes.BadInput{Message: "Invalid imp.ext."} | ||
func removeBidderNodeFromImpExt(imp *openrtb2.Imp) error { | ||
if imp.Ext == nil { | ||
return nil | ||
} | ||
updatedExt := jsonparser.Delete(imp.Ext, "bidder") | ||
isEmpty := true | ||
err := jsonparser.ObjectEach(updatedExt, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error { | ||
isEmpty = false | ||
return nil | ||
}) | ||
Comment on lines
+527
to
+530
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 this is an interesting approach. I imagine this is much faster than unmarshaling to a map and checking the length. |
||
|
||
if impExtSkadnRaw := impExt.Skadn; impExtSkadnRaw != nil { | ||
var impExtSkadn map[string]json.RawMessage | ||
|
||
if err := json.Unmarshal(impExtSkadnRaw, &impExtSkadn); err != nil { | ||
return nil, &errortypes.BadInput{Message: "Invalid imp.ext.skadn."} | ||
} | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if impExtJson, err := json.Marshal(impExt); string(impExtJson) != "{}" { | ||
return impExtJson, err | ||
if isEmpty { | ||
imp.Ext = nil | ||
} else { | ||
return nil, nil | ||
imp.Ext = updatedExt | ||
} | ||
return nil | ||
} | ||
|
||
func groupImpressionsByPod(imps []openrtb2.Imp) (map[string]([]openrtb2.Imp), []string, []error) { | ||
pods := make(map[string][]openrtb2.Imp) | ||
orderKeys := make([]string, 0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
adapters/smaato/smaatotest/supplemental/bad-skadn-format-request.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I think you can get rid of the
ext
variable and instead just assignfirstImp.Ext
toimps[0].Ext
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed