zitadel/internal/command/custom_text_model.go
Florian Forster fa9f581d56
chore(v2): move to new org (#3499)
* chore: move to new org

* logging

* fix: org rename caos -> zitadel

Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
2022-04-26 23:01:45 +00:00

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