mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
ed80a8bb1e
* feat(actions): begin api * feat(actions): begin api * api and projections * fix: handle multiple statements for a single event in projections * export func type * fix test * update to new reduce interface * flows in login * feat: jwt idp * feat: command side * feat: add tests * actions and flows * fill idp views with jwt idps and return apis * add jwtEndpoint to jwt idp * begin jwt request handling * add feature * merge * merge * handle jwt idp * cleanup * bug fixes * autoregister * get token from specific header name * fix: proto * fixes * i18n * begin tests * fix and log http proxy * remove docker cache * fixes * usergrants in actions api * tests adn cleanup * cleanup * fix add user grant * set login context * i18n Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package command
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/repository/org"
|
|
)
|
|
|
|
type OrgFlowWriteModel struct {
|
|
FlowWriteModel
|
|
}
|
|
|
|
func NewOrgFlowWriteModel(flowType domain.FlowType, resourceOwner string) *OrgFlowWriteModel {
|
|
return &OrgFlowWriteModel{
|
|
FlowWriteModel: *NewFlowWriteModel(flowType, resourceOwner),
|
|
}
|
|
}
|
|
|
|
func (wm *OrgFlowWriteModel) AppendEvents(events ...eventstore.EventReader) {
|
|
for _, event := range events {
|
|
switch e := event.(type) {
|
|
case *org.TriggerActionsSetEvent:
|
|
if e.FlowType != wm.FlowType {
|
|
continue
|
|
}
|
|
wm.FlowWriteModel.AppendEvents(&e.TriggerActionsSetEvent)
|
|
case *org.TriggerActionsCascadeRemovedEvent:
|
|
if e.FlowType != wm.FlowType {
|
|
continue
|
|
}
|
|
wm.FlowWriteModel.AppendEvents(&e.TriggerActionsCascadeRemovedEvent)
|
|
case *org.FlowClearedEvent:
|
|
if e.FlowType != wm.FlowType {
|
|
continue
|
|
}
|
|
wm.FlowWriteModel.AppendEvents(&e.FlowClearedEvent)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (wm *OrgFlowWriteModel) Reduce() error {
|
|
return wm.FlowWriteModel.Reduce()
|
|
}
|
|
|
|
func (wm *OrgFlowWriteModel) Query() *eventstore.SearchQueryBuilder {
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
|
|
ResourceOwner(wm.ResourceOwner).
|
|
AddQuery().
|
|
AggregateTypes(org.AggregateType).
|
|
EventTypes(org.TriggerActionsSetEventType,
|
|
org.TriggerActionsCascadeRemovedEventType,
|
|
org.FlowClearedEventType).
|
|
Builder()
|
|
}
|