clean watches when make a repository private and check permission when send release emails (#36319)

This commit is contained in:
Lunny Xiao
2026-01-14 08:11:22 -08:00
committed by GitHub
parent 1c1a7b8492
commit 8a98ac2213
7 changed files with 153 additions and 8 deletions
+10
View File
@@ -176,3 +176,13 @@ func WatchIfAuto(ctx context.Context, userID, repoID int64, isWrite bool) error
}
return watchRepoMode(ctx, watch, WatchModeAuto)
}
// ClearRepoWatches clears all watches for a repository and from the user that watched it.
// Used when a repository is set to private.
func ClearRepoWatches(ctx context.Context, repoID int64) error {
if _, err := db.Exec(ctx, "UPDATE `repository` SET num_watches = 0 WHERE id = ?", repoID); err != nil {
return err
}
return db.DeleteBeans(ctx, Watch{RepoID: repoID})
}