Remove unused deleteCookieBannerTranslation mutation
The mutation was wired up in the GraphQL schema and resolver but never called from the console frontend. This removes the service method, request type, resolver, schema entries, and two unused error sentinels (ErrTranslationNotFound, ErrTranslationAlreadyExists). Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -33,6 +33,4 @@ var (
|
|||||||
ErrCookieNameAlreadyExists = errors.New("a cookie with this name already exists in this banner")
|
ErrCookieNameAlreadyExists = errors.New("a cookie with this name already exists in this banner")
|
||||||
ErrCategoriesBannerMismatch = errors.New("source and target categories belong to different banners")
|
ErrCategoriesBannerMismatch = errors.New("source and target categories belong to different banners")
|
||||||
ErrSameCategoryMove = errors.New("source and target cookie categories must be different")
|
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")
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -146,11 +146,6 @@ type (
|
|||||||
Translations json.RawMessage
|
Translations json.RawMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteCookieBannerTranslationRequest struct {
|
|
||||||
CookieBannerID gid.GID
|
|
||||||
Language string
|
|
||||||
}
|
|
||||||
|
|
||||||
VisitorConsent struct {
|
VisitorConsent struct {
|
||||||
VisitorID string `json:"visitor_id"`
|
VisitorID string `json:"visitor_id"`
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
@@ -311,15 +306,6 @@ func (r *UpsertCookieBannerTranslationRequest) Validate() error {
|
|||||||
return v.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 {
|
func CanonicalizeOrigin(raw string) string {
|
||||||
u, err := url.Parse(raw)
|
u, err := url.Parse(raw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1906,40 +1892,6 @@ func (s *Service) UpsertCookieBannerTranslation(
|
|||||||
return result, nil
|
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(
|
func (s *Service) ListCookieBannerTranslations(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
scope coredata.Scoper,
|
scope coredata.Scoper,
|
||||||
|
|||||||
@@ -785,45 +785,6 @@ func (r *mutationResolver) UpsertCookieBannerTranslation(ctx context.Context, in
|
|||||||
}, nil
|
}, 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.
|
// Cookie returns schema.CookieResolver implementation.
|
||||||
func (r *Resolver) Cookie() schema.CookieResolver { return &cookieResolver{r} }
|
func (r *Resolver) Cookie() schema.CookieResolver { return &cookieResolver{r} }
|
||||||
|
|
||||||
|
|||||||
@@ -258,9 +258,6 @@ extend type Mutation {
|
|||||||
upsertCookieBannerTranslation(
|
upsertCookieBannerTranslation(
|
||||||
input: UpsertCookieBannerTranslationInput!
|
input: UpsertCookieBannerTranslationInput!
|
||||||
): UpsertCookieBannerTranslationPayload!
|
): UpsertCookieBannerTranslationPayload!
|
||||||
deleteCookieBannerTranslation(
|
|
||||||
input: DeleteCookieBannerTranslationInput!
|
|
||||||
): DeleteCookieBannerTranslationPayload!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input CreateCookieBannerInput {
|
input CreateCookieBannerInput {
|
||||||
@@ -415,17 +412,7 @@ input UpsertCookieBannerTranslationInput {
|
|||||||
translations: String!
|
translations: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
input DeleteCookieBannerTranslationInput {
|
|
||||||
cookieBannerId: ID!
|
|
||||||
language: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpsertCookieBannerTranslationPayload {
|
type UpsertCookieBannerTranslationPayload {
|
||||||
cookieBannerTranslation: CookieBannerTranslation!
|
cookieBannerTranslation: CookieBannerTranslation!
|
||||||
cookieBanner: CookieBanner!
|
cookieBanner: CookieBanner!
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteCookieBannerTranslationPayload {
|
|
||||||
deletedLanguage: String!
|
|
||||||
cookieBanner: CookieBanner!
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user