Skip to content

Commit 2b1350f

Browse files
authored
Merge pull request #1438 from getfider/failing-webhooks
Option to keep failing webhooks enabled.
2 parents 6ac93b8 + 0b7f13a commit 2b1350f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

app/pkg/env/env.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ type config struct {
144144
Message string `env:"MAINTENANCE_MESSAGE"`
145145
Until string `env:"MAINTENANCE_UNTIL"`
146146
}
147+
Webhook struct {
148+
DisableOnFailure bool `env:"WEBHOOK_DISABLE_ON_FAILURE,default=true"`
149+
}
147150
GoogleAnalytics string `env:"GOOGLE_ANALYTICS"`
148151
SearchNoiseWords string `env:"SEARCH_NOISE_WORDS,default=add|support|for|implement|create|make|allow|enable|provide|some|also|include|very|make|and|for|to|a|able|function|feature|app"`
149152
}

app/services/webhook/webhook.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ package webhook
33
import (
44
"context"
55
"fmt"
6+
"net/http"
7+
"strings"
8+
69
"github.com/getfider/fider/app/models/cmd"
710
"github.com/getfider/fider/app/models/dto"
811
"github.com/getfider/fider/app/models/entity"
912
"github.com/getfider/fider/app/models/query"
1013
"github.com/getfider/fider/app/pkg/bus"
14+
"github.com/getfider/fider/app/pkg/env"
1115
"github.com/getfider/fider/app/pkg/log"
1216
"github.com/getfider/fider/app/pkg/tpl"
1317
"github.com/getfider/fider/app/pkg/webhook"
14-
"net/http"
15-
"strings"
1618
)
1719

1820
func init() {
@@ -159,10 +161,12 @@ func resultWithError(ctx context.Context, message, error string, result *dto.Web
159161
"Error": error,
160162
})
161163

162-
webhooks := &query.MarkWebhookAsFailed{ID: result.Webhook.ID}
163-
err := bus.Dispatch(ctx, webhooks)
164-
if err != nil {
165-
return nil, err
164+
if env.Config.Webhook.DisableOnFailure {
165+
webhooks := &query.MarkWebhookAsFailed{ID: result.Webhook.ID}
166+
err := bus.Dispatch(ctx, webhooks)
167+
if err != nil {
168+
return nil, err
169+
}
166170
}
167171

168172
return result, nil

0 commit comments

Comments
 (0)