feat: Hosted login translation API (#10011)

# Which Problems Are Solved

This PR implements https://github.com/zitadel/zitadel/issues/9850

# How the Problems Are Solved

  - New protobuf definition
  - Implementation of retrieval of system translations
- Implementation of retrieval and persistence of organization and
instance level translations

# Additional Context

- Closes #9850

# TODO

- [x] Integration tests for Get and Set hosted login translation
endpoints
- [x] DB migration test
- [x] Command function tests
- [x] Command util functions tests
- [x] Query function test
- [x] Query util functions tests
This commit is contained in:
Marco A.
2025-06-18 13:24:39 +02:00
committed by GitHub
parent cddbd3dd47
commit 28f7218ea1
23 changed files with 3613 additions and 527 deletions

View File

@@ -114,4 +114,5 @@ func init() {
eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyAddedEventType, NotificationPolicyAddedEventMapper)
eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyChangedEventType, NotificationPolicyChangedEventMapper)
eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyRemovedEventType, NotificationPolicyRemovedEventMapper)
eventstore.RegisterFilterEventMapper(AggregateType, HostedLoginTranslationSet, HostedLoginTranslationSetEventMapper)
}

View File

@@ -0,0 +1,55 @@
package org
import (
"context"
"golang.org/x/text/language"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/zerrors"
)
const (
HostedLoginTranslationSet = orgEventTypePrefix + "hosted_login_translation.set"
)
type HostedLoginTranslationSetEvent struct {
eventstore.BaseEvent `json:"-"`
Translation map[string]any `json:"translation,omitempty"`
Language language.Tag `json:"language,omitempty"`
Level string `json:"level,omitempty"`
}
func NewHostedLoginTranslationSetEvent(ctx context.Context, aggregate *eventstore.Aggregate, translation map[string]any, language language.Tag) *HostedLoginTranslationSetEvent {
return &HostedLoginTranslationSetEvent{
BaseEvent: *eventstore.NewBaseEventForPush(ctx, aggregate, HostedLoginTranslationSet),
Translation: translation,
Language: language,
Level: string(aggregate.Type),
}
}
func (e *HostedLoginTranslationSetEvent) Payload() any {
return e
}
func (e *HostedLoginTranslationSetEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
func (e *HostedLoginTranslationSetEvent) Fields() []*eventstore.FieldOperation {
return nil
}
func HostedLoginTranslationSetEventMapper(event eventstore.Event) (eventstore.Event, error) {
translationSet := &HostedLoginTranslationSetEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := event.Unmarshal(translationSet)
if err != nil {
return nil, zerrors.ThrowInternal(err, "ORG-BH82Eb", "unable to unmarshal hosted login translation set event")
}
return translationSet, nil
}