-
Notifications
You must be signed in to change notification settings - Fork 237
LI module: Use matcher instead of source for eid premission #4487
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
Open
peixunzhang
wants to merge
11
commits into
prebid:master
Choose a base branch
from
LiveIntent:DATA-46376
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5d02835
DATA-46376
peixunzhang 07bd873
rename
peixunzhang 2b5c693
refactor n test
peixunzhang 1c2fba3
inden
peixunzhang 96b8f2a
use exist stamp from ulysses
peixunzhang 2f68568
only use to check
peixunzhang cb27009
fix tests and set default
peixunzhang c105fbf
adjust comment
peixunzhang 504884e
test
peixunzhang 17f1ae3
lint
peixunzhang eeb9146
comments
peixunzhang 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 hidden or 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 |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| import org.apache.commons.collections4.CollectionUtils; | ||
| import org.apache.commons.collections4.ListUtils; | ||
| import org.apache.commons.collections4.SetUtils; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.prebid.server.activity.Activity; | ||
| import org.prebid.server.activity.ComponentType; | ||
| import org.prebid.server.activity.infrastructure.ActivityInfrastructure; | ||
|
|
@@ -50,7 +49,6 @@ | |
| import java.util.Optional; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ThreadLocalRandom; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class LiveIntentOmniChannelIdentityProcessedAuctionRequestHook implements ProcessedAuctionRequestHook { | ||
|
|
||
|
|
@@ -61,6 +59,9 @@ public class LiveIntentOmniChannelIdentityProcessedAuctionRequestHook implements | |
|
|
||
| private static final String INSERTER = "s2s.liveintent.com"; | ||
|
|
||
| // IdResResponse is already stamped by Ulysses, in the EID's matcher field, it has "liveintent.com" | ||
| private static final String MATCHER = "liveintent.com"; | ||
|
|
||
| private final LiveIntentOmniChannelProperties config; | ||
| private final JacksonMapper mapper; | ||
| private final HttpClient httpClient; | ||
|
|
@@ -216,19 +217,19 @@ private BidRequest updateBidRequest(BidRequest bidRequest, List<Eid> resolvedEid | |
| } | ||
|
|
||
| private ExtRequest updateExtRequest(ExtRequest ext, List<Eid> resolvedEids) { | ||
| final Set<String> uniqueSources = CollectionUtils.emptyIfNull(resolvedEids).stream() | ||
| .map(Eid::getSource) | ||
| .filter(StringUtils::isNotEmpty) | ||
| .collect(Collectors.toSet()); | ||
| if (CollectionUtils.isEmpty(resolvedEids)) { | ||
| return ext; | ||
| } | ||
|
|
||
| final ExtRequestPrebid extPrebid = ext != null ? ext.getPrebid() : null; | ||
| final ExtRequestPrebidData extPrebidData = extPrebid != null ? extPrebid.getData() : null; | ||
| final List<ExtRequestPrebidDataEidPermissions> eidPermissions = | ||
| extPrebidData != null ? extPrebidData.getEidPermissions() : null; | ||
|
|
||
| final List<ExtRequestPrebidDataEidPermissions> modifiedEidPermissions = CollectionUtils.isEmpty(eidPermissions) | ||
| ? createEidPermissions(uniqueSources) | ||
| : modifyEidPermissions(eidPermissions, uniqueSources); | ||
| final List<ExtRequestPrebidDataEidPermissions> modifiedEidPermissions = CollectionUtils | ||
| .isEmpty(eidPermissions) | ||
| ? createEidPermissions() | ||
| : modifyEidPermissions(eidPermissions); | ||
|
|
||
| final ExtRequestPrebid updatedExtPrebid = Optional.ofNullable(extPrebid) | ||
| .map(ExtRequestPrebid::toBuilder) | ||
|
|
@@ -257,24 +258,21 @@ private static User updateUser(User user, List<Eid> resolvedEids) { | |
| .build(); | ||
| } | ||
|
|
||
| private List<ExtRequestPrebidDataEidPermissions> createEidPermissions(Set<String> sources) { | ||
| return sources.stream() | ||
| .map(source -> ExtRequestPrebidDataEidPermissions.builder() | ||
| .source(source) | ||
| .inserter(INSERTER) | ||
| .bidders(targetBidders.stream().toList()) | ||
| .build()) | ||
| .toList(); | ||
| private List<ExtRequestPrebidDataEidPermissions> createEidPermissions() { | ||
| return List.of(ExtRequestPrebidDataEidPermissions.builder() | ||
|
Collaborator
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.
|
||
| .matcher(MATCHER) | ||
| .inserter(INSERTER) | ||
| .bidders(targetBidders.stream().toList()) | ||
| .build()); | ||
| } | ||
|
|
||
| private List<ExtRequestPrebidDataEidPermissions> modifyEidPermissions( | ||
| List<ExtRequestPrebidDataEidPermissions> eidPermissions, | ||
| Set<String> sources) { | ||
| List<ExtRequestPrebidDataEidPermissions> eidPermissions) { | ||
| final List<ExtRequestPrebidDataEidPermissions> modifiedEidPermissions = eidPermissions.stream() | ||
| .map(it -> updateEidPermission(it, sources)) | ||
| .filter(Objects::nonNull) | ||
| .toList(); | ||
| final List<ExtRequestPrebidDataEidPermissions> defaultEidPermissions = createEidPermissions(sources); | ||
| .map(this::updateEidPermission) | ||
| .filter(Objects::nonNull) | ||
| .toList(); | ||
| final List<ExtRequestPrebidDataEidPermissions> defaultEidPermissions = createEidPermissions(); | ||
| return ListUtils.union(modifiedEidPermissions, defaultEidPermissions); | ||
| } | ||
|
|
||
|
|
@@ -286,10 +284,9 @@ private ExtRequestPrebidData updatePrebidData(ExtRequestPrebidData extPrebidData | |
| return ExtRequestPrebidData.of(originalBidders, eidPermissions); | ||
| } | ||
|
|
||
| private ExtRequestPrebidDataEidPermissions updateEidPermission(ExtRequestPrebidDataEidPermissions eidPermission, | ||
| Set<String> sources) { | ||
| if (!sources.contains(eidPermission.getSource()) || !INSERTER.equals(eidPermission.getInserter())) { | ||
| return eidPermission; | ||
| private ExtRequestPrebidDataEidPermissions updateEidPermission(ExtRequestPrebidDataEidPermissions eidPermission) { | ||
| if (!MATCHER.equals(eidPermission.getMatcher()) || !INSERTER.equals(eidPermission.getInserter())) { | ||
| return eidPermission; | ||
| } | ||
|
|
||
| final List<String> allowedBidders = ListUtils.emptyIfNull(eidPermission.getBidders()); | ||
|
|
||
This file contains hidden or 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
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.
One-line it