diff --git a/app/api/controller/gitspace/list_all.go b/app/api/controller/gitspace/list_all.go index 7f5da8e2e..9038d60e2 100644 --- a/app/api/controller/gitspace/list_all.go +++ b/app/api/controller/gitspace/list_all.go @@ -31,15 +31,8 @@ const spaceIsDeleted = "Failed to find space: resource not found" func (c *Controller) ListAllGitspaces( // nolint:gocognit ctx context.Context, session *auth.Session, + filter *types.GitspaceFilter, ) ([]*types.GitspaceConfig, error) { - deleted := false - markedForDeletion := false - filter := &types.GitspaceFilter{ - GitspaceInstanceFilter: types.GitspaceInstanceFilter{UserIdentifier: session.Principal.UID}, - Deleted: &deleted, - MarkedForDeletion: &markedForDeletion, - } - var result []*types.GitspaceConfig err := c.tx.WithTx(ctx, func(ctx context.Context) (err error) { allGitspaceConfigs, err := c.gitspaceConfigStore.ListWithLatestInstance(ctx, filter) diff --git a/app/api/handler/gitspace/list_all_gitspaces.go b/app/api/handler/gitspace/list_all_gitspaces.go index 5247fbee3..5d842a328 100644 --- a/app/api/handler/gitspace/list_all_gitspaces.go +++ b/app/api/handler/gitspace/list_all_gitspaces.go @@ -20,13 +20,23 @@ import ( "github.com/harness/gitness/app/api/controller/gitspace" "github.com/harness/gitness/app/api/render" "github.com/harness/gitness/app/api/request" + "github.com/harness/gitness/types" + "github.com/harness/gitness/types/enum" ) func HandleListAllGitspaces(gitspaceCtrl *gitspace.Controller) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() session, _ := request.AuthSessionFrom(ctx) - gitspaces, err := gitspaceCtrl.ListAllGitspaces(ctx, session) + deleted := false + markedForDeletion := false + filter := &types.GitspaceFilter{ + GitspaceInstanceFilter: types.GitspaceInstanceFilter{UserIdentifier: session.Principal.UID}, + Deleted: &deleted, + MarkedForDeletion: &markedForDeletion, + } + filter.Owner = enum.GitspaceOwnerSelf + gitspaces, err := gitspaceCtrl.ListAllGitspaces(ctx, session, filter) if err != nil { render.TranslatedUserError(ctx, w, err) return