mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add replay of webhooks. (#18191)
This commit is contained in:
@@ -1189,11 +1189,33 @@ func TestWebhook(ctx *context.Context) {
|
||||
ctx.Flash.Error("PrepareWebhook: " + err.Error())
|
||||
ctx.Status(500)
|
||||
} else {
|
||||
ctx.Flash.Info(ctx.Tr("repo.settings.webhook.test_delivery_success"))
|
||||
ctx.Flash.Info(ctx.Tr("repo.settings.webhook.delivery.success"))
|
||||
ctx.Status(200)
|
||||
}
|
||||
}
|
||||
|
||||
// ReplayWebhook replays a webhook
|
||||
func ReplayWebhook(ctx *context.Context) {
|
||||
hookTaskUUID := ctx.Params(":uuid")
|
||||
|
||||
orCtx, w := checkWebhook(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
if err := webhook_service.ReplayHookTask(w, hookTaskUUID); err != nil {
|
||||
if webhook.IsErrHookTaskNotExist(err) {
|
||||
ctx.NotFound("ReplayHookTask", nil)
|
||||
} else {
|
||||
ctx.ServerError("ReplayHookTask", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.webhook.delivery.success"))
|
||||
ctx.Redirect(fmt.Sprintf("%s/%d", orCtx.Link, w.ID))
|
||||
}
|
||||
|
||||
// DeleteWebhook delete a webhook
|
||||
func DeleteWebhook(ctx *context.Context) {
|
||||
if err := webhook.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
|
Reference in New Issue
Block a user