Skip to content

Commit

Permalink
Use a standalone struct name for Organization (go-gitea#17632)
Browse files Browse the repository at this point in the history
* Use a standalone struct name for Organization

* recover unnecessary change

* make the code readable

* Fix template failure

* Fix template failure

* Move HasMemberWithUserID to org

* Fix test

* Remove unnecessary user type check

* Fix test

Co-authored-by: wxiaoguang <[email protected]>
  • Loading branch information
2 people authored and Stelios Malathouras committed Mar 28, 2022
1 parent 9212736 commit fd3823c
Show file tree
Hide file tree
Showing 43 changed files with 335 additions and 259 deletions.
5 changes: 3 additions & 2 deletions models/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,12 @@ func (repo *Repository) recalculateTeamAccesses(e db.Engine, ignTeamID int64) (e
return fmt.Errorf("refreshCollaboratorAccesses: %v", err)
}

if err = repo.Owner.loadTeams(e); err != nil {
teams, err := OrgFromUser(repo.Owner).loadTeams(e)
if err != nil {
return err
}

for _, t := range repo.Owner.Teams {
for _, t := range teams {
if t.ID == ignTeamID {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
// check readable repositories by doer/actor
if opts.Actor == nil || !opts.Actor.IsAdmin {
if opts.RequestedUser.IsOrganization() {
env, err := opts.RequestedUser.AccessibleReposEnv(actorID)
env, err := OrgFromUser(opts.RequestedUser).AccessibleReposEnv(actorID)
if err != nil {
return nil, fmt.Errorf("AccessibleReposEnv: %v", err)
}
Expand All @@ -366,7 +366,7 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
}

if opts.RequestedTeam != nil {
env := opts.RequestedUser.AccessibleTeamReposEnv(opts.RequestedTeam)
env := OrgFromUser(opts.RequestedUser).AccessibleTeamReposEnv(opts.RequestedTeam)
teamRepoIDs, err := env.RepoIDs(1, opts.RequestedUser.NumRepos)
if err != nil {
return nil, fmt.Errorf("GetTeamRepositories: %v", err)
Expand Down
Loading

0 comments on commit fd3823c

Please sign in to comment.