mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
35 lines
770 B
Go
35 lines
770 B
Go
package command
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
type CustomTextWriteModel struct {
|
|
eventstore.WriteModel
|
|
|
|
Key string
|
|
Language language.Tag
|
|
Text string
|
|
State domain.CustomTextState
|
|
}
|
|
|
|
func (wm *CustomTextWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *policy.CustomTextSetEvent:
|
|
if wm.Key != e.Key || wm.Language != e.Language {
|
|
continue
|
|
}
|
|
wm.Text = e.Text
|
|
wm.State = domain.CustomTextStateActive
|
|
case *policy.CustomTextRemovedEvent:
|
|
wm.State = domain.CustomTextStateRemoved
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|