From e91e2093f99a0ee10d6e2908ecdf1bed536e8c62 Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Thu, 24 Aug 2023 18:21:38 +0200 Subject: [PATCH 1/3] Default to enable all request methods --- echo_handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echo_handlers.go b/echo_handlers.go index ab599bac..6e5fae76 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -250,7 +250,7 @@ func (svc *Service) AppsNewHandler(c echo.Context) error { requestMethods := c.QueryParam("request_methods") if requestMethods == "" { //pay_invoice checkbox is default checked but can be disabled - requestMethods = NIP_47_PAY_INVOICE_METHOD + requestMethods = fmt.Sprintf("%s %s %s", NIP_47_GET_BALANCE_METHOD, NIP_47_PAY_INVOICE_METHOD, NIP_47_MAKE_INVOICE_METHOD) } budgetEnabled := maxAmount != "" || budgetRenewal != "" csrf, _ := c.Get(middleware.DefaultCSRFConfig.ContextKey).(string) From 556a8f48f657e880d6f4c8e6054de510cacb7799 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Tue, 29 Aug 2023 11:44:13 +0700 Subject: [PATCH 2/3] chore: do not hardcode default selected request methods --- echo_handlers.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/echo_handlers.go b/echo_handlers.go index 6e5fae76..06ac1cef 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -249,8 +249,13 @@ func (svc *Service) AppsNewHandler(c echo.Context) error { disabled := c.QueryParam("editable") == "false" requestMethods := c.QueryParam("request_methods") if requestMethods == "" { - //pay_invoice checkbox is default checked but can be disabled - requestMethods = fmt.Sprintf("%s %s %s", NIP_47_GET_BALANCE_METHOD, NIP_47_PAY_INVOICE_METHOD, NIP_47_MAKE_INVOICE_METHOD) + // if no request methods are given, enable them all by default + keys := make([]string, 0, len(nip47MethodDescriptions)) + for key := range nip47MethodDescriptions { + keys = append(keys, key) + } + + requestMethods = strings.Join(keys, " ") } budgetEnabled := maxAmount != "" || budgetRenewal != "" csrf, _ := c.Get(middleware.DefaultCSRFConfig.ContextKey).(string) From 033e4c844fcecc73948420e164cd32c58c52ffb5 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Tue, 29 Aug 2023 11:46:55 +0700 Subject: [PATCH 3/3] fix: initialize array --- echo_handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echo_handlers.go b/echo_handlers.go index 06ac1cef..30e5eb66 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -250,7 +250,7 @@ func (svc *Service) AppsNewHandler(c echo.Context) error { requestMethods := c.QueryParam("request_methods") if requestMethods == "" { // if no request methods are given, enable them all by default - keys := make([]string, 0, len(nip47MethodDescriptions)) + keys := []string{} for key := range nip47MethodDescriptions { keys = append(keys, key) }