forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DSA: Inject default in bid requests if not present (prebid#3540)
- Loading branch information
Showing
15 changed files
with
910 additions
and
22 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dsa | ||
|
||
import ( | ||
"github.com/prebid/prebid-server/v2/config" | ||
"github.com/prebid/prebid-server/v2/openrtb_ext" | ||
) | ||
|
||
// Writer is used to write the default DSA to the request (req.regs.ext.dsa) | ||
type Writer struct { | ||
Config *config.AccountDSA | ||
GDPRInScope bool | ||
} | ||
|
||
// Write sets the default DSA object on the request at regs.ext.dsa if it is | ||
// defined in the account config and it is not already present on the request | ||
func (dw Writer) Write(req *openrtb_ext.RequestWrapper) error { | ||
if req == nil || getReqDSA(req) != nil { | ||
return nil | ||
} | ||
if dw.Config == nil || dw.Config.DefaultUnpacked == nil { | ||
return nil | ||
} | ||
if dw.Config.GDPROnly && !dw.GDPRInScope { | ||
return nil | ||
} | ||
regExt, err := req.GetRegExt() | ||
if err != nil { | ||
return err | ||
} | ||
clonedDefaultUnpacked := dw.Config.DefaultUnpacked.Clone() | ||
regExt.SetDSA(clonedDefaultUnpacked) | ||
return nil | ||
} |
Oops, something went wrong.