Skip to content

Commit

Permalink
Added methods to v2 parsed consent (#14)
Browse files Browse the repository at this point in the history
I've added methods here that do some barebones checking of purposes +
consent within the TCF v2 parsed consent.

The business logic here may change quite a bit after discussions with our
privacy / data ethics folks, so use with caution. We will tag this as v0.3.1.

Reviewer: mdehdi
  • Loading branch information
Andy Day authored Jul 14, 2020
1 parent de5fda8 commit 42b016b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions v2_parsed_consent.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,29 @@ const (
// - Conduct any other data processing operation allowed under a different purpose under this purpose
TechnicallyDeliverAds
)

// EveryPurposeAllowed returns true iff every purpose number in ps exists in
// the V2ParsedConsent, otherwise false.
func (p *V2ParsedConsent) EveryPurposeAllowed(ps []int) bool {
for _, rp := range ps {
if !p.PurposesConsent[rp] {
return false
}
}
return true
}

// VendorAllowed returns true if the ParsedConsent contains affirmative consent
// for VendorID v.
func (p *V2ParsedConsent) VendorAllowed(v int) bool {
if p.IsConsentRangeEncoding {
for _, re := range p.ConsentedVendorsRange {
if re.StartVendorID <= v && v <= re.EndVendorID {
return true
}
}
return false
}

return p.ConsentedVendors[v]
}

0 comments on commit 42b016b

Please sign in to comment.