mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
00fec8830a
* fix: push events instead of aggregates * fix: tests * try without aggregate methods and with aggregate methods * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: client secret * fix: query eventtypes * fix: query eventtypes * fix: eventstore index * fix: index * fix: merge new eventstore * fix: remove unnecessary todos * fix: remove unnecessary todos Co-authored-by: Fabiennne <fabienne.gerschwiler@gmail.com>
112 lines
2.3 KiB
Go
112 lines
2.3 KiB
Go
package org
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
"github.com/caos/zitadel/internal/v2/repository/member"
|
|
)
|
|
|
|
var (
|
|
MemberAddedEventType = orgEventTypePrefix + member.AddedEventType
|
|
MemberChangedEventType = orgEventTypePrefix + member.ChangedEventType
|
|
MemberRemovedEventType = orgEventTypePrefix + member.RemovedEventType
|
|
)
|
|
|
|
type MemberAddedEvent struct {
|
|
member.MemberAddedEvent
|
|
}
|
|
|
|
func NewMemberAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
userID string,
|
|
roles ...string,
|
|
) *MemberAddedEvent {
|
|
return &MemberAddedEvent{
|
|
MemberAddedEvent: *member.NewMemberAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
MemberAddedEventType,
|
|
),
|
|
userID,
|
|
roles...,
|
|
),
|
|
}
|
|
}
|
|
|
|
func MemberAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := member.MemberAddedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MemberAddedEvent{MemberAddedEvent: *e.(*member.MemberAddedEvent)}, nil
|
|
}
|
|
|
|
type MemberChangedEvent struct {
|
|
member.MemberChangedEvent
|
|
}
|
|
|
|
func NewMemberChangedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
userID string,
|
|
roles ...string,
|
|
) *MemberChangedEvent {
|
|
|
|
return &MemberChangedEvent{
|
|
MemberChangedEvent: *member.NewMemberChangedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
MemberChangedEventType,
|
|
),
|
|
userID,
|
|
roles...,
|
|
),
|
|
}
|
|
}
|
|
|
|
func MemberChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := member.ChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MemberChangedEvent{MemberChangedEvent: *e.(*member.MemberChangedEvent)}, nil
|
|
}
|
|
|
|
type MemberRemovedEvent struct {
|
|
member.MemberRemovedEvent
|
|
}
|
|
|
|
func NewMemberRemovedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
userID string,
|
|
) *MemberRemovedEvent {
|
|
|
|
return &MemberRemovedEvent{
|
|
MemberRemovedEvent: *member.NewRemovedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
MemberRemovedEventType,
|
|
),
|
|
userID,
|
|
),
|
|
}
|
|
}
|
|
|
|
func MemberRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := member.RemovedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MemberRemovedEvent{MemberRemovedEvent: *e.(*member.MemberRemovedEvent)}, nil
|
|
}
|