zitadel/internal/command/instance_custom_text_model.go
Fabi 9d4f296c62
fix: rename iam to instance (#3345)
* fix: rename iam command side to instance

* fix: rename iam command side to instance

* fix: rename iam command side to instance

* fix: rename iam command side to instance

* fix: rename orgiampolicy to domain policy

* fix: merge conflicts

* fix: protos

* fix: md files

* implement deprecated org iam policy again

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-03-24 16:21:34 +00:00

51 lines
1.3 KiB
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/instance"
)
type InstanceCustomTextWriteModel struct {
CustomTextWriteModel
}
func NewInstanceCustomTextWriteModel(key string, language language.Tag) *InstanceCustomTextWriteModel {
return &InstanceCustomTextWriteModel{
CustomTextWriteModel{
WriteModel: eventstore.WriteModel{
AggregateID: domain.IAMID,
ResourceOwner: domain.IAMID,
},
Key: key,
Language: language,
},
}
}
func (wm *InstanceCustomTextWriteModel) AppendEvents(events ...eventstore.Event) {
for _, event := range events {
switch e := event.(type) {
case *instance.CustomTextSetEvent:
wm.CustomTextWriteModel.AppendEvents(&e.CustomTextSetEvent)
}
}
}
func (wm *InstanceCustomTextWriteModel) Reduce() error {
return wm.CustomTextWriteModel.Reduce()
}
func (wm *InstanceCustomTextWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateIDs(wm.CustomTextWriteModel.AggregateID).
AggregateTypes(instance.AggregateType).
EventTypes(
instance.CustomTextSetEventType).
Builder()
}