Files
zitadel/internal/command/hosted_login_translation_model.go
T
Marco A.andGitHub 28f7218ea1 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
2025-06-18 13:24:39 +02:00

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()
}