mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-21 20:38:47 +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:
@@ -0,0 +1,45 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
"github.com/zitadel/zitadel/internal/repository/org"
|
||||
)
|
||||
|
||||
type HostedLoginTranslationWriteModel struct {
|
||||
eventstore.WriteModel
|
||||
Language language.Tag
|
||||
Translation map[string]any
|
||||
Level string
|
||||
LevelID string
|
||||
}
|
||||
|
||||
func NewHostedLoginTranslationWriteModel(resourceID string) *HostedLoginTranslationWriteModel {
|
||||
return &HostedLoginTranslationWriteModel{
|
||||
WriteModel: eventstore.WriteModel{
|
||||
AggregateID: resourceID,
|
||||
ResourceOwner: resourceID,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (wm *HostedLoginTranslationWriteModel) Reduce() error {
|
||||
for _, event := range wm.Events {
|
||||
switch e := event.(type) {
|
||||
case *org.HostedLoginTranslationSetEvent:
|
||||
wm.Language = e.Language
|
||||
wm.Translation = e.Translation
|
||||
wm.Level = e.Level
|
||||
wm.LevelID = e.Aggregate().ID
|
||||
case *instance.HostedLoginTranslationSetEvent:
|
||||
wm.Language = e.Language
|
||||
wm.Translation = e.Translation
|
||||
wm.Level = e.Level
|
||||
wm.LevelID = e.Aggregate().ID
|
||||
}
|
||||
}
|
||||
|
||||
return wm.WriteModel.Reduce()
|
||||
}
|
||||
Reference in New Issue
Block a user