mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 07:54:26 +00:00
## Which problems are solved
The execution of statements of projections did not have the context
present.
## How the problems were solved
Pass the context to the execute function
## Additional info
This change is required to use the repositories of the relational tables
in projections.
(cherry picked from commit 20e7807ee5)
29 lines
1.0 KiB
Go
29 lines
1.0 KiB
Go
package handlers
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
const NotifyUserID = "NOTIFICATION" //TODO: system?
|
|
|
|
func HandlerContext(parent context.Context, event *eventstore.Aggregate) context.Context {
|
|
ctx := authz.WithInstanceID(parent, event.InstanceID)
|
|
return authz.SetCtxData(ctx, authz.CtxData{UserID: NotifyUserID, OrgID: event.ResourceOwner})
|
|
}
|
|
|
|
func ContextWithNotifier(ctx context.Context, aggregate *eventstore.Aggregate) context.Context {
|
|
return authz.WithInstanceID(authz.SetCtxData(ctx, authz.CtxData{UserID: NotifyUserID, OrgID: aggregate.ResourceOwner}), aggregate.InstanceID)
|
|
}
|
|
|
|
func (n *NotificationQueries) HandlerContext(parent context.Context, event *eventstore.Aggregate) (context.Context, error) {
|
|
instance, err := n.InstanceByID(parent, event.InstanceID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ctx := authz.WithInstance(parent, instance)
|
|
return authz.SetCtxData(ctx, authz.CtxData{UserID: NotifyUserID, OrgID: event.ResourceOwner}), nil
|
|
}
|