fix: query organization directly from event store (#10463)

Querying an organization by id allowed to trigger the org projection.
This could lead to performance impacts if the projection gets triggered
too often.

Instead of executing the trigger the organization by id query is now
always executed on the eventstore and reduces all event types required
of the organization requested.

---------

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Silvan
2025-08-12 11:37:08 +02:00
committed by adlerhurst
parent 2f79a01e86
commit 6602a9e6c3
16 changed files with 39 additions and 77 deletions

View File

@@ -114,7 +114,7 @@ type userCommandProvider interface {
}
type orgViewProvider interface {
OrgByID(context.Context, bool, string) (*query.Org, error)
OrgByID(context.Context, string) (*query.Org, error)
OrgByPrimaryDomain(context.Context, string) (*query.Org, error)
}
@@ -1548,7 +1548,7 @@ func (repo *AuthRequestRepo) getDomainPolicy(ctx context.Context, orgID string)
func setOrgID(ctx context.Context, orgViewProvider orgViewProvider, request *domain.AuthRequest) error {
orgID := request.GetScopeOrgID()
if orgID != "" {
org, err := orgViewProvider.OrgByID(ctx, false, orgID)
org, err := orgViewProvider.OrgByID(ctx, orgID)
if err != nil {
return err
}
@@ -1721,7 +1721,7 @@ func activeUserByID(ctx context.Context, userViewProvider userViewProvider, user
if !(user.State == user_model.UserStateActive || user.State == user_model.UserStateInitial) {
return nil, zerrors.ThrowPreconditionFailed(nil, "EVENT-FJ262", "Errors.User.NotActive")
}
org, err := queries.OrgByID(ctx, false, user.ResourceOwner)
org, err := queries.OrgByID(ctx, user.ResourceOwner)
if err != nil {
return nil, err
}

View File

@@ -237,7 +237,7 @@ type mockViewOrg struct {
State domain.OrgState
}
func (m *mockViewOrg) OrgByID(context.Context, bool, string) (*query.Org, error) {
func (m *mockViewOrg) OrgByID(context.Context, string) (*query.Org, error) {
return &query.Org{
State: m.State,
}, nil
@@ -251,7 +251,7 @@ func (m *mockViewOrg) OrgByPrimaryDomain(context.Context, string) (*query.Org, e
type mockViewErrOrg struct{}
func (m *mockViewErrOrg) OrgByID(context.Context, bool, string) (*query.Org, error) {
func (m *mockViewErrOrg) OrgByID(context.Context, string) (*query.Org, error) {
return nil, zerrors.ThrowInternal(nil, "id", "internal error")
}