Bläddra i källkod

Remove github.com/google/uuid

Replace it with a hand-rolled implementation. Heck, an UUID isn't even a
requirement, according to [omnivore](https://docs.omnivore.app/integrations/api.html#saving-a-url-with-the-api)'s
documentation, any "unique id" would do.
jvoisin 2 år sedan
förälder
incheckning
bce21a9f91
3 ändrade filer med 8 tillägg och 4 borttagningar
  1. 1 1
      go.mod
  2. 5 0
      internal/crypto/crypto.go
  3. 2 3
      internal/integration/omnivore/omnivore.go

+ 1 - 1
go.mod

@@ -7,7 +7,6 @@ require (
 	github.com/abadojack/whatlanggo v1.0.1
 	github.com/coreos/go-oidc/v3 v3.9.0
 	github.com/go-webauthn/webauthn v0.10.1
-	github.com/google/uuid v1.6.0
 	github.com/gorilla/mux v1.8.1
 	github.com/lib/pq v1.10.9
 	github.com/prometheus/client_golang v1.18.0
@@ -33,6 +32,7 @@ require (
 	github.com/fxamacker/cbor/v2 v2.5.0 // indirect
 	github.com/go-jose/go-jose/v3 v3.0.1 // indirect
 	github.com/golang/protobuf v1.5.3 // indirect
+	github.com/google/uuid v1.6.0 // indirect
 	github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/prometheus/client_model v0.5.0 // indirect

+ 5 - 0
internal/crypto/crypto.go

@@ -55,3 +55,8 @@ func GenerateSHA256Hmac(secret string, data []byte) string {
 	h.Write(data)
 	return hex.EncodeToString(h.Sum(nil))
 }
+
+func GenerateUUID() string {
+	b := GenerateRandomBytes(16)
+	return fmt.Sprintf("%X-%X-%X-%X-%X", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
+}

+ 2 - 3
internal/integration/omnivore/omnivore.go

@@ -11,8 +11,7 @@ import (
 	"net/http"
 	"time"
 
-	"github.com/google/uuid"
-
+	"miniflux.app/v2/internal/crypto"
 	"miniflux.app/v2/internal/version"
 )
 
@@ -79,7 +78,7 @@ func (c *client) SaveUrl(url string) error {
 		"query": mutation,
 		"variables": map[string]interface{}{
 			"input": map[string]interface{}{
-				"clientRequestId": uuid.New().String(),
+				"clientRequestId": crypto.GenerateUUID(),
 				"source":          "api",
 				"url":             url,
 			},