mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
55
internal/repository/org/hosted_login_translation.go
Normal file
55
internal/repository/org/hosted_login_translation.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user