forked from forgejo/forgejo
fix webhook test (#2415)
* fix webhook test * fix error message * fix typo
This commit is contained in:
parent
491f0ebc58
commit
3e6fed368b
2 changed files with 63 additions and 46 deletions
|
@ -545,6 +545,14 @@ func DiscordHooksEditPost(ctx *context.Context, form auth.NewDiscordHookForm) {
|
|||
|
||||
// TestWebhook test if web hook is work fine
|
||||
func TestWebhook(ctx *context.Context) {
|
||||
hookID := ctx.ParamsInt64(":id")
|
||||
w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID)
|
||||
if err != nil {
|
||||
ctx.Flash.Error("GetWebhookByID: " + err.Error())
|
||||
ctx.Status(500)
|
||||
return
|
||||
}
|
||||
|
||||
// Grab latest commit or fake one if it's empty repository.
|
||||
commit := ctx.Repo.Commit
|
||||
if commit == nil {
|
||||
|
@ -581,8 +589,8 @@ func TestWebhook(ctx *context.Context) {
|
|||
Pusher: apiUser,
|
||||
Sender: apiUser,
|
||||
}
|
||||
if err := models.PrepareWebhooks(ctx.Repo.Repository, models.HookEventPush, p); err != nil {
|
||||
ctx.Flash.Error("PrepareWebhooks: " + err.Error())
|
||||
if err := models.PrepareWebhook(w, ctx.Repo.Repository, models.HookEventPush, p); err != nil {
|
||||
ctx.Flash.Error("PrepareWebhook: " + err.Error())
|
||||
ctx.Status(500)
|
||||
} else {
|
||||
go models.HookQueue.Add(ctx.Repo.Repository.ID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue