diff --git a/docs/publish.md b/docs/publish.md index 6410bece..745c99c4 100644 --- a/docs/publish.md +++ b/docs/publish.md @@ -1248,7 +1248,6 @@ Below are the functions that are available to use inside your message/title temp * [Path and Filepath Functions](publish/template-functions.md#path-and-filepath-functions): `base`, `dir`, `ext`, `clean`, `isAbs`, `osBase`, `osDir`, `osExt`, `osClean`, `osIsAbs` * [Flow Control Functions](publish/template-functions.md#flow-control-functions): `fail` * Advanced Functions - * [UUID Functions](publish/template-functions.md#uuid-functions): `uuidv4` * [Reflection](publish/template-functions.md#reflection-functions): `typeOf`, `kindIs`, `typeIsLike`, etc. * [Cryptographic and Security Functions](publish/template-functions.md#cryptographic-and-security-functions): `sha256sum`, etc. * [URL](publish/template-functions.md#url-functions): `urlParse`, `urlJoin` diff --git a/docs/publish/template-functions.md b/docs/publish/template-functions.md index 238bddd9..4c6b6dfe 100644 --- a/docs/publish/template-functions.md +++ b/docs/publish/template-functions.md @@ -18,7 +18,6 @@ The original set of template functions is based on the [Sprig library](https://m - [Type Conversion Functions](#type-conversion-functions) - [Path and Filepath Functions](#path-and-filepath-functions) - [Flow Control Functions](#flow-control-functions) -- [UUID Functions](#uuid-functions) - [Reflection Functions](#reflection-functions) - [Cryptographic and Security Functions](#cryptographic-and-security-functions) - [URL Functions](#url-functions) @@ -1357,16 +1356,6 @@ template rendering should fail. fail "Please accept the end user license agreement" ``` -## UUID Functions - -Sprig can generate UUID v4 universally unique IDs. - -``` -uuidv4 -``` - -The above returns a new UUID of the v4 (randomly generated) type. - ## Reflection Functions Sprig provides rudimentary reflection tools. These help advanced template diff --git a/go.mod b/go.mod index 88b88463..dc35ae8b 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require github.com/pkg/errors v0.9.1 // indirect require ( firebase.google.com/go/v4 v4.16.1 github.com/SherClockHolmes/webpush-go v1.4.0 - github.com/google/uuid v1.6.0 github.com/microcosm-cc/bluemonday v1.0.27 github.com/prometheus/client_golang v1.22.0 github.com/stripe/stripe-go/v74 v74.30.0 @@ -69,6 +68,7 @@ require ( github.com/golang-jwt/jwt/v5 v5.2.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/s2a-go v0.1.9 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect github.com/googleapis/gax-go/v2 v2.14.2 // indirect github.com/gorilla/css v1.0.1 // indirect diff --git a/server/server_test.go b/server/server_test.go index c904cbb7..ad2bb8fd 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -3083,7 +3083,7 @@ func TestServer_MessageTemplate_FromNamedTemplate_GitHubCommentCreated(t *testin response := request(t, s, "POST", "/mytopic?template=github", githubCommentCreatedJSON, nil) require.Equal(t, 200, response.Code) m := toMessage(t, response.Body.String()) - require.Equal(t, "💬 [ntfy] New comment on issue #1389 instant alerts without Pull to refresh", m.Title) + require.Equal(t, "💬 New comment on issue #1389 instant alerts without Pull to refresh", m.Title) require.Equal(t, `Commenter: https://github.com/wunter8 Repository: https://github.com/binwiederhier/ntfy Comment link: https://github.com/binwiederhier/ntfy/issues/1389#issuecomment-3078214289 @@ -3102,7 +3102,7 @@ func TestServer_MessageTemplate_FromNamedTemplate_GitHubIssueOpened(t *testing.T response := request(t, s, "POST", "/mytopic?template=github", githubIssueOpenedJSON, nil) require.Equal(t, 200, response.Code) m := toMessage(t, response.Body.String()) - require.Equal(t, "🐛 [ntfy] Issue opened: #1391 http 500 error (ntfy error 50001)", m.Title) + require.Equal(t, "🐛 Issue opened: #1391 http 500 error (ntfy error 50001)", m.Title) require.Equal(t, `Opened by: https://github.com/TheUser-dev Repository: https://github.com/binwiederhier/ntfy Issue link: https://github.com/binwiederhier/ntfy/issues/1391 diff --git a/util/sprig/crypto.go b/util/sprig/crypto.go index 4d027781..db8a6814 100644 --- a/util/sprig/crypto.go +++ b/util/sprig/crypto.go @@ -7,8 +7,6 @@ import ( "encoding/hex" "fmt" "hash/adler32" - - "github.com/google/uuid" ) func sha512sum(input string) string { @@ -30,8 +28,3 @@ func adler32sum(input string) string { hash := adler32.Checksum([]byte(input)) return fmt.Sprintf("%d", hash) } - -// uuidv4 provides a safe and secure UUID v4 implementation -func uuidv4() string { - return uuid.New().String() -} diff --git a/util/sprig/crypto_test.go b/util/sprig/crypto_test.go index bad809a5..d6fb1736 100644 --- a/util/sprig/crypto_test.go +++ b/util/sprig/crypto_test.go @@ -31,24 +31,3 @@ func TestAdler32Sum(t *testing.T) { t.Error(err) } } - -func TestUUIDGeneration(t *testing.T) { - tpl := `{{uuidv4}}` - out, err := runRaw(tpl, nil) - if err != nil { - t.Error(err) - } - - if len(out) != 36 { - t.Error("Expected UUID of length 36") - } - - out2, err := runRaw(tpl, nil) - if err != nil { - t.Error(err) - } - - if out == out2 { - t.Error("Expected subsequent UUID generations to be different") - } -} diff --git a/util/sprig/functions.go b/util/sprig/functions.go index 1cd026c6..10ededd6 100644 --- a/util/sprig/functions.go +++ b/util/sprig/functions.go @@ -58,10 +58,7 @@ var genericMap = map[string]any{ }, "substr": substring, // Switch order so that "foo" | repeat 5 - "repeat": func(count int, str string) string { return strings.Repeat(str, count) }, - // Deprecated: Use trimAll. - "trimall": func(a, b string) string { return strings.Trim(b, a) }, - // Switch order so that "$foo" | trimall "$" + "repeat": func(count int, str string) string { return strings.Repeat(str, count) }, "trimAll": func(a, b string) string { return strings.Trim(b, a) }, "trimSuffix": func(a, b string) string { return strings.TrimSuffix(b, a) }, "trimPrefix": func(a, b string) string { return strings.TrimPrefix(b, a) }, @@ -220,9 +217,6 @@ var genericMap = map[string]any{ "chunk": chunk, "mustChunk": mustChunk, - // UUIDs: - "uuidv4": uuidv4, - // Flow Control: "fail": func(msg string) (string, error) { return "", errors.New(msg) },