From 351cd4916283530d93a1dd40ed47cc7a6ff42e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 24 Apr 2026 18:44:17 +0400 Subject: [PATCH] Add probo_consent cookie to necessary category on banner creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The consent cookie is automatically created as a database record in the necessary category when a new cookie banner is set up, so it appears alongside other necessary cookies in the banner UI. Signed-off-by: Émile Ré --- pkg/cookiebanner/service.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/cookiebanner/service.go b/pkg/cookiebanner/service.go index 6641852c5..634862778 100644 --- a/pkg/cookiebanner/service.go +++ b/pkg/cookiebanner/service.go @@ -591,6 +591,23 @@ func (s *Service) CreateCookieBanner( } slugToGID[dc.Slug] = category.ID + + if dc.Kind == coredata.CookieCategoryKindNecessary { + consentCookie := &coredata.Cookie{ + ID: gid.New(scope.GetTenantID(), coredata.CookieEntityType), + OrganizationID: banner.OrganizationID, + CookieBannerID: banner.ID, + CookieCategoryID: category.ID, + Name: "probo_consent", + Duration: fmt.Sprintf("%d days", req.ConsentExpiryDays), + Description: "Stores your cookie consent preferences for this website.", + CreatedAt: now, + UpdatedAt: now, + } + if err := consentCookie.Insert(ctx, tx, scope); err != nil { + return fmt.Errorf("cannot insert probo_consent cookie: %w", err) + } + } } for lang, uiStrings := range defaultUIStringsByLanguage {