mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +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>
96 lines
3.0 KiB
Go
96 lines
3.0 KiB
Go
package command
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/repository/org"
|
|
)
|
|
|
|
type OrgCustomMessageTextReadModel struct {
|
|
CustomMessageTextReadModel
|
|
}
|
|
|
|
func NewOrgCustomMessageTextWriteModel(orgID, messageTextType string, lang language.Tag) *OrgCustomMessageTextReadModel {
|
|
return &OrgCustomMessageTextReadModel{
|
|
CustomMessageTextReadModel{
|
|
WriteModel: eventstore.WriteModel{
|
|
AggregateID: orgID,
|
|
ResourceOwner: orgID,
|
|
},
|
|
MessageTextType: messageTextType,
|
|
Language: lang,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (wm *OrgCustomMessageTextReadModel) AppendEvents(events ...eventstore.EventReader) {
|
|
for _, event := range events {
|
|
switch e := event.(type) {
|
|
case *org.CustomTextSetEvent:
|
|
wm.CustomMessageTextReadModel.AppendEvents(&e.CustomTextSetEvent)
|
|
case *org.CustomTextRemovedEvent:
|
|
wm.CustomMessageTextReadModel.AppendEvents(&e.CustomTextRemovedEvent)
|
|
case *org.CustomTextTemplateRemovedEvent:
|
|
wm.CustomMessageTextReadModel.AppendEvents(&e.CustomTextTemplateRemovedEvent)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (wm *OrgCustomMessageTextReadModel) Reduce() error {
|
|
return wm.CustomMessageTextReadModel.Reduce()
|
|
}
|
|
|
|
func (wm *OrgCustomMessageTextReadModel) Query() *eventstore.SearchQueryBuilder {
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, org.AggregateType).
|
|
AggregateIDs(wm.CustomMessageTextReadModel.AggregateID).
|
|
ResourceOwner(wm.ResourceOwner).
|
|
EventTypes(
|
|
org.CustomTextSetEventType,
|
|
org.CustomTextRemovedEventType,
|
|
org.CustomTextTemplateRemovedEventType)
|
|
}
|
|
|
|
type OrgCustomMessageTemplatesReadModel struct {
|
|
CustomMessageTemplatesReadModel
|
|
}
|
|
|
|
func NewOrgCustomMessageTextsWriteModel(orgID string) *OrgCustomMessageTemplatesReadModel {
|
|
return &OrgCustomMessageTemplatesReadModel{
|
|
CustomMessageTemplatesReadModel{
|
|
WriteModel: eventstore.WriteModel{
|
|
AggregateID: orgID,
|
|
ResourceOwner: orgID,
|
|
},
|
|
CustomMessageTemplate: make(map[string]*CustomText),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (wm *OrgCustomMessageTemplatesReadModel) AppendEvents(events ...eventstore.EventReader) {
|
|
for _, event := range events {
|
|
switch e := event.(type) {
|
|
case *org.CustomTextSetEvent:
|
|
wm.CustomMessageTemplatesReadModel.AppendEvents(&e.CustomTextSetEvent)
|
|
case *org.CustomTextRemovedEvent:
|
|
wm.CustomMessageTemplatesReadModel.AppendEvents(&e.CustomTextRemovedEvent)
|
|
case *org.CustomTextTemplateRemovedEvent:
|
|
wm.CustomMessageTemplatesReadModel.AppendEvents(&e.CustomTextTemplateRemovedEvent)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (wm *OrgCustomMessageTemplatesReadModel) Reduce() error {
|
|
return wm.CustomMessageTemplatesReadModel.Reduce()
|
|
}
|
|
|
|
func (wm *OrgCustomMessageTemplatesReadModel) Query() *eventstore.SearchQueryBuilder {
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, org.AggregateType).
|
|
AggregateIDs(wm.CustomMessageTemplatesReadModel.AggregateID).
|
|
ResourceOwner(wm.ResourceOwner).
|
|
EventTypes(
|
|
org.CustomTextSetEventType,
|
|
org.CustomTextRemovedEventType,
|
|
org.CustomTextTemplateRemovedEventType)
|
|
}
|