Skip to content

Commit

Permalink
fix(server): repo filter remains between different contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Nov 16, 2023
1 parent ef33daa commit 887dafa
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions server/internal/app/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ import (

func UsecaseMiddleware(r *repo.Container, g *gateway.Container, ar *accountrepo.Container, ag *accountgateway.Container, config interactor.ContainerConfig) echo.MiddlewareFunc {
return ContextMiddleware(func(ctx context.Context) context.Context {
repos := r

if op := adapter.Operator(ctx); op != nil {

ws := repo.WorkspaceFilterFromOperator(op)
sc := repo.SceneFilterFromOperator(op)

// apply filters to repos
r = r.Filtered(
repo.WorkspaceFilterFromOperator(op),
repo.SceneFilterFromOperator(op),
repos = repos.Filtered(
ws,
sc,
)
}

Expand All @@ -30,7 +36,7 @@ func UsecaseMiddleware(r *repo.Container, g *gateway.Container, ar *accountrepo.
ar2 = ar
}

uc := interactor.NewContainer(r, g, ar2, ag, config)
uc := interactor.NewContainer(repos, g, ar2, ag, config)
ctx = adapter.AttachUsecases(ctx, &uc)
return ctx
})
Expand Down

0 comments on commit 887dafa

Please sign in to comment.