mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-26 14:28:46 +00:00
fix: push events (#1262)
* 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 <[email protected]>
This commit is contained in:
@@ -49,10 +49,17 @@ func (e *ApplicationAddedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
return []*eventstore.EventUniqueConstraint{NewAddApplicationUniqueConstraint(e.Name, e.projectID)}
|
||||
}
|
||||
|
||||
func NewApplicationAddedEvent(ctx context.Context, appID, name, projectID string) *ApplicationAddedEvent {
|
||||
func NewApplicationAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID,
|
||||
name,
|
||||
projectID string,
|
||||
) *ApplicationAddedEvent {
|
||||
return &ApplicationAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationAddedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -94,10 +101,18 @@ func (e *ApplicationChangedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
}
|
||||
}
|
||||
|
||||
func NewApplicationChangedEvent(ctx context.Context, appID, oldName, newName, projectID string) *ApplicationChangedEvent {
|
||||
func NewApplicationChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID,
|
||||
oldName,
|
||||
newName,
|
||||
projectID string,
|
||||
) *ApplicationChangedEvent {
|
||||
return &ApplicationChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationChangedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -134,10 +149,15 @@ func (e *ApplicationDeactivatedEvent) UniqueConstraints() []*eventstore.EventUni
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewApplicationDeactivatedEvent(ctx context.Context, appID string) *ApplicationDeactivatedEvent {
|
||||
func NewApplicationDeactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *ApplicationDeactivatedEvent {
|
||||
return &ApplicationDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationDeactivatedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -171,10 +191,15 @@ func (e *ApplicationReactivatedEvent) UniqueConstraints() []*eventstore.EventUni
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewApplicationReactivatedEvent(ctx context.Context, appID string) *ApplicationReactivatedEvent {
|
||||
func NewApplicationReactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *ApplicationReactivatedEvent {
|
||||
return &ApplicationReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationReactivatedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -210,10 +235,17 @@ func (e *ApplicationRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveApplicationUniqueConstraint(e.name, e.projectID)}
|
||||
}
|
||||
|
||||
func NewApplicationRemovedEvent(ctx context.Context, appID, name, projectID string) *ApplicationRemovedEvent {
|
||||
func NewApplicationRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID,
|
||||
name,
|
||||
projectID string,
|
||||
) *ApplicationRemovedEvent {
|
||||
return &ApplicationRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationRemovedType,
|
||||
),
|
||||
AppID: appID,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -50,10 +51,18 @@ func (e *GrantAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrain
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectGrantUniqueConstraint(e.GrantedOrgID, e.projectID)}
|
||||
}
|
||||
|
||||
func NewGrantAddedEvent(ctx context.Context, grantID, grantedOrgID, projectID string, roleKeys []string) *GrantAddedEvent {
|
||||
func NewGrantAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID,
|
||||
grantedOrgID,
|
||||
projectID string,
|
||||
roleKeys []string,
|
||||
) *GrantAddedEvent {
|
||||
return &GrantAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantAddedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -91,10 +100,16 @@ func (e *GrantChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstra
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantChangedEvent(ctx context.Context, grantID string, roleKeys []string) *GrantChangedEvent {
|
||||
func NewGrantChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
roleKeys []string,
|
||||
) *GrantChangedEvent {
|
||||
return &GrantChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantChangedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -130,10 +145,16 @@ func (e *GrantCascadeChangedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantCascadeChangedEvent(ctx context.Context, grantID string, roleKeys []string) *GrantCascadeChangedEvent {
|
||||
func NewGrantCascadeChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
roleKeys []string,
|
||||
) *GrantCascadeChangedEvent {
|
||||
return &GrantCascadeChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantCascadeChangedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -168,10 +189,15 @@ func (e *GrantDeactivateEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantDeactivateEvent(ctx context.Context, grantID string) *GrantDeactivateEvent {
|
||||
func NewGrantDeactivateEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
) *GrantDeactivateEvent {
|
||||
return &GrantDeactivateEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantDeactivatedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -205,10 +231,15 @@ func (e *GrantReactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantReactivatedEvent(ctx context.Context, grantID string) *GrantReactivatedEvent {
|
||||
func NewGrantReactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
) *GrantReactivatedEvent {
|
||||
return &GrantReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantReactivatedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -244,10 +275,17 @@ func (e *GrantRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstra
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectGrantUniqueConstraint(e.grantedOrgID, e.projectID)}
|
||||
}
|
||||
|
||||
func NewGrantRemovedEvent(ctx context.Context, grantID, grantedOrgID, projectID string) *GrantRemovedEvent {
|
||||
func NewGrantRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID,
|
||||
grantedOrgID,
|
||||
projectID string,
|
||||
) *GrantRemovedEvent {
|
||||
return &GrantRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantRemovedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -50,6 +51,7 @@ func (e *GrantMemberAddedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
|
||||
func NewProjectGrantMemberAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
projectID,
|
||||
userID,
|
||||
grantID string,
|
||||
@@ -58,6 +60,7 @@ func NewProjectGrantMemberAddedEvent(
|
||||
return &GrantMemberAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantMemberAddedType,
|
||||
),
|
||||
projectID: projectID,
|
||||
@@ -98,6 +101,7 @@ func (e *GrantMemberChangedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
|
||||
func NewProjectGrantMemberChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID,
|
||||
grantID string,
|
||||
roles ...string,
|
||||
@@ -105,6 +109,7 @@ func NewProjectGrantMemberChangedEvent(
|
||||
return &GrantMemberChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantMemberAddedType,
|
||||
),
|
||||
UserID: userID,
|
||||
@@ -144,6 +149,7 @@ func (e *GrantMemberRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
|
||||
func NewProjectGrantMemberRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
projectID,
|
||||
userID,
|
||||
grantID string,
|
||||
@@ -151,6 +157,7 @@ func NewProjectGrantMemberRemovedEvent(
|
||||
return &GrantMemberRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantMemberRemovedType,
|
||||
),
|
||||
UserID: userID,
|
||||
|
||||
@@ -2,6 +2,7 @@ package project
|
||||
|
||||
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"
|
||||
@@ -19,7 +20,7 @@ type MemberAddedEvent struct {
|
||||
|
||||
func NewProjectMemberAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberAddedEvent {
|
||||
@@ -27,9 +28,9 @@ func NewProjectMemberAddedEvent(
|
||||
MemberAddedEvent: *member.NewMemberAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberAddedType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
roles...,
|
||||
),
|
||||
@@ -51,6 +52,7 @@ type MemberChangedEvent struct {
|
||||
|
||||
func NewProjectMemberChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberChangedEvent {
|
||||
@@ -59,6 +61,7 @@ func NewProjectMemberChangedEvent(
|
||||
MemberChangedEvent: *member.NewMemberChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberChangedType,
|
||||
),
|
||||
userID,
|
||||
@@ -82,7 +85,7 @@ type MemberRemovedEvent struct {
|
||||
|
||||
func NewProjectMemberRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
) *MemberRemovedEvent {
|
||||
|
||||
@@ -90,9 +93,9 @@ func NewProjectMemberRemovedEvent(
|
||||
MemberRemovedEvent: *member.NewRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberRemovedType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ func (e *OIDCConfigAddedEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
|
||||
func NewOIDCConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
version domain.OIDCVersion,
|
||||
appID string,
|
||||
clientID string,
|
||||
@@ -71,6 +72,7 @@ func NewOIDCConfigAddedEvent(
|
||||
return &OIDCConfigAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCConfigAddedType,
|
||||
),
|
||||
Version: version,
|
||||
@@ -136,6 +138,7 @@ func (e *OIDCConfigChangedEvent) UniqueConstraints() []*eventstore.EventUniqueCo
|
||||
|
||||
func NewOIDCConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
changes []OIDCConfigChanges,
|
||||
) (*OIDCConfigChangedEvent, error) {
|
||||
@@ -146,6 +149,7 @@ func NewOIDCConfigChangedEvent(
|
||||
changeEvent := &OIDCConfigChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCConfigChangedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -272,12 +276,14 @@ func (e *OIDCConfigSecretChangedEvent) UniqueConstraints() []*eventstore.EventUn
|
||||
|
||||
func NewOIDCConfigSecretChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
clientSecret *crypto.CryptoValue,
|
||||
) *OIDCConfigSecretChangedEvent {
|
||||
return &OIDCConfigSecretChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCConfigSecretChangedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -314,11 +320,13 @@ func (e *OIDCConfigSecretCheckSucceededEvent) UniqueConstraints() []*eventstore.
|
||||
|
||||
func NewOIDCConfigSecretCheckSucceededEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *OIDCConfigSecretCheckSucceededEvent {
|
||||
return &OIDCConfigSecretCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCClientSecretCheckSucceededType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -354,11 +362,13 @@ func (e *OIDCConfigSecretCheckFailedEvent) UniqueConstraints() []*eventstore.Eve
|
||||
|
||||
func NewOIDCConfigSecretCheckFailedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *OIDCConfigSecretCheckFailedEvent {
|
||||
return &OIDCConfigSecretCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCClientSecretCheckFailedType,
|
||||
),
|
||||
AppID: appID,
|
||||
|
||||
@@ -45,15 +45,19 @@ func (e *ProjectAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *ProjectAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectNameUniqueConstraint(e.Name, e.ResourceOwner())}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectNameUniqueConstraint(e.Name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func NewProjectAddedEvent(ctx context.Context, name, resourceOwner string) *ProjectAddedEvent {
|
||||
func NewProjectAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
name string,
|
||||
) *ProjectAddedEvent {
|
||||
return &ProjectAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectAddedType,
|
||||
resourceOwner,
|
||||
),
|
||||
Name: name,
|
||||
}
|
||||
@@ -88,8 +92,8 @@ func (e *ProjectChangeEvent) Data() interface{} {
|
||||
func (e *ProjectChangeEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
if e.oldName != "" {
|
||||
return []*eventstore.EventUniqueConstraint{
|
||||
NewRemoveProjectNameUniqueConstraint(e.oldName, e.ResourceOwner()),
|
||||
NewAddProjectNameUniqueConstraint(*e.Name, e.ResourceOwner()),
|
||||
NewRemoveProjectNameUniqueConstraint(e.oldName, e.Aggregate().ResourceOwner),
|
||||
NewAddProjectNameUniqueConstraint(*e.Name, e.Aggregate().ResourceOwner),
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -97,17 +101,20 @@ func (e *ProjectChangeEvent) UniqueConstraints() []*eventstore.EventUniqueConstr
|
||||
|
||||
func NewProjectChangeEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner, oldName string,
|
||||
changes []ProjectChanges) (*ProjectChangeEvent, error) {
|
||||
aggregate *eventstore.Aggregate,
|
||||
oldName string,
|
||||
changes []ProjectChanges,
|
||||
) (*ProjectChangeEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "PROJECT-mV9xc", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &ProjectChangeEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectChangedType,
|
||||
resourceOwner,
|
||||
),
|
||||
oldName: oldName,
|
||||
}
|
||||
for _, change := range changes {
|
||||
change(changeEvent)
|
||||
@@ -160,10 +167,11 @@ func (e *ProjectDeactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewProjectDeactivatedEvent(ctx context.Context) *ProjectDeactivatedEvent {
|
||||
func NewProjectDeactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *ProjectDeactivatedEvent {
|
||||
return &ProjectDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectDeactivatedType,
|
||||
),
|
||||
}
|
||||
@@ -187,10 +195,11 @@ func (e *ProjectReactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewProjectReactivatedEvent(ctx context.Context) *ProjectReactivatedEvent {
|
||||
func NewProjectReactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *ProjectReactivatedEvent {
|
||||
return &ProjectReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectReactivatedType,
|
||||
),
|
||||
}
|
||||
@@ -213,15 +222,19 @@ func (e *ProjectRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *ProjectRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectNameUniqueConstraint(e.Name, e.ResourceOwner())}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectNameUniqueConstraint(e.Name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func NewProjectRemovedEvent(ctx context.Context, name, resourceOwner string) *ProjectRemovedEvent {
|
||||
func NewProjectRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
name string,
|
||||
) *ProjectRemovedEvent {
|
||||
return &ProjectRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectRemovedType,
|
||||
resourceOwner,
|
||||
),
|
||||
Name: name,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -47,10 +48,18 @@ func (e *RoleAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectRoleUniqueConstraint(e.Key, e.projectID)}
|
||||
}
|
||||
|
||||
func NewRoleAddedEvent(ctx context.Context, key, displayName, group, projectID string) *RoleAddedEvent {
|
||||
func NewRoleAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
key,
|
||||
displayName,
|
||||
group,
|
||||
projectID string,
|
||||
) *RoleAddedEvent {
|
||||
return &RoleAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
RoleAddedType,
|
||||
),
|
||||
Key: key,
|
||||
@@ -91,13 +100,16 @@ func (e *RoleChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrai
|
||||
|
||||
func NewRoleChangedEvent(
|
||||
ctx context.Context,
|
||||
changes []RoleChanges) (*RoleChangedEvent, error) {
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []RoleChanges,
|
||||
) (*RoleChangedEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "PROJECT-eR9vx", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &RoleChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
RoleChangedType,
|
||||
),
|
||||
}
|
||||
@@ -154,10 +166,15 @@ func (e *RoleRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrai
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectRoleUniqueConstraint(e.Key, e.projectID)}
|
||||
}
|
||||
|
||||
func NewRoleRemovedEvent(ctx context.Context, key, projectID string) *RoleRemovedEvent {
|
||||
func NewRoleRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
key,
|
||||
projectID string) *RoleRemovedEvent {
|
||||
return &RoleRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
RoleRemovedType,
|
||||
),
|
||||
Key: key,
|
||||
|
||||
Reference in New Issue
Block a user