diff --git a/build/pluginctl/logs_test.go b/build/pluginctl/logs_test.go index 687d8c2..2917a27 100644 --- a/build/pluginctl/logs_test.go +++ b/build/pluginctl/logs_test.go @@ -154,17 +154,17 @@ func TestFilterLogEntries(t *testing.T) { }, "filter out old entries": { logs: []string{ - fmt.Sprintf(`{"message":"old2", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, time.Now().Add(-2*time.Second).Format(timeStampFormat)), - fmt.Sprintf(`{"message":"old1", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, time.Now().Add(-1*time.Second).Format(timeStampFormat)), - fmt.Sprintf(`{"message":"now", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, time.Now().Format(timeStampFormat)), - fmt.Sprintf(`{"message":"new1", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, time.Now().Add(1*time.Second).Format(timeStampFormat)), - fmt.Sprintf(`{"message":"new2", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, time.Now().Add(2*time.Second).Format(timeStampFormat)), + fmt.Sprintf(`{"message":"old2", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, now.Add(-2*time.Second).Format(timeStampFormat)), + fmt.Sprintf(`{"message":"old1", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, now.Add(-1*time.Second).Format(timeStampFormat)), + fmt.Sprintf(`{"message":"now", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, now.Format(timeStampFormat)), + fmt.Sprintf(`{"message":"new1", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, now.Add(1*time.Second).Format(timeStampFormat)), + fmt.Sprintf(`{"message":"new2", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, now.Add(2*time.Second).Format(timeStampFormat)), }, pluginID: "some.plugin.id", since: now, expectedLogs: []string{ - fmt.Sprintf(`{"message":"new1", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, time.Now().Add(1*time.Second).Format(timeStampFormat)), - fmt.Sprintf(`{"message":"new2", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, time.Now().Add(2*time.Second).Format(timeStampFormat)), + fmt.Sprintf(`{"message":"new1", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, now.Add(1*time.Second).Format(timeStampFormat)), + fmt.Sprintf(`{"message":"new2", "plugin_id": "some.plugin.id", "timestamp": "%s"}`, now.Add(2*time.Second).Format(timeStampFormat)), }, expectedErr: false, }, diff --git a/go.mod b/go.mod index f212429..062e5c9 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/mattermost/mattermost/server/public v0.0.12 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.10.0 - github.com/thoas/go-funk v0.6.0 go.uber.org/atomic v1.11.0 ) diff --git a/go.sum b/go.sum index 5508626..8d4d4ae 100644 --- a/go.sum +++ b/go.sum @@ -172,15 +172,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= -github.com/thoas/go-funk v0.6.0 h1:ryxN0pa9FnI7YHgODdLIZ4T6paCZJt8od6N9oRztMxM= -github.com/thoas/go-funk v0.6.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/tinylib/msgp v1.1.9 h1:SHf3yoO2sGA0veCJeCBYLHuttAVFHGm2RHgNodW7wQU= github.com/tinylib/msgp v1.1.9/go.mod h1:BCXGB54lDD8qUEPmiG0cQQUANC4IUQyB2ItS2UDlO/k= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= diff --git a/server/service/notification.go b/server/service/notification.go index d8014d0..4c8c4b3 100644 --- a/server/service/notification.go +++ b/server/service/notification.go @@ -1,7 +1,7 @@ package service import ( - "github.com/thoas/go-funk" + "slices" "github.com/mattermost/mattermost-plugin-confluence/server/config" "github.com/mattermost/mattermost-plugin-confluence/server/serializer" @@ -41,12 +41,12 @@ func getNotificationChannelIDs(url, spaceKey, pageID, eventType string) []string urlSpaceKeySubscriptionChannelIDs := make([]string, 0) urlPageIDSubscriptionChannelIDs := make([]string, 0) for channelID, events := range urlPageIDSubscriptions { - if funk.Contains(events, eventType) { + if slices.Contains(events, eventType) { urlPageIDSubscriptionChannelIDs = append(urlPageIDSubscriptionChannelIDs, channelID) } } for channelID, events := range urlSpaceKeySubscriptions { - if funk.Contains(events, eventType) { + if slices.Contains(events, eventType) { urlSpaceKeySubscriptionChannelIDs = append(urlSpaceKeySubscriptionChannelIDs, channelID) } } diff --git a/server/util/util.go b/server/util/util.go index 01935ba..f798f30 100644 --- a/server/util/util.go +++ b/server/util/util.go @@ -20,13 +20,6 @@ func GetKeyHash(key string) string { return base64.StdEncoding.EncodeToString(hash.Sum(nil)) } -func Min(a, b int) int { - if a < b { - return a - } - return b -} - func SplitArgs(s string) ([]string, error) { indexes := regexp.MustCompile("\"").FindAllStringIndex(s, -1) if len(indexes)%2 != 0 { @@ -42,7 +35,7 @@ func SplitArgs(s string) ([]string, error) { var args []string for i := 0; i < len(indexes)-1; i++ { start := indexes[i][1] - end := Min(len(s), indexes[i+1][0]) + end := min(len(s), indexes[i+1][0]) if i%2 == 0 { args = append(args, strings.Split(strings.Trim(s[start:end], " "), " ")...)