Skip to content

Commit

Permalink
Remove go-funk dependency (#116)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Schumacher <[email protected]>
  • Loading branch information
mickmister and hanzei authored Dec 3, 2024
1 parent 770aa79 commit 8571cb2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
14 changes: 7 additions & 7 deletions build/pluginctl/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions server/service/notification.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
}
}
Expand Down
9 changes: 1 addition & 8 deletions server/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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], " "), " ")...)
Expand Down

0 comments on commit 8571cb2

Please sign in to comment.