From 833f2aec006ac0f6643c41872e45dd79220b9174 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 23 Mar 2026 16:10:00 +0100 Subject: [PATCH] refactor: use accessibleProjectIDsSubquery in addBucketsToTasks --- pkg/models/tasks.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index e34079c42..01222ef39 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -562,18 +562,6 @@ func addBucketsToTasks(s *xorm.Session, a web.Auth, taskIDs []int64, taskMap map return err } - // We need to fetch all projects for that user to make sure they only - // get to see buckets that they have permission to see. - projectIDs := []int64{} - allProjects, _, _, err := getAllRawProjects(s, a, "", 0, -1, false) - if err != nil { - return err - } - - for _, project := range allProjects { - projectIDs = append(projectIDs, project.ID) - } - buckets := make(map[int64]*Bucket) err = s. Where(builder.In("id", builder.Select("bucket_id"). @@ -581,7 +569,7 @@ func addBucketsToTasks(s *xorm.Session, a web.Auth, taskIDs []int64, taskMap map Where(builder.In("task_id", taskIDs)))). And(builder.In("project_view_id", builder.Select("id"). From("project_views"). - Where(builder.In("project_id", projectIDs)))). + Where(accessibleProjectIDsSubquery(a, "project_views.project_id")))). Find(&buckets) if err != nil { return err