mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
959530ddad
* fix: correct selectors for extended writemodel * fix: no previous checks in eventstore * start check previous * feat: auth user commands * feat: auth user commands * feat: auth user commands * feat: otp * feat: corrections from pr merge * feat: webauthn * feat: comment old webauthn * feat: refactor user, human, machine * feat: webauth command side * feat: command and query side in login * feat: fix user writemodel append events * fix: remove creation dates on command side * fix: remove previous sequence * previous sequence * fix: external idps * Update internal/api/grpc/management/user.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/v2/command/user_human_email.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: pr changes * fix: phone verification Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
87 lines
2.0 KiB
Go
87 lines
2.0 KiB
Go
package eventstore
|
|
|
|
type Aggregater interface {
|
|
//ID returns the aggreagte id
|
|
ID() string
|
|
//KeyType returns the aggregate type
|
|
Type() AggregateType
|
|
//Events returns the events which will be pushed
|
|
Events() []EventPusher
|
|
//ResourceOwner returns the organisation id which manages this aggregate
|
|
// resource owner is only on the inital push needed
|
|
// afterwards the resource owner of the previous event is taken
|
|
ResourceOwner() string
|
|
//Version represents the semantic version of the aggregate
|
|
Version() Version
|
|
}
|
|
|
|
func NewAggregate(
|
|
id string,
|
|
typ AggregateType,
|
|
resourceOwner string,
|
|
version Version,
|
|
) *Aggregate {
|
|
return &Aggregate{
|
|
id: id,
|
|
typ: typ,
|
|
resourceOwner: resourceOwner,
|
|
version: version,
|
|
events: []EventPusher{},
|
|
}
|
|
}
|
|
|
|
func AggregateFromWriteModel(
|
|
wm *WriteModel,
|
|
typ AggregateType,
|
|
version Version,
|
|
) *Aggregate {
|
|
return &Aggregate{
|
|
id: wm.AggregateID,
|
|
typ: typ,
|
|
resourceOwner: wm.ResourceOwner,
|
|
version: version,
|
|
events: []EventPusher{},
|
|
}
|
|
}
|
|
|
|
//Aggregate is the basic implementation of Aggregater
|
|
type Aggregate struct {
|
|
id string `json:"-"`
|
|
typ AggregateType `json:"-"`
|
|
events []EventPusher `json:"-"`
|
|
resourceOwner string `json:"-"`
|
|
version Version `json:"-"`
|
|
}
|
|
|
|
//PushEvents adds all the events to the aggregate.
|
|
// The added events will be pushed to eventstore
|
|
func (a *Aggregate) PushEvents(events ...EventPusher) *Aggregate {
|
|
a.events = append(a.events, events...)
|
|
return a
|
|
}
|
|
|
|
//ID implements Aggregater
|
|
func (a *Aggregate) ID() string {
|
|
return a.id
|
|
}
|
|
|
|
//KeyType implements Aggregater
|
|
func (a *Aggregate) Type() AggregateType {
|
|
return a.typ
|
|
}
|
|
|
|
//Events implements Aggregater
|
|
func (a *Aggregate) Events() []EventPusher {
|
|
return a.events
|
|
}
|
|
|
|
//ResourceOwner implements Aggregater
|
|
func (a *Aggregate) ResourceOwner() string {
|
|
return a.resourceOwner
|
|
}
|
|
|
|
//Version implements Aggregater
|
|
func (a *Aggregate) Version() Version {
|
|
return a.version
|
|
}
|