diff --git a/pkg/cookiebanner/errors.go b/pkg/cookiebanner/errors.go index f820f1732..d260c51cc 100644 --- a/pkg/cookiebanner/errors.go +++ b/pkg/cookiebanner/errors.go @@ -33,6 +33,4 @@ var ( ErrCookieNameAlreadyExists = errors.New("a cookie with this name already exists in this banner") ErrCategoriesBannerMismatch = errors.New("source and target categories belong to different banners") ErrSameCategoryMove = errors.New("source and target cookie categories must be different") - ErrTranslationNotFound = errors.New("cookie banner translation not found") - ErrTranslationAlreadyExists = errors.New("translation for this language already exists") ) diff --git a/pkg/cookiebanner/service.go b/pkg/cookiebanner/service.go index c345dc889..6e17e6900 100644 --- a/pkg/cookiebanner/service.go +++ b/pkg/cookiebanner/service.go @@ -146,11 +146,6 @@ type ( Translations json.RawMessage } - DeleteCookieBannerTranslationRequest struct { - CookieBannerID gid.GID - Language string - } - VisitorConsent struct { VisitorID string `json:"visitor_id"` Version int `json:"version"` @@ -311,15 +306,6 @@ func (r *UpsertCookieBannerTranslationRequest) Validate() error { return v.Error() } -func (r *DeleteCookieBannerTranslationRequest) Validate() error { - v := validator.New() - - v.Check(r.CookieBannerID, "cookie_banner_id", validator.Required(), validator.GID(coredata.CookieBannerEntityType)) - v.Check(r.Language, "language", validator.Required(), validator.SafeTextNoNewLine(10)) - - return v.Error() -} - func CanonicalizeOrigin(raw string) string { u, err := url.Parse(raw) if err != nil { @@ -1906,40 +1892,6 @@ func (s *Service) UpsertCookieBannerTranslation( return result, nil } -func (s *Service) DeleteCookieBannerTranslation( - ctx context.Context, - scope coredata.Scoper, - req DeleteCookieBannerTranslationRequest, -) error { - if err := req.Validate(); err != nil { - return fmt.Errorf("invalid request: %w", err) - } - - return s.pg.WithTx( - ctx, - func(ctx context.Context, tx pg.Tx) error { - var translation coredata.CookieBannerTranslation - err := translation.LoadByCookieBannerIDAndLanguage(ctx, tx, scope, req.CookieBannerID, req.Language) - if err != nil { - if errors.Is(err, coredata.ErrResourceNotFound) { - return ErrTranslationNotFound - } - return fmt.Errorf("cannot load cookie banner translation: %w", err) - } - - if err := translation.Delete(ctx, tx, scope); err != nil { - return fmt.Errorf("cannot delete cookie banner translation: %w", err) - } - - if _, err := s.ensureDraftVersionForBanner(ctx, tx, scope, req.CookieBannerID); err != nil { - return fmt.Errorf("cannot ensure draft version: %w", err) - } - - return nil - }, - ) -} - func (s *Service) ListCookieBannerTranslations( ctx context.Context, scope coredata.Scoper, diff --git a/pkg/server/api/console/v1/cookie_banner_resolvers.go b/pkg/server/api/console/v1/cookie_banner_resolvers.go index 574da6bdb..0ce6b025d 100644 --- a/pkg/server/api/console/v1/cookie_banner_resolvers.go +++ b/pkg/server/api/console/v1/cookie_banner_resolvers.go @@ -785,45 +785,6 @@ func (r *mutationResolver) UpsertCookieBannerTranslation(ctx context.Context, in }, nil } -// DeleteCookieBannerTranslation is the resolver for the deleteCookieBannerTranslation field. -func (r *mutationResolver) DeleteCookieBannerTranslation(ctx context.Context, input types.DeleteCookieBannerTranslationInput) (*types.DeleteCookieBannerTranslationPayload, error) { - if err := r.authorize(ctx, input.CookieBannerID, probo.ActionCookieBannerUpdate); err != nil { - return nil, err - } - - scope := coredata.NewScopeFromObjectID(input.CookieBannerID) - - err := r.cookieBanner.DeleteCookieBannerTranslation( - ctx, - scope, - cookiebanner.DeleteCookieBannerTranslationRequest{ - CookieBannerID: input.CookieBannerID, - Language: input.Language, - }, - ) - if err != nil { - if errors.Is(err, cookiebanner.ErrTranslationNotFound) { - return nil, gqlutils.NotFound(ctx, err) - } - if errors.Is(err, cookiebanner.ErrBannerNotFound) { - return nil, gqlutils.NotFound(ctx, err) - } - r.logger.ErrorCtx(ctx, "cannot delete cookie banner translation", log.Error(err)) - return nil, gqlutils.Internal(ctx) - } - - banner, err := r.cookieBanner.GetCookieBanner(ctx, scope, input.CookieBannerID) - if err != nil { - r.logger.ErrorCtx(ctx, "cannot load cookie banner", log.Error(err)) - return nil, gqlutils.Internal(ctx) - } - - return &types.DeleteCookieBannerTranslationPayload{ - DeletedLanguage: input.Language, - CookieBanner: types.NewCookieBanner(banner), - }, nil -} - // Cookie returns schema.CookieResolver implementation. func (r *Resolver) Cookie() schema.CookieResolver { return &cookieResolver{r} } diff --git a/pkg/server/api/console/v1/graphql/cookie_banner.graphql b/pkg/server/api/console/v1/graphql/cookie_banner.graphql index 69dba8a9a..3ec70f246 100644 --- a/pkg/server/api/console/v1/graphql/cookie_banner.graphql +++ b/pkg/server/api/console/v1/graphql/cookie_banner.graphql @@ -258,9 +258,6 @@ extend type Mutation { upsertCookieBannerTranslation( input: UpsertCookieBannerTranslationInput! ): UpsertCookieBannerTranslationPayload! - deleteCookieBannerTranslation( - input: DeleteCookieBannerTranslationInput! - ): DeleteCookieBannerTranslationPayload! } input CreateCookieBannerInput { @@ -415,17 +412,7 @@ input UpsertCookieBannerTranslationInput { translations: String! } -input DeleteCookieBannerTranslationInput { - cookieBannerId: ID! - language: String! -} - type UpsertCookieBannerTranslationPayload { cookieBannerTranslation: CookieBannerTranslation! cookieBanner: CookieBanner! } - -type DeleteCookieBannerTranslationPayload { - deletedLanguage: String! - cookieBanner: CookieBanner! -}