github.com/prebid/prebid-server/v2@v2.18.0/privacy/lmt/policy.go (about) 1 package lmt 2 3 import "github.com/prebid/openrtb/v20/openrtb2" 4 5 const ( 6 trackingUnrestricted = 0 7 trackingRestricted = 1 8 ) 9 10 // Policy represents the LMT (Limit Ad Tracking) policy for an OpenRTB bid request. 11 type Policy struct { 12 Signal int 13 SignalProvided bool 14 } 15 16 // ReadFromRequest extracts the LMT (Limit Ad Tracking) policy from an OpenRTB bid request. 17 func ReadFromRequest(req *openrtb2.BidRequest) (policy Policy) { 18 if req != nil && req.Device != nil && req.Device.Lmt != nil { 19 policy.Signal = int(*req.Device.Lmt) 20 policy.SignalProvided = true 21 } 22 return 23 } 24 25 // CanEnforce returns true the LMT (Limit Ad Tracking) signal is provided by the publisher. 26 func (p Policy) CanEnforce() bool { 27 return p.SignalProvided 28 } 29 30 // ShouldEnforce returns true when the LMT (Limit Ad Tracking) policy is in effect. 31 func (p Policy) ShouldEnforce(bidder string) bool { 32 return p.SignalProvided && p.Signal == trackingRestricted 33 }