mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
831bb88ec4
* fix: correctly delete sessions created before 2.42 * fix test * fix linting * fixes requested from review
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package command
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
// resourceOwnerModel can be used to retrieve the resourceOwner of an aggregate
|
|
// by checking the first event it.
|
|
type resourceOwnerModel struct {
|
|
instanceID string
|
|
aggregateType eventstore.AggregateType
|
|
aggregateID string
|
|
|
|
resourceOwner string
|
|
}
|
|
|
|
func NewResourceOwnerModel(instanceID string, aggregateType eventstore.AggregateType, aggregateID string) *resourceOwnerModel {
|
|
return &resourceOwnerModel{
|
|
instanceID: instanceID,
|
|
aggregateType: aggregateType,
|
|
aggregateID: aggregateID,
|
|
}
|
|
}
|
|
|
|
func (r *resourceOwnerModel) Reduce() error {
|
|
return nil
|
|
}
|
|
func (r *resourceOwnerModel) AppendEvents(events ...eventstore.Event) {
|
|
if len(events) == 1 {
|
|
r.resourceOwner = events[0].Aggregate().ResourceOwner
|
|
}
|
|
}
|
|
func (r *resourceOwnerModel) Query() *eventstore.SearchQueryBuilder {
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
|
|
InstanceID(r.instanceID).
|
|
AddQuery().
|
|
AggregateTypes(r.aggregateType).
|
|
AggregateIDs(r.aggregateID).
|
|
Builder().
|
|
Limit(1)
|
|
}
|