mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 05:36:19 +01:00
some fixes, but not done yet!
This commit is contained in:
parent
6b7d35eade
commit
25f5a8d798
1 changed files with 12 additions and 7 deletions
|
@ -88,6 +88,11 @@ func maxAccessMode(modes ...AccessMode) AccessMode {
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *Repository) recalculateTeamAccesses(e Engine, mode AccessMode) error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *Repository) recalculateAccesses(e Engine) error {
|
func (repo *Repository) recalculateAccesses(e Engine) error {
|
||||||
accessMap := make(map[int64]AccessMode, 20)
|
accessMap := make(map[int64]AccessMode, 20)
|
||||||
|
|
||||||
|
@ -111,6 +116,8 @@ func (repo *Repository) recalculateAccesses(e Engine) error {
|
||||||
for _, team := range repo.Owner.Teams {
|
for _, team := range repo.Owner.Teams {
|
||||||
if !(team.IsOwnerTeam() || team.HasRepository(repo)) {
|
if !(team.IsOwnerTeam() || team.HasRepository(repo)) {
|
||||||
continue
|
continue
|
||||||
|
} else if team.IsOwnerTeam() {
|
||||||
|
team.Authorize = ACCESS_MODE_OWNER
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = team.getMembers(e); err != nil {
|
if err = team.getMembers(e); err != nil {
|
||||||
|
@ -129,22 +136,20 @@ func (repo *Repository) recalculateAccesses(e Engine) error {
|
||||||
|
|
||||||
newAccesses := make([]Access, 0, len(accessMap))
|
newAccesses := make([]Access, 0, len(accessMap))
|
||||||
for userID, mode := range accessMap {
|
for userID, mode := range accessMap {
|
||||||
if userID == repo.OwnerId || mode <= minMode {
|
if mode < minMode {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newAccesses = append(newAccesses, Access{
|
newAccesses = append(newAccesses, Access{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
RepoID: repo.Id,
|
RepoID: repo.Id,
|
||||||
Mode: mode})
|
Mode: mode,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete old accesses for repository
|
// Delete old accesses and insert new ones for repository.
|
||||||
if _, err = e.Delete(&Access{RepoID: repo.Id}); err != nil {
|
if _, err = e.Delete(&Access{RepoID: repo.Id}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
} else if _, err = e.Insert(newAccesses); err != nil {
|
||||||
|
|
||||||
// And insert the new ones
|
|
||||||
if _, err = e.Insert(newAccesses); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue