mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-30 19:12:16 +00:00
# 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
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
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()
|
|
}
|