mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
bdf3887f9e
* feat: default custom message text * feat: org custom message text * feat: org custom message text * feat: custom messages query side * feat: default messages * feat: message text user fields * feat: check for inactive user * feat: fix send password reset * feat: fix custom org text * feat: add variables to docs * feat: custom text tests * feat: fix notifications * feat: add custom text feature * feat: add custom text feature * feat: feature in custom message texts * feat: add custom text feature in frontend * feat: merge main * feat: feature tests * feat: change phone message in setup * fix: remove unused code, add event translation * fix: merge main and fix problems * fix: english translation file * fix: migration versions * fix: setup * feat: fix pr requests * feat: fix phone code message * feat: migration * feat: setup * fix: remove unused tests Co-authored-by: Livio Amstutz <livio.a@gmail.com>
35 lines
761 B
Go
35 lines
761 B
Go
package command
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/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()
|
|
}
|