Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: preserve webhook URL query params for generic notifications (#2276)
Giulio Savinia598df7b1ed8
diff --git a/backend/pkg/utils/notifications/generic_sender.go b/backend/pkg/utils/notifications/generic_sender.goindex d79281a8b..6366f1da2 100644--- a/backend/pkg/utils/notifications/generic_sender.go+++ b/backend/pkg/utils/notifications/generic_sender.go@@ -45,11 +45,22 @@ func BuildGenericURL(config models.GenericConfig) (string, error) {// Shoutrrr's generic service uses HTTP or HTTPS based on the DisableTLS settingscheme := "generic"- // Start with the base URL+ // Start with the base URL.+ // Preserve any query parameters from the original webhook URL by encoding+ // the ? as %3F so it stays in the path component. Shoutrrr decodes the path+ // when constructing the outbound HTTP request, recovering the original query+ // string for the upstream service.+ rawPath := webhookURL.Path+ decodedPath := webhookURL.Path+ if webhookURL.RawQuery != "" {+ rawPath = webhookURL.Path + "%3F" + webhookURL.RawQuery+ decodedPath = webhookURL.Path + "?" + webhookURL.RawQuery+ }shoutrrrURL := &url.URL{- Scheme: scheme,- Host: webhookURL.Host,- Path: webhookURL.Path,+ Scheme: scheme,+ Host: webhookURL.Host,+ RawPath: rawPath,+ Path: decodedPath,}// Build query parameters@@ -116,14 +127,11 @@ func SendGenericWithTitle(ctx context.Context, config models.GenericConfig, titlreturn fmt.Errorf("failed to create shoutrrr Generic sender: %w", err)}- // Build params with title+ // Build params with title. Always use "title" as the param key — Shoutrrr's+ // generic service maps it to the configured titlekey in the JSON payload.params := shoutrrrTypes.Params{}if title != "" {- titleKey := config.TitleKey- if titleKey == "" {- titleKey = "title"- }- params[titleKey] = title+ params["title"] = title}errs := sender.Send(message, ¶ms)diff --git a/backend/pkg/utils/notifications/generic_sender_test.go b/backend/pkg/utils/notifications/generic_sender_test.goindex 037f03d2a..86ae30bd9 100644--- a/backend/pkg/utils/notifications/generic_sender_test.go+++ b/backend/pkg/utils/notifications/generic_sender_test.go@@ -129,6 +129,20 @@ func TestBuildGenericURL(t *testing.T) {},wantURL: "generic://webhook.example.com:8443/api/v1/notify",},+ {+ name: "webhook URL with query params preserved",+ config: models.GenericConfig{+ WebhookURL: "http://www.pushplus.plus/send?token=abc123",+ },+ wantURL: "generic://www.pushplus.plus/send%3Ftoken=abc123?disabletls=yes&template=json",+ },+ {+ name: "webhook URL with multiple query params preserved",+ config: models.GenericConfig{+ WebhookURL: "https://api.example.com/webhook?token=abc&channel=general",+ },+ wantURL: "generic://api.example.com/webhook%3Ftoken=abc&channel=general?disabletls=no&template=json",+ },{name: "empty webhook URL",config: models.GenericConfig{