aboutsummaryrefslogtreecommitdiff
path: root/internal/ui
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <f@miniflux.net> 2023-09-08 22:45:17 -0700
committerGravatar Frédéric Guillot <f@miniflux.net> 2023-09-09 13:11:42 -0700
commit48f6885f4472efbe0e23f990ae8d4545f9a6a73d (patch)
treea05b35013e65f95013f90006b07870ddaeaf4065 /internal/ui
parent32d33104a4934771ca99b1bcfe55bd0e4e88809b (diff)
downloadv2-48f6885f4472efbe0e23f990ae8d4545f9a6a73d.tar.gz
v2-48f6885f4472efbe0e23f990ae8d4545f9a6a73d.tar.zst
v2-48f6885f4472efbe0e23f990ae8d4545f9a6a73d.zip
Add generic webhook integration
Diffstat (limited to 'internal/ui')
-rw-r--r--internal/ui/form/integration.go7
-rw-r--r--internal/ui/integration_show.go3
-rw-r--r--internal/ui/integration_update.go12
3 files changed, 22 insertions, 0 deletions
diff --git a/internal/ui/form/integration.go b/internal/ui/form/integration.go
index 53ff9202..de7b1630 100644
--- a/internal/ui/form/integration.go
+++ b/internal/ui/form/integration.go
@@ -69,6 +69,9 @@ type IntegrationForm struct {
ShaarliEnabled bool
ShaarliURL string
ShaarliAPISecret string
+ WebhookEnabled bool
+ WebhookURL string
+ WebhookSecret string
}
// Merge copy form values to the model.
@@ -129,6 +132,8 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
integration.ShaarliEnabled = i.ShaarliEnabled
integration.ShaarliURL = i.ShaarliURL
integration.ShaarliAPISecret = i.ShaarliAPISecret
+ integration.WebhookEnabled = i.WebhookEnabled
+ integration.WebhookURL = i.WebhookURL
}
// NewIntegrationForm returns a new IntegrationForm.
@@ -192,5 +197,7 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
ShaarliEnabled: r.FormValue("shaarli_enabled") == "1",
ShaarliURL: r.FormValue("shaarli_url"),
ShaarliAPISecret: r.FormValue("shaarli_api_secret"),
+ WebhookEnabled: r.FormValue("webhook_enabled") == "1",
+ WebhookURL: r.FormValue("webhook_url"),
}
}
diff --git a/internal/ui/integration_show.go b/internal/ui/integration_show.go
index 7a30a043..abde5348 100644
--- a/internal/ui/integration_show.go
+++ b/internal/ui/integration_show.go
@@ -84,6 +84,9 @@ func (h *handler) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
ShaarliEnabled: integration.ShaarliEnabled,
ShaarliURL: integration.ShaarliURL,
ShaarliAPISecret: integration.ShaarliAPISecret,
+ WebhookEnabled: integration.WebhookEnabled,
+ WebhookURL: integration.WebhookURL,
+ WebhookSecret: integration.WebhookSecret,
}
sess := session.New(h.store, request.SessionID(r))
diff --git a/internal/ui/integration_update.go b/internal/ui/integration_update.go
index 4a68691c..b8bfed44 100644
--- a/internal/ui/integration_update.go
+++ b/internal/ui/integration_update.go
@@ -67,6 +67,18 @@ func (h *handler) updateIntegration(w http.ResponseWriter, r *http.Request) {
integration.GoogleReaderPassword = ""
}
+ if integrationForm.WebhookEnabled {
+ if integrationForm.WebhookURL == "" {
+ integration.WebhookEnabled = false
+ integration.WebhookSecret = ""
+ } else if integration.WebhookSecret == "" {
+ integration.WebhookSecret = crypto.GenerateRandomStringHex(32)
+ }
+ } else {
+ integration.WebhookURL = ""
+ integration.WebhookSecret = ""
+ }
+
err = h.store.UpdateIntegration(integration)
if err != nil {
html.ServerError(w, r, err)