Skip to content
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

Fix not removed watches on unallowed repositories #4201

Merged
merged 13 commits into from
Jun 19, 2018

Conversation

daviian
Copy link
Member

@daviian daviian commented Jun 9, 2018

Targets: #3343, #3782, #4149

What does it do:

  • removes watches if users gets removed from a team or a team is deleted as a whole.
  • also sets new team users to watch all team repositories.
  • remove watch if user gets removed from the collaborators of a repo

TODO:

  • create migration to remove watches that are hanging in the air
  • also remove issue_watches
  • also remove issue_watches in migration

@daviian daviian changed the title Bugfix/watches Fix not removed watches on unallowed repositories Jun 9, 2018
@codecov-io
Copy link

codecov-io commented Jun 9, 2018

Codecov Report

Merging #4201 into master will increase coverage by 0.01%.
The diff coverage is 29.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4201      +/-   ##
==========================================
+ Coverage   19.97%   19.98%   +0.01%     
==========================================
  Files         153      153              
  Lines       30530    30581      +51     
==========================================
+ Hits         6097     6112      +15     
- Misses      23519    23542      +23     
- Partials      914      927      +13
Impacted Files Coverage Δ
models/repo_collaboration.go 64.22% <0%> (-3.3%) ⬇️
models/repo.go 17.78% <0%> (-0.04%) ⬇️
models/issue_watch.go 76.47% <100%> (+5.73%) ⬆️
models/org_team.go 50.22% <15.62%> (-2.75%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 467ff4d...75f9efb. Read the comment docs.

@bkcsoft bkcsoft added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 9, 2018
@bkcsoft bkcsoft added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 9, 2018
@lafriks lafriks added this to the 1.5.0 milestone Jun 9, 2018
@daviian
Copy link
Member Author

daviian commented Jun 9, 2018

@lafriks Please add status/wip as I've to add the migration to cleanup hanging watches

@techknowlogick techknowlogick added the pr/wip This PR is not ready for review label Jun 10, 2018
@bkcsoft
Copy link
Member

bkcsoft commented Jun 15, 2018

@daviian I don't think that the mgiration is necessary for this fix. It would be nice to have, but not something that should hold back this PR.

@daviian
Copy link
Member Author

daviian commented Jun 15, 2018

@bkcsoft It's already implemented. I'm currently in the middle of testing the migration locally ;) If it's fine i'll push.

@daviian daviian removed the pr/wip This PR is not ready for review label Jun 15, 2018
return a.Mode, nil
}

sess := x.NewSession()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need

defer sess.Close()
if err := sess.Begin(); err != nil {
return err
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes. Totally forgot.

@@ -178,6 +178,11 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e
if err = watchRepo(e, teamUser.UID, repo.ID, false); err != nil {
return err
}

// Remove all IssueWatches a user has subscribed to in the repositories
if err := removeIssueWatchersByRepoID(e, teamUser.ID, repo.ID); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

teamUser.UID

@daviian
Copy link
Member Author

daviian commented Jun 15, 2018

@lunny Added your suggestions

}
if _, err := x.Get(repo); err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should repoCache[watch.RepoID] = repo

}
if _, err := x.Get(repo); err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

@lunny
Copy link
Member

lunny commented Jun 19, 2018

Please follow my comment, otherwise LGTM

@bkcsoft bkcsoft added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 19, 2018
@techknowlogick techknowlogick merged commit a93f138 into go-gitea:master Jun 19, 2018
@techknowlogick
Copy link
Member

@lafriks the ticket this was attached to was marked as backport, but you removed the label from this PR, should it still be backported?

@lunny
Copy link
Member

lunny commented Jun 20, 2018

This will not be back port since it has a migration which will let user difficult upgrade from v1.4 to v1.5

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants