diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-10-21 18:21:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 18:21:56 +0200 |
commit | 1887c9525483957cfc2a1af5bccfd7d03b41f015 (patch) | |
tree | 5e50c736dfec251aaa628286c75e9aec19f1c8a4 /models/repo.go | |
parent | e828564445ba5856747f17faf2ac6b1a223a911d (diff) | |
download | gitea-1887c9525483957cfc2a1af5bccfd7d03b41f015.tar.gz gitea-1887c9525483957cfc2a1af5bccfd7d03b41f015.zip |
Decouple HookTask from Repository (#17940)
At the moment a repository reference is needed for webhooks. With the
upcoming package PR we need to send webhooks without a repository
reference. For example a package is uploaded to an organization. In
theory this enables the usage of webhooks for future user actions.
This PR removes the repository id from `HookTask` and changes how the
hooks are processed (see `services/webhook/deliver.go`). In a follow up
PR I want to remove the usage of the `UniqueQueue´ and replace it with a
normal queue because there is no reason to be unique.
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go index 65159f14af..08fbb0abea 100644 --- a/models/repo.go +++ b/models/repo.go @@ -123,6 +123,11 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error { return err } + if _, err := db.GetEngine(ctx).In("hook_id", builder.Select("id").From("webhook").Where(builder.Eq{"webhook.repo_id": repo.ID})). + Delete(&webhook.HookTask{}); err != nil { + return err + } + if err := db.DeleteBeans(ctx, &access_model.Access{RepoID: repo.ID}, &activities_model.Action{RepoID: repo.ID}, @@ -130,7 +135,6 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error { &issues_model.Comment{RefRepoID: repoID}, &git_model.CommitStatus{RepoID: repoID}, &git_model.DeletedBranch{RepoID: repoID}, - &webhook.HookTask{RepoID: repoID}, &git_model.LFSLock{RepoID: repoID}, &repo_model.LanguageStat{RepoID: repoID}, &issues_model.Milestone{RepoID: repoID}, |