aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/webhook.go
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/web/repo/webhook.go
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/web/repo/webhook.go')
-rw-r--r--routers/web/repo/webhook.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/routers/web/repo/webhook.go b/routers/web/repo/webhook.go
index 425198ce24..ee980333b7 100644
--- a/routers/web/repo/webhook.go
+++ b/routers/web/repo/webhook.go
@@ -633,7 +633,7 @@ func TestWebhook(ctx *context.Context) {
hookID := ctx.ParamsInt64(":id")
w, err := webhook.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID)
if err != nil {
- ctx.Flash.Error("GetWebhookByID: " + err.Error())
+ ctx.Flash.Error("GetWebhookByRepoID: " + err.Error())
ctx.Status(http.StatusInternalServerError)
return
}
@@ -679,7 +679,7 @@ func TestWebhook(ctx *context.Context) {
Pusher: apiUser,
Sender: apiUser,
}
- if err := webhook_service.PrepareWebhook(w, ctx.Repo.Repository, webhook.HookEventPush, p); err != nil {
+ if err := webhook_service.PrepareWebhook(ctx, w, webhook.HookEventPush, p); err != nil {
ctx.Flash.Error("PrepareWebhook: " + err.Error())
ctx.Status(http.StatusInternalServerError)
} else {
@@ -697,7 +697,7 @@ func ReplayWebhook(ctx *context.Context) {
return
}
- if err := webhook_service.ReplayHookTask(w, hookTaskUUID); err != nil {
+ if err := webhook_service.ReplayHookTask(ctx, w, hookTaskUUID); err != nil {
if webhook.IsErrHookTaskNotExist(err) {
ctx.NotFound("ReplayHookTask", nil)
} else {