- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6.2k
Fix invalid issues in project boards #22865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 74 commits
16836c2
              91cbfce
              3f76a8f
              192a6d4
              26564fb
              a266778
              99a3351
              810de4e
              39f8366
              33c57bc
              5242c79
              f92c5e0
              feb43e0
              3e6ae97
              49a9595
              a608963
              a3396b9
              005568f
              adb83e6
              6ebb80d
              87d98fc
              ebb6e83
              762cfa6
              2579105
              ec104a2
              c0677c3
              f9c3351
              6e668ef
              a4a75a3
              6235923
              a75dedb
              0d2869d
              2d11075
              e022704
              5850d85
              2b398fd
              87668f7
              4c1c419
              72d059d
              7be7b02
              43336a2
              0a22729
              951c4f1
              05f6415
              e0475b7
              eac2724
              d1d5f30
              17b2eb2
              8868100
              a824862
              aaf9ef8
              5adbb7d
              894f960
              cd10524
              3fba5cc
              f16fc72
              f0cd211
              396f11e
              cf84ed7
              cad44d9
              b9227fa
              77a2c67
              c92cb2e
              42af698
              5e42b0e
              1a6da57
              265e7d3
              32dd6a0
              5dc2aa0
              d761487
              62efaae
              0d6757d
              b78d62e
              a5cf0a4
              8f3d51d
              752ae93
              77ac2bc
              4a70ec2
              c90b29e
              598cddf
              14122ea
              cdb454a
              79a6d4e
              821fce2
              e22dcfa
              f924720
              cedeb38
              4313a8c
              e0c91cb
              d2fad57
              0621ed5
              a48cdba
              b229467
              004f4d2
              80922b1
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -480,6 +480,62 @@ func (issue *Issue) getLabels(ctx context.Context) (err error) { | |
| return nil | ||
| } | ||
|  | ||
| func (issues IssueList) FilterValidByDoer(ctx context.Context, doer *user_model.User) (IssueList, error) { | ||
| repos, err := issues.LoadRepositories(ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|  | ||
| if err := repo_model.RepositoryList(repos).LoadOwners(ctx); err != nil { | ||
| return nil, err | ||
| } | ||
|  | ||
| issueList := issues[:0] | ||
| for _, issue := range issues { | ||
| if isIssueVisibleToDoer, err := issue.isIssueVisibleToDoer(ctx, doer); err != nil { | ||
| return nil, err | ||
| } else if isIssueVisibleToDoer { | ||
| issueList = append(issueList, issue) | ||
| } | ||
| } | ||
| return issueList, nil | ||
| } | ||
|  | ||
| // isIssueVisibleToDoer returns whether doer can view the issue | ||
| func (issue *Issue) isIssueVisibleToDoer(ctx context.Context, doer *user_model.User) (bool, error) { | ||
| if perm, err := access_model.GetUserRepoPermission(ctx, issue.Repo, doer); err != nil { | ||
| return false, err | ||
| } else if !perm.HasAccess() { | ||
| return false, nil | ||
| } | ||
|  | ||
| if unit.TypeIssues.UnitGlobalDisabled() { | ||
|          | ||
| return false, nil | ||
| } | ||
| if !issue.Repo.UnitEnabled(ctx, unit.TypeIssues) { | ||
|         
                  6543 marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| return false, nil | ||
| } | ||
| // TODO: what about Mirror repo | ||
|  | ||
| if issue.Repo.Owner.IsOrganization() && issue.Repo.IsPrivate { | ||
| collaboration, err := repo_model.GetCollaboration(ctx, issue.Repo.ID, doer.ID) | ||
| if err != nil { | ||
| return false, fmt.Errorf("GetCollaboration: %w", err) | ||
| } | ||
| if collaboration == nil { | ||
| if (*organization.Organization)(issue.Repo.Owner).UnitPermission(ctx, doer, unit.TypeIssues) < perm.AccessModeRead { | ||
| return false, nil | ||
| } | ||
| } else { | ||
| if collaboration.Mode < perm.AccessModeRead { | ||
| return false, nil | ||
| } | ||
| } | ||
| } | ||
|  | ||
| return true, nil | ||
| } | ||
|  | ||
| func clearIssueLabels(ctx context.Context, issue *Issue, doer *user_model.User) (err error) { | ||
| if err = issue.getLabels(ctx); err != nil { | ||
| return fmt.Errorf("getLabels: %w", err) | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.