remove issue_watches when team member is removed, team repository is removed, a collaborator is removed
This commit is contained in:
parent
fd3cf7e090
commit
7d54006802
|
|
@ -71,3 +71,14 @@ func getIssueWatchers(e Engine, issueID int64) (watches []*IssueWatch, err error
|
|||
Find(&watches)
|
||||
return
|
||||
}
|
||||
|
||||
func removeIssueWatchersByRepoID(e Engine, userID int64, repoID int64) error {
|
||||
iw := &IssueWatch{
|
||||
IsWatching: false,
|
||||
}
|
||||
_, err := e.
|
||||
Join("INNER", "issue", "`issue`.id = `issue_watch`.issue_id AND `issue`.repo_id = ?", repoID).
|
||||
Cols("is_watching", "updated_unix").
|
||||
Update(iw)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -396,6 +401,11 @@ func DeleteTeam(t *Team) error {
|
|||
if err = watchRepo(sess, user.ID, repo.ID, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove all IssueWatches a user has subscribed to in the repositories
|
||||
if err = removeIssueWatchersByRepoID(sess, user.ID, repo.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -592,6 +602,11 @@ func removeTeamMember(e *xorm.Session, team *Team, userID int64) error {
|
|||
if err = watchRepo(e, userID, repo.ID, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove all IssueWatches a user has subscribed to in the repositories
|
||||
if err := removeIssueWatchersByRepoID(e, userID, repo.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the user is a member of any team in the organization.
|
||||
|
|
|
|||
|
|
@ -1851,6 +1851,9 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
|
|||
if _, err = sess.In("issue_id", issueIDs).Delete(&Reaction{}); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = sess.In("issue_id", issueIDs).Delete(&IssueWatch{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
attachments := make([]*Attachment, 0, 5)
|
||||
if err = sess.
|
||||
|
|
|
|||
|
|
@ -176,5 +176,10 @@ func (repo *Repository) DeleteCollaboration(uid int64) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
// Remove all IssueWatches a user has subscribed to in the repository
|
||||
if err := removeIssueWatchersByRepoID(sess, uid, repo.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user