summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-10-21 18:21:56 +0200
committerGitHub <noreply@github.com>2022-10-21 18:21:56 +0200
commit1887c9525483957cfc2a1af5bccfd7d03b41f015 (patch)
tree5e50c736dfec251aaa628286c75e9aec19f1c8a4 /routers/api/v1/repo
parente828564445ba5856747f17faf2ac6b1a223a911d (diff)
downloadgitea-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 'routers/api/v1/repo')
-rw-r--r--routers/api/v1/repo/hook.go2
-rw-r--r--routers/api/v1/repo/hook_test.go1
2 files changed, 1 insertions, 2 deletions
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go
index 86361817cb..5956fe9da9 100644
--- a/routers/api/v1/repo/hook.go
+++ b/routers/api/v1/repo/hook.go
@@ -168,7 +168,7 @@ func TestHook(ctx *context.APIContext) {
commit := convert.ToPayloadCommit(ctx.Repo.Repository, ctx.Repo.Commit)
commitID := ctx.Repo.Commit.ID.String()
- if err := webhook_service.PrepareWebhook(hook, ctx.Repo.Repository, webhook.HookEventPush, &api.PushPayload{
+ if err := webhook_service.PrepareWebhook(ctx, hook, webhook.HookEventPush, &api.PushPayload{
Ref: ref,
Before: commitID,
After: commitID,
diff --git a/routers/api/v1/repo/hook_test.go b/routers/api/v1/repo/hook_test.go
index 07f1532f82..fd9a165bf3 100644
--- a/routers/api/v1/repo/hook_test.go
+++ b/routers/api/v1/repo/hook_test.go
@@ -28,7 +28,6 @@ func TestTestHook(t *testing.T) {
assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
unittest.AssertExistsAndLoadBean(t, &webhook.HookTask{
- RepoID: 1,
HookID: 1,
}, unittest.Cond("is_delivered=?", false))
}