Link detected cookies to existing patterns on conflict
When a cookie pattern already exists for a banner, the insert conflict caused a continue that silently dropped the detected cookie instead of linking it to the existing pattern. Load the existing pattern to obtain its ID and proceed with cookie insertion. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -2286,11 +2286,16 @@ func (s *Service) ReportDetectedCookies(
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert cookie pattern: %w", err)
|
||||
}
|
||||
if !wasInserted {
|
||||
continue
|
||||
if wasInserted {
|
||||
patternID = newPattern.ID
|
||||
inserted++
|
||||
} else {
|
||||
var existingPattern coredata.CookiePattern
|
||||
if err := existingPattern.LoadByBannerIDAndPattern(ctx, tx, scope, banner.ID, dc.Name); err != nil {
|
||||
return fmt.Errorf("cannot load existing cookie pattern: %w", err)
|
||||
}
|
||||
patternID = existingPattern.ID
|
||||
}
|
||||
patternID = newPattern.ID
|
||||
inserted++
|
||||
}
|
||||
|
||||
cookie := &coredata.Cookie{
|
||||
|
||||
Reference in New Issue
Block a user