Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Make the signing key optional

Acho Arnold431c2cf8d0e9
diff --git a/api/pkg/requests/request.go b/api/pkg/requests/request.go
index 19688f68..b6842804 100644
--- a/api/pkg/requests/request.go
+++ b/api/pkg/requests/request.go
@@ -1,6 +1,7 @@
package requests
import (
+ "net/url"
"strconv"
"strings"
"unicode"
@@ -42,6 +43,18 @@ func (input *request) sanitizeBool(value string) string {
return value
}
+func (input *request) sanitizeURL(value string) string {
+ value = strings.TrimSpace(value)
+ website, err := url.Parse(value)
+ if err != nil {
+ return value
+ }
+ if website.Scheme == "" {
+ return "https://" + value
+ }
+ return value
+}
+
func (input *request) sanitizeStringPointer(value string) *string {
value = strings.TrimSpace(value)
if value == "" {
diff --git a/api/pkg/requests/webhook_store_request.go b/api/pkg/requests/webhook_store_request.go
index d453adeb..fca0a7d2 100644
--- a/api/pkg/requests/webhook_store_request.go
+++ b/api/pkg/requests/webhook_store_request.go
@@ -18,7 +18,8 @@ type WebhookStore struct {
// Sanitize sets defaults to WebhookStore
func (input *WebhookStore) Sanitize() WebhookStore {
- input.URL = strings.TrimSpace(input.URL)
+ input.URL = input.sanitizeURL(input.URL)
+ input.SigningKey = strings.TrimSpace(input.SigningKey)
input.Events = input.removeStringDuplicates(input.Events)
var phoneNumbers []string
diff --git a/api/pkg/validators/webhook_handler_validator.go b/api/pkg/validators/webhook_handler_validator.go
index 89fd5042..131ae329 100644
--- a/api/pkg/validators/webhook_handler_validator.go
+++ b/api/pkg/validators/webhook_handler_validator.go
@@ -70,7 +70,6 @@ func (validator *WebhookHandlerValidator) ValidateStore(ctx context.Context, use
Data: &request,
Rules: govalidator.MapData{
"signing_key": []string{
- "required",
"min:1",
"max:255",
},
diff --git a/web/pages/settings/index.vue b/web/pages/settings/index.vue
index 9b439b5a..2061e2ae 100644
--- a/web/pages/settings/index.vue
+++ b/web/pages/settings/index.vue
@@ -429,7 +429,7 @@
class="mt-6"
persistent-placeholder
persistent-hint
- label="Signing Key"
+ label="Signing Key (optional)"
placeholder="******************"
:error="errorMessages.has('signing_key')"
:error-messages="errorMessages.get('signing_key')"