diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go index 829cfb6a14..10ed0ae5c7 100644 --- a/bridge/slack/handlers.go +++ b/bridge/slack/handlers.go @@ -7,7 +7,7 @@ import ( "github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/helper" - "github.com/nlopes/slack" + "github.com/slack-go/slack" ) func (b *Bslack) handleSlack() { diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go index b95ae87898..c970b0d7ca 100644 --- a/bridge/slack/helpers.go +++ b/bridge/slack/helpers.go @@ -7,8 +7,8 @@ import ( "time" "github.com/42wim/matterbridge/bridge/config" - "github.com/nlopes/slack" "github.com/sirupsen/logrus" + "github.com/slack-go/slack" ) // populateReceivedMessage shapes the initial Matterbridge message that we will forward to the diff --git a/bridge/slack/legacy.go b/bridge/slack/legacy.go index 5c2eca20d5..d89d286d5e 100644 --- a/bridge/slack/legacy.go +++ b/bridge/slack/legacy.go @@ -5,7 +5,7 @@ import ( "github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/matterhook" - "github.com/nlopes/slack" + "github.com/slack-go/slack" ) type BLegacy struct { diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 94f1302592..23c856bd46 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -13,8 +13,8 @@ import ( "github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/matterhook" lru "github.com/hashicorp/golang-lru" - "github.com/nlopes/slack" "github.com/rs/xid" + "github.com/slack-go/slack" ) type Bslack struct { diff --git a/bridge/slack/users_channels.go b/bridge/slack/users_channels.go index ce14e5098a..6886414e51 100644 --- a/bridge/slack/users_channels.go +++ b/bridge/slack/users_channels.go @@ -8,8 +8,8 @@ import ( "time" "github.com/42wim/matterbridge/bridge/config" - "github.com/nlopes/slack" "github.com/sirupsen/logrus" + "github.com/slack-go/slack" ) const minimumRefreshInterval = 10 * time.Second diff --git a/go.mod b/go.mod index 2f19f2e121..f437198265 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,6 @@ require ( github.com/mrexodia/wray v0.0.0-20160318003008-78a2c1f284ff // indirect github.com/nelsonken/gomf v0.0.0-20180504123937-a9dd2f9deae9 github.com/nicksnyder/go-i18n v1.4.0 // indirect - github.com/nlopes/slack v0.6.0 github.com/onsi/ginkgo v1.6.0 // indirect github.com/onsi/gomega v1.4.1 // indirect github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c @@ -44,6 +43,7 @@ require ( github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca github.com/shazow/ssh-chat v1.8.2 github.com/sirupsen/logrus v1.4.2 + github.com/slack-go/slack v0.6.3-0.20200228121756-f56d616d5901 github.com/spf13/viper v1.6.1 github.com/stretchr/testify v1.4.0 github.com/technoweenie/multipartstreamer v1.0.1 // indirect @@ -55,8 +55,6 @@ require ( gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect ) -replace github.com/nlopes/slack v0.6.0 => github.com/matterbridge/slack v0.1.1-0.20191208194820-95190f11bfb6 - replace github.com/bwmarrin/discordgo v0.20.2 => github.com/matterbridge/discordgo v0.18.1-0.20200109173909-ed873362fa43 go 1.13 diff --git a/go.sum b/go.sum index 9232baaae2..5b569d1c69 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,8 @@ github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dT github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-telegram-bot-api/telegram-bot-api v4.6.5-0.20181225215658-ec221ba9ea45+incompatible h1:i64CCJcSqkRIkm5OSdZQjZq84/gJsk2zNwHWIRYWlKE= github.com/go-telegram-bot-api/telegram-bot-api v4.6.5-0.20181225215658-ec221ba9ea45+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM= +github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= +github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -132,16 +134,12 @@ github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible/go.mod h1:igE6rUAn3jai2wCdsjFHfhUoekjrFthoEjFObKKwSb4= github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91 h1:KzDEcy8eDbTx881giW8a6llsAck3e2bJvMyKvh1IK+k= github.com/matterbridge/go-xmpp v0.0.0-20180529212104-cd19799fba91/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q= -github.com/matterbridge/gomatrix v0.0.0-20200209221412-326bea8d866e h1:i1wiGiwjRZ1Yy0JbERoDeikLzOnM6tkkQTT20b3Yy1E= -github.com/matterbridge/gomatrix v0.0.0-20200209221412-326bea8d866e/go.mod h1:+jWeaaUtXQbBRdKYWfjW6JDDYiI2XXE+3NnTjW5kg8g= github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6 h1:Kl65VJv38HjYFnnwH+MP6Z8hcJT5UHuSpHVU5vW1HH0= github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6/go.mod h1:+jWeaaUtXQbBRdKYWfjW6JDDYiI2XXE+3NnTjW5kg8g= github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18 h1:fLhwXtWGtfTgZVxHG1lcKjv+re7dRwyyuYFNu69xdho= github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA= github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61 h1:R/MgM/eUyRBQx2FiH6JVmXck8PaAuKfe2M1tWIzW7nE= github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU= -github.com/matterbridge/slack v0.1.1-0.20191208194820-95190f11bfb6 h1:UvXXR9tHYqJUXZVEtiK2qkEWBXfFneicate5kOshVFk= -github.com/matterbridge/slack v0.1.1-0.20191208194820-95190f11bfb6/go.mod h1:2uCJim0Ct2z1Uj+XQq47KCLLC1b/9UTYaZOvDtbZfK4= github.com/mattermost/mattermost-server v5.5.0+incompatible h1:0wcLGgYtd+YImtLDPf2AOfpBHxbU4suATx+6XKw1XbU= github.com/mattermost/mattermost-server v5.5.0+incompatible/go.mod h1:5L6MjAec+XXQwMIt791Ganu45GKsSiM+I0tLR9wUj8Y= github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= @@ -217,6 +215,8 @@ github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 h1:lpEzuenPuO1XNTeikEmvqYFcU37GVLl8SRNblzyvGBE= github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= +github.com/slack-go/slack v0.6.3-0.20200228121756-f56d616d5901 h1:sXIMY2YPYEm5NoGMCrJC50N+8t9W6vbY9qr61zcLEAE= +github.com/slack-go/slack v0.6.3-0.20200228121756-f56d616d5901/go.mod h1:ZUNi+O1Pwr2ch2UOp2AfF+s7QYQgwht2Cd1UTeIYw9A= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go index f513311284..6b036430dd 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -14,7 +14,7 @@ import ( "time" "github.com/gorilla/schema" - "github.com/nlopes/slack" + "github.com/slack-go/slack" ) // OMessage for mattermost incoming webhook. (send to mattermost) diff --git a/vendor/github.com/nlopes/slack/block_unknown.go b/vendor/github.com/nlopes/slack/block_unknown.go deleted file mode 100644 index b5ce1e473c..0000000000 --- a/vendor/github.com/nlopes/slack/block_unknown.go +++ /dev/null @@ -1,14 +0,0 @@ -package slack - -// UnknownBlock represents a block type that is not yet known. This block type exists to prevent Slack from introducing -// new and unknown block types that break this library. -type UnknownBlock struct { - Type MessageBlockType `json:"type"` - BlockID string `json:"block_id,omitempty"` - Elements BlockElements `json:"elements"` -} - -// BlockType returns the type of the block -func (b UnknownBlock) BlockType() MessageBlockType { - return b.Type -} diff --git a/vendor/github.com/nlopes/slack/go.sum b/vendor/github.com/nlopes/slack/go.sum deleted file mode 100644 index 3bb45c1f81..0000000000 --- a/vendor/github.com/nlopes/slack/go.sum +++ /dev/null @@ -1,22 +0,0 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= -github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/nlopes/slack v0.1.0/go.mod h1:jVI4BBK3lSktibKahxBF74txcK2vyvkza1z/+rRnVAM= -github.com/nlopes/slack v0.5.0 h1:NbIae8Kd0NpqaEI3iUrsuS0KbcEDhzhc939jLW5fNm0= -github.com/nlopes/slack v0.5.0/go.mod h1:jVI4BBK3lSktibKahxBF74txcK2vyvkza1z/+rRnVAM= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/victorcoder/slack-test v0.0.0-20190131110821-6f9a569c10af h1:JFxr+No3ZWgCtxnnTWCybnB/z0Iy3qLmdj3u2NV5o48= -github.com/victorcoder/slack-test v0.0.0-20190131110821-6f9a569c10af/go.mod h1:dStM4ShMus8J3hiq66ExbbzGLkwyZ+RQJePwFhWCCvQ= -github.com/victorcoder/slack-test v0.0.0-20190131113129-a43b3bb77f43 h1:wtFekkaAAQibpy3iE4Hhx2Gi9pZAbITOSfVP7GXk5eM= -github.com/victorcoder/slack-test v0.0.0-20190131113129-a43b3bb77f43/go.mod h1:dStM4ShMus8J3hiq66ExbbzGLkwyZ+RQJePwFhWCCvQ= -golang.org/x/net v0.0.0-20180108090419-434ec0c7fe37 h1:BkNcmLtAVeWe9h5k0jt24CQgaG5vb4x/doFbAiEC/Ho= -golang.org/x/net v0.0.0-20180108090419-434ec0c7fe37/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/vendor/github.com/nlopes/slack/.gitignore b/vendor/github.com/slack-go/slack/.gitignore similarity index 100% rename from vendor/github.com/nlopes/slack/.gitignore rename to vendor/github.com/slack-go/slack/.gitignore diff --git a/vendor/github.com/nlopes/slack/.gometalinter.json b/vendor/github.com/slack-go/slack/.gometalinter.json similarity index 100% rename from vendor/github.com/nlopes/slack/.gometalinter.json rename to vendor/github.com/slack-go/slack/.gometalinter.json diff --git a/vendor/github.com/nlopes/slack/.travis.yml b/vendor/github.com/slack-go/slack/.travis.yml similarity index 100% rename from vendor/github.com/nlopes/slack/.travis.yml rename to vendor/github.com/slack-go/slack/.travis.yml diff --git a/vendor/github.com/nlopes/slack/CHANGELOG.md b/vendor/github.com/slack-go/slack/CHANGELOG.md similarity index 100% rename from vendor/github.com/nlopes/slack/CHANGELOG.md rename to vendor/github.com/slack-go/slack/CHANGELOG.md diff --git a/vendor/github.com/nlopes/slack/LICENSE b/vendor/github.com/slack-go/slack/LICENSE similarity index 100% rename from vendor/github.com/nlopes/slack/LICENSE rename to vendor/github.com/slack-go/slack/LICENSE diff --git a/vendor/github.com/slack-go/slack/Makefile b/vendor/github.com/slack-go/slack/Makefile new file mode 100644 index 0000000000..1c64747d78 --- /dev/null +++ b/vendor/github.com/slack-go/slack/Makefile @@ -0,0 +1,36 @@ +.PHONY: help deps fmt lint test test-race test-integration + +help: + @echo "" + @echo "Welcome to slack-go/slack make." + @echo "The following commands are available:" + @echo "" + @echo " make deps : Fetch all dependencies" + @echo " make fmt : Run go fmt to fix any formatting issues" + @echo " make lint : Use go vet to check for linting issues" + @echo " make test : Run all short tests" + @echo " make test-race : Run all tests with race condition checking" + @echo " make test-integration : Run all tests without limiting to short" + @echo "" + @echo " make pr-prep : Run this before making a PR to run fmt, lint and tests" + @echo "" + +deps: + @go mod tidy + +fmt: + @go fmt . + +lint: + @go vet . + +test: + @go test -count=1 -timeout 300s -short . + +test-race: + @go test -count=1 -timeout 300s -short -race . + +test-integration: + @go test -count=1 -timeout 600s . + +pr-prep: fmt lint test-race test-integration diff --git a/vendor/github.com/nlopes/slack/README.md b/vendor/github.com/slack-go/slack/README.md similarity index 63% rename from vendor/github.com/nlopes/slack/README.md rename to vendor/github.com/slack-go/slack/README.md index a5e8e5efa7..eaf077828f 100644 --- a/vendor/github.com/nlopes/slack/README.md +++ b/vendor/github.com/slack-go/slack/README.md @@ -1,5 +1,6 @@ -Slack API in Go [![GoDoc](https://godoc.org/github.com/nlopes/slack?status.svg)](https://godoc.org/github.com/nlopes/slack) [![Build Status](https://travis-ci.org/nlopes/slack.svg)](https://travis-ci.org/nlopes/slack) +Slack API in Go [![GoDoc](https://godoc.org/github.com/slack-go/slack?status.svg)](https://godoc.org/github.com/slack-go/slack) [![Build Status](https://travis-ci.org/slack-go/slack.svg)](https://travis-ci.org/slack-go/slack) =============== +This is the original Slack library for Go created by Norberto Lopez, transferred to a Github organization. [![Join the chat at https://gitter.im/go-slack/Lobby](https://badges.gitter.im/go-slack/Lobby.svg)](https://gitter.im/go-slack/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -12,13 +13,13 @@ a fully managed way. ## Changelog -[CHANGELOG.md](https://github.com/nlopes/slack/blob/master/CHANGELOG.md) is available. Please visit it for updates. +[CHANGELOG.md](https://github.com/slack-go/slack/blob/master/CHANGELOG.md) is available. Please visit it for updates. ## Installing ### *go get* - $ go get -u github.com/nlopes/slack + $ go get -u github.com/slack-go/slack ## Example @@ -28,7 +29,7 @@ a fully managed way. import ( "fmt" - "github.com/nlopes/slack" + "github.com/slack-go/slack" ) func main() { @@ -53,7 +54,7 @@ func main() { import ( "fmt" - "github.com/nlopes/slack" + "github.com/slack-go/slack" ) func main() { @@ -69,12 +70,12 @@ func main() { ## Minimal RTM usage: -See https://github.com/nlopes/slack/blob/master/examples/websocket/websocket.go +See https://github.com/slack-go/slack/blob/master/examples/websocket/websocket.go ## Minimal EventsAPI usage: -See https://github.com/nlopes/slack/blob/master/examples/eventsapi/events.go +See https://github.com/slack-go/slack/blob/master/examples/eventsapi/events.go ## Contributing @@ -82,6 +83,14 @@ See https://github.com/nlopes/slack/blob/master/examples/eventsapi/events.go You are more than welcome to contribute to this project. Fork and make a Pull Request, or create an Issue if you see any problem. +Before making any Pull Request please run the following: + +``` +make pr-prep +``` + +This will check/update code formatting, linting and then run all tests + ## License BSD 2 Clause license diff --git a/vendor/github.com/nlopes/slack/TODO.txt b/vendor/github.com/slack-go/slack/TODO.txt similarity index 100% rename from vendor/github.com/nlopes/slack/TODO.txt rename to vendor/github.com/slack-go/slack/TODO.txt diff --git a/vendor/github.com/nlopes/slack/admin.go b/vendor/github.com/slack-go/slack/admin.go similarity index 100% rename from vendor/github.com/nlopes/slack/admin.go rename to vendor/github.com/slack-go/slack/admin.go diff --git a/vendor/github.com/nlopes/slack/attachments.go b/vendor/github.com/slack-go/slack/attachments.go similarity index 98% rename from vendor/github.com/nlopes/slack/attachments.go rename to vendor/github.com/slack-go/slack/attachments.go index af62fb6766..b5b79f9fed 100644 --- a/vendor/github.com/nlopes/slack/attachments.go +++ b/vendor/github.com/slack-go/slack/attachments.go @@ -61,7 +61,7 @@ type ConfirmationField struct { // Attachment contains all the information for an attachment type Attachment struct { Color string `json:"color,omitempty"` - Fallback string `json:"fallback"` + Fallback string `json:"fallback,omitempty"` CallbackID string `json:"callback_id,omitempty"` ID int `json:"id,omitempty"` @@ -84,7 +84,7 @@ type Attachment struct { Actions []AttachmentAction `json:"actions,omitempty"` MarkdownIn []string `json:"mrkdwn_in,omitempty"` - Blocks []Block `json:"blocks,omitempty"` + Blocks Blocks `json:"blocks,omitempty"` Footer string `json:"footer,omitempty"` FooterIcon string `json:"footer_icon,omitempty"` diff --git a/vendor/github.com/nlopes/slack/auth.go b/vendor/github.com/slack-go/slack/auth.go similarity index 100% rename from vendor/github.com/nlopes/slack/auth.go rename to vendor/github.com/slack-go/slack/auth.go diff --git a/vendor/github.com/nlopes/slack/backoff.go b/vendor/github.com/slack-go/slack/backoff.go similarity index 100% rename from vendor/github.com/nlopes/slack/backoff.go rename to vendor/github.com/slack-go/slack/backoff.go diff --git a/vendor/github.com/nlopes/slack/block.go b/vendor/github.com/slack-go/slack/block.go similarity index 98% rename from vendor/github.com/nlopes/slack/block.go rename to vendor/github.com/slack-go/slack/block.go index 502b11353a..32ff260cc3 100644 --- a/vendor/github.com/nlopes/slack/block.go +++ b/vendor/github.com/slack-go/slack/block.go @@ -14,6 +14,7 @@ const ( MBTImage MessageBlockType = "image" MBTAction MessageBlockType = "actions" MBTContext MessageBlockType = "context" + MBTInput MessageBlockType = "input" ) // Block defines an interface all block types should implement diff --git a/vendor/github.com/nlopes/slack/block_action.go b/vendor/github.com/slack-go/slack/block_action.go similarity index 100% rename from vendor/github.com/nlopes/slack/block_action.go rename to vendor/github.com/slack-go/slack/block_action.go diff --git a/vendor/github.com/nlopes/slack/block_context.go b/vendor/github.com/slack-go/slack/block_context.go similarity index 100% rename from vendor/github.com/nlopes/slack/block_context.go rename to vendor/github.com/slack-go/slack/block_context.go diff --git a/vendor/github.com/nlopes/slack/block_conv.go b/vendor/github.com/slack-go/slack/block_conv.go similarity index 84% rename from vendor/github.com/nlopes/slack/block_conv.go rename to vendor/github.com/slack-go/slack/block_conv.go index 9f5d52c717..ce48ce1911 100644 --- a/vendor/github.com/nlopes/slack/block_conv.go +++ b/vendor/github.com/slack-go/slack/block_conv.go @@ -58,13 +58,18 @@ func (b *Blocks) UnmarshalJSON(data []byte) error { block = &DividerBlock{} case "image": block = &ImageBlock{} + case "input": + block = &InputBlock{} case "section": block = &SectionBlock{} case "rich_text": // for now ignore the (complex) content of rich_text blocks until we can fully support it continue + case "file": + // for now ignore the file blocks until we can fully support it + continue default: - block = &UnknownBlock{} + return errors.New("unsupported block type") } err = json.Unmarshal(r, block) @@ -79,6 +84,46 @@ func (b *Blocks) UnmarshalJSON(data []byte) error { return nil } +// UnmarshalJSON implements the Unmarshaller interface for InputBlock, so that any JSON +// unmarshalling is delegated and proper type determination can be made before unmarshal +func (b *InputBlock) UnmarshalJSON(data []byte) error { + type alias InputBlock + a := struct { + Element json.RawMessage `json:"element"` + *alias + }{ + alias: (*alias)(b), + } + + if err := json.Unmarshal(data, &a); err != nil { + return err + } + + s := sumtype{} + if err := json.Unmarshal(a.Element, &s); err != nil { + return nil + } + + var e BlockElement + switch s.TypeVal { + case "datepicker": + e = &DatePickerBlockElement{} + case "plain_text_input": + e = &PlainTextInputBlockElement{} + case "static_select", "external_select", "users_select", "conversations_select", "channels_select": + e = &SelectBlockElement{} + default: + return errors.New("unsupported block element type") + } + + if err := json.Unmarshal(a.Element, e); err != nil { + return err + } + b.Element = e + + return nil +} + // MarshalJSON implements the Marshaller interface for BlockElements so that any JSON // marshalling is delegated and proper type determination can be made before marshal func (b *BlockElements) MarshalJSON() ([]byte, error) { @@ -127,10 +172,12 @@ func (b *BlockElements) UnmarshalJSON(data []byte) error { blockElement = &OverflowBlockElement{} case "datepicker": blockElement = &DatePickerBlockElement{} + case "plain_text_input": + blockElement = &PlainTextInputBlockElement{} case "static_select", "external_select", "users_select", "conversations_select", "channels_select": blockElement = &SelectBlockElement{} default: - blockElement = &UnknownBlockElement{} + return errors.New("unsupported block element type") } err = json.Unmarshal(r, blockElement) diff --git a/vendor/github.com/nlopes/slack/block_divider.go b/vendor/github.com/slack-go/slack/block_divider.go similarity index 100% rename from vendor/github.com/nlopes/slack/block_divider.go rename to vendor/github.com/slack-go/slack/block_divider.go diff --git a/vendor/github.com/nlopes/slack/block_element.go b/vendor/github.com/slack-go/slack/block_element.go similarity index 86% rename from vendor/github.com/nlopes/slack/block_element.go rename to vendor/github.com/slack-go/slack/block_element.go index 5b1b4b0198..e0a7bf96d2 100644 --- a/vendor/github.com/nlopes/slack/block_element.go +++ b/vendor/github.com/slack-go/slack/block_element.go @@ -3,10 +3,11 @@ package slack // https://api.slack.com/reference/messaging/block-elements const ( - METImage MessageElementType = "image" - METButton MessageElementType = "button" - METOverflow MessageElementType = "overflow" - METDatepicker MessageElementType = "datepicker" + METImage MessageElementType = "image" + METButton MessageElementType = "button" + METOverflow MessageElementType = "overflow" + METDatepicker MessageElementType = "datepicker" + METPlainTextInput MessageElementType = "plain_text_input" MixedElementImage MixedElementType = "mixed_image" MixedElementText MixedElementType = "mixed_text" @@ -62,20 +63,6 @@ type BlockElements struct { ElementSet []BlockElement `json:"elements,omitempty"` } -// UnknownBlockElement any block element that this library does not directly support. -// See the "Rich Elements" section at the following URL: -// https://api.slack.com/changelog/2019-09-what-they-see-is-what-you-get-and-more-and-less -// New block element types may be introduced by Slack at any time; this is a catch-all for any such block elements. -type UnknownBlockElement struct { - Type MessageElementType `json:"type"` - Elements BlockElements -} - -// ElementType returns the type of the Element -func (s UnknownBlockElement) ElementType() MessageElementType { - return s.Type -} - // ImageBlockElement An element to insert an image - this element can be used // in section and context blocks only. If you want a block with only an image // in it, you're looking for the image block. @@ -250,3 +237,31 @@ func NewDatePickerBlockElement(actionID string) *DatePickerBlockElement { ActionID: actionID, } } + +// PlainTextInputBlockElement creates a field where a user can enter freeform data. +// Plain-text input elements are currently only available in modals. +// +// More Information: https://api.slack.com/reference/messaging/block-elements#input +type PlainTextInputBlockElement struct { + Type MessageElementType `json:"type"` + ActionID string `json:"action_id"` + Placeholder *TextBlockObject `json:"placeholder,omitempty"` + InitialValue string `json:"initial_value,omitempty"` + Multiline bool `json:"multiline,omitempty"` + MinLength int `json:"min_length,omitempty"` + MaxLength int `json:"max_length,omitempty"` +} + +// ElementType returns the type of the Element +func (s PlainTextInputBlockElement) ElementType() MessageElementType { + return s.Type +} + +// NewPlainTextInputBlockElement returns an instance of a plain-text input element +func NewPlainTextInputBlockElement(placeholder *TextBlockObject, actionID string) *PlainTextInputBlockElement { + return &PlainTextInputBlockElement{ + Type: METPlainTextInput, + ActionID: actionID, + Placeholder: placeholder, + } +} diff --git a/vendor/github.com/nlopes/slack/block_image.go b/vendor/github.com/slack-go/slack/block_image.go similarity index 100% rename from vendor/github.com/nlopes/slack/block_image.go rename to vendor/github.com/slack-go/slack/block_image.go diff --git a/vendor/github.com/slack-go/slack/block_input.go b/vendor/github.com/slack-go/slack/block_input.go new file mode 100644 index 0000000000..9d082038a6 --- /dev/null +++ b/vendor/github.com/slack-go/slack/block_input.go @@ -0,0 +1,30 @@ +package slack + +// InputBlock defines data that is used to collect information from users - +// it can hold a plain-text input element, a select menu element, +// a multi-select menu element, or a datepicker. +// +// More Information: https://api.slack.com/reference/messaging/blocks#input +type InputBlock struct { + Type MessageBlockType `json:"type"` + BlockID string `json:"block_id,omitempty"` + Label *TextBlockObject `json:"label"` + Element BlockElement `json:"element"` + Hint *TextBlockObject `json:"hint,omitempty"` + Optional bool `json:"optional,omitempty"` +} + +// BlockType returns the type of the block +func (s InputBlock) BlockType() MessageBlockType { + return s.Type +} + +// NewInputBlock returns a new instance of an Input Block +func NewInputBlock(blockID string, label *TextBlockObject, element BlockElement) *InputBlock { + return &InputBlock{ + Type: MBTInput, + BlockID: blockID, + Label: label, + Element: element, + } +} diff --git a/vendor/github.com/nlopes/slack/block_object.go b/vendor/github.com/slack-go/slack/block_object.go similarity index 100% rename from vendor/github.com/nlopes/slack/block_object.go rename to vendor/github.com/slack-go/slack/block_object.go diff --git a/vendor/github.com/nlopes/slack/block_section.go b/vendor/github.com/slack-go/slack/block_section.go similarity index 100% rename from vendor/github.com/nlopes/slack/block_section.go rename to vendor/github.com/slack-go/slack/block_section.go diff --git a/vendor/github.com/nlopes/slack/bots.go b/vendor/github.com/slack-go/slack/bots.go similarity index 100% rename from vendor/github.com/nlopes/slack/bots.go rename to vendor/github.com/slack-go/slack/bots.go diff --git a/vendor/github.com/nlopes/slack/channels.go b/vendor/github.com/slack-go/slack/channels.go similarity index 100% rename from vendor/github.com/nlopes/slack/channels.go rename to vendor/github.com/slack-go/slack/channels.go diff --git a/vendor/github.com/nlopes/slack/chat.go b/vendor/github.com/slack-go/slack/chat.go similarity index 99% rename from vendor/github.com/nlopes/slack/chat.go rename to vendor/github.com/slack-go/slack/chat.go index c074484205..b54f8d6de8 100644 --- a/vendor/github.com/nlopes/slack/chat.go +++ b/vendor/github.com/slack-go/slack/chat.go @@ -6,7 +6,7 @@ import ( "net/http" "net/url" - "github.com/nlopes/slack/slackutilsx" + "github.com/slack-go/slack/slackutilsx" ) const ( @@ -347,11 +347,11 @@ func MsgOptionUnfurl(timestamp string, unfurls map[string]Attachment) MsgOption } // MsgOptionResponseURL supplies a url to use as the endpoint. -func MsgOptionResponseURL(url string, rt string) MsgOption { +func MsgOptionResponseURL(url string, responseType string) MsgOption { return func(config *sendConfig) error { config.mode = chatResponse config.endpoint = url - config.responseType = rt + config.responseType = responseType config.values.Del("ts") return nil } diff --git a/vendor/github.com/nlopes/slack/comment.go b/vendor/github.com/slack-go/slack/comment.go similarity index 100% rename from vendor/github.com/nlopes/slack/comment.go rename to vendor/github.com/slack-go/slack/comment.go diff --git a/vendor/github.com/nlopes/slack/conversation.go b/vendor/github.com/slack-go/slack/conversation.go similarity index 100% rename from vendor/github.com/nlopes/slack/conversation.go rename to vendor/github.com/slack-go/slack/conversation.go diff --git a/vendor/github.com/nlopes/slack/dialog.go b/vendor/github.com/slack-go/slack/dialog.go similarity index 100% rename from vendor/github.com/nlopes/slack/dialog.go rename to vendor/github.com/slack-go/slack/dialog.go diff --git a/vendor/github.com/nlopes/slack/dialog_select.go b/vendor/github.com/slack-go/slack/dialog_select.go similarity index 100% rename from vendor/github.com/nlopes/slack/dialog_select.go rename to vendor/github.com/slack-go/slack/dialog_select.go diff --git a/vendor/github.com/nlopes/slack/dialog_text.go b/vendor/github.com/slack-go/slack/dialog_text.go similarity index 100% rename from vendor/github.com/nlopes/slack/dialog_text.go rename to vendor/github.com/slack-go/slack/dialog_text.go diff --git a/vendor/github.com/nlopes/slack/dnd.go b/vendor/github.com/slack-go/slack/dnd.go similarity index 100% rename from vendor/github.com/nlopes/slack/dnd.go rename to vendor/github.com/slack-go/slack/dnd.go diff --git a/vendor/github.com/nlopes/slack/emoji.go b/vendor/github.com/slack-go/slack/emoji.go similarity index 100% rename from vendor/github.com/nlopes/slack/emoji.go rename to vendor/github.com/slack-go/slack/emoji.go diff --git a/vendor/github.com/nlopes/slack/errors.go b/vendor/github.com/slack-go/slack/errors.go similarity index 93% rename from vendor/github.com/nlopes/slack/errors.go rename to vendor/github.com/slack-go/slack/errors.go index b31e2caf54..a1dfec25f2 100644 --- a/vendor/github.com/nlopes/slack/errors.go +++ b/vendor/github.com/slack-go/slack/errors.go @@ -1,6 +1,6 @@ package slack -import "github.com/nlopes/slack/internal/errorsx" +import "github.com/slack-go/slack/internal/errorsx" // Errors returned by various methods. const ( diff --git a/vendor/github.com/nlopes/slack/files.go b/vendor/github.com/slack-go/slack/files.go similarity index 100% rename from vendor/github.com/nlopes/slack/files.go rename to vendor/github.com/slack-go/slack/files.go diff --git a/vendor/github.com/nlopes/slack/go.mod b/vendor/github.com/slack-go/slack/go.mod similarity index 74% rename from vendor/github.com/nlopes/slack/go.mod rename to vendor/github.com/slack-go/slack/go.mod index a97bf38141..cbe11808a5 100644 --- a/vendor/github.com/nlopes/slack/go.mod +++ b/vendor/github.com/slack-go/slack/go.mod @@ -1,7 +1,10 @@ -module github.com/matterbridge/slack +module github.com/slack-go/slack + +go 1.13 require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-test/deep v1.0.4 github.com/gorilla/websocket v1.2.0 github.com/pkg/errors v0.8.0 github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/vendor/github.com/slack-go/slack/go.sum b/vendor/github.com/slack-go/slack/go.sum new file mode 100644 index 0000000000..7a0ae46ec1 --- /dev/null +++ b/vendor/github.com/slack-go/slack/go.sum @@ -0,0 +1,12 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= +github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= +github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/vendor/github.com/nlopes/slack/groups.go b/vendor/github.com/slack-go/slack/groups.go similarity index 100% rename from vendor/github.com/nlopes/slack/groups.go rename to vendor/github.com/slack-go/slack/groups.go diff --git a/vendor/github.com/nlopes/slack/history.go b/vendor/github.com/slack-go/slack/history.go similarity index 100% rename from vendor/github.com/nlopes/slack/history.go rename to vendor/github.com/slack-go/slack/history.go diff --git a/vendor/github.com/nlopes/slack/im.go b/vendor/github.com/slack-go/slack/im.go similarity index 100% rename from vendor/github.com/nlopes/slack/im.go rename to vendor/github.com/slack-go/slack/im.go diff --git a/vendor/github.com/nlopes/slack/info.go b/vendor/github.com/slack-go/slack/info.go similarity index 100% rename from vendor/github.com/nlopes/slack/info.go rename to vendor/github.com/slack-go/slack/info.go diff --git a/vendor/github.com/nlopes/slack/interactions.go b/vendor/github.com/slack-go/slack/interactions.go similarity index 98% rename from vendor/github.com/nlopes/slack/interactions.go rename to vendor/github.com/slack-go/slack/interactions.go index de1ed3700e..26a8b6db6f 100644 --- a/vendor/github.com/nlopes/slack/interactions.go +++ b/vendor/github.com/slack-go/slack/interactions.go @@ -44,6 +44,7 @@ type InteractionCallback struct { MessageTs string `json:"message_ts"` AttachmentID string `json:"attachment_id"` ActionCallback ActionCallbacks `json:"actions"` + APIAppID string `json:"api_app_id"` DialogSubmissionCallback } diff --git a/vendor/github.com/nlopes/slack/internal/errorsx/errorsx.go b/vendor/github.com/slack-go/slack/internal/errorsx/errorsx.go similarity index 100% rename from vendor/github.com/nlopes/slack/internal/errorsx/errorsx.go rename to vendor/github.com/slack-go/slack/internal/errorsx/errorsx.go diff --git a/vendor/github.com/nlopes/slack/internal/timex/timex.go b/vendor/github.com/slack-go/slack/internal/timex/timex.go similarity index 100% rename from vendor/github.com/nlopes/slack/internal/timex/timex.go rename to vendor/github.com/slack-go/slack/internal/timex/timex.go diff --git a/vendor/github.com/nlopes/slack/item.go b/vendor/github.com/slack-go/slack/item.go similarity index 100% rename from vendor/github.com/nlopes/slack/item.go rename to vendor/github.com/slack-go/slack/item.go diff --git a/vendor/github.com/nlopes/slack/logger.go b/vendor/github.com/slack-go/slack/logger.go similarity index 100% rename from vendor/github.com/nlopes/slack/logger.go rename to vendor/github.com/slack-go/slack/logger.go diff --git a/vendor/github.com/nlopes/slack/messageID.go b/vendor/github.com/slack-go/slack/messageID.go similarity index 100% rename from vendor/github.com/nlopes/slack/messageID.go rename to vendor/github.com/slack-go/slack/messageID.go diff --git a/vendor/github.com/nlopes/slack/messages.go b/vendor/github.com/slack-go/slack/messages.go similarity index 98% rename from vendor/github.com/nlopes/slack/messages.go rename to vendor/github.com/slack-go/slack/messages.go index f67d99a769..f2f5b145e5 100644 --- a/vendor/github.com/nlopes/slack/messages.go +++ b/vendor/github.com/slack-go/slack/messages.go @@ -15,13 +15,14 @@ type OutgoingMessage struct { // Message is an auxiliary type to allow us to have a message containing sub messages type Message struct { Msg - SubMessage *Msg `json:"message,omitempty"` + SubMessage *Msg `json:"message,omitempty"` PreviousMessage *Msg `json:"previous_message,omitempty"` } // Msg contains information about a slack message type Msg struct { // Basic Message + ClientMsgID string `json:"client_msg_id"` Type string `json:"type,omitempty"` Channel string `json:"channel,omitempty"` User string `json:"user,omitempty"` diff --git a/vendor/github.com/nlopes/slack/misc.go b/vendor/github.com/slack-go/slack/misc.go similarity index 100% rename from vendor/github.com/nlopes/slack/misc.go rename to vendor/github.com/slack-go/slack/misc.go diff --git a/vendor/github.com/nlopes/slack/oauth.go b/vendor/github.com/slack-go/slack/oauth.go similarity index 100% rename from vendor/github.com/nlopes/slack/oauth.go rename to vendor/github.com/slack-go/slack/oauth.go diff --git a/vendor/github.com/nlopes/slack/pagination.go b/vendor/github.com/slack-go/slack/pagination.go similarity index 100% rename from vendor/github.com/nlopes/slack/pagination.go rename to vendor/github.com/slack-go/slack/pagination.go diff --git a/vendor/github.com/nlopes/slack/pins.go b/vendor/github.com/slack-go/slack/pins.go similarity index 100% rename from vendor/github.com/nlopes/slack/pins.go rename to vendor/github.com/slack-go/slack/pins.go diff --git a/vendor/github.com/nlopes/slack/reactions.go b/vendor/github.com/slack-go/slack/reactions.go similarity index 100% rename from vendor/github.com/nlopes/slack/reactions.go rename to vendor/github.com/slack-go/slack/reactions.go diff --git a/vendor/github.com/nlopes/slack/reminders.go b/vendor/github.com/slack-go/slack/reminders.go similarity index 100% rename from vendor/github.com/nlopes/slack/reminders.go rename to vendor/github.com/slack-go/slack/reminders.go diff --git a/vendor/github.com/nlopes/slack/rtm.go b/vendor/github.com/slack-go/slack/rtm.go similarity index 100% rename from vendor/github.com/nlopes/slack/rtm.go rename to vendor/github.com/slack-go/slack/rtm.go diff --git a/vendor/github.com/nlopes/slack/search.go b/vendor/github.com/slack-go/slack/search.go similarity index 100% rename from vendor/github.com/nlopes/slack/search.go rename to vendor/github.com/slack-go/slack/search.go diff --git a/vendor/github.com/nlopes/slack/security.go b/vendor/github.com/slack-go/slack/security.go similarity index 100% rename from vendor/github.com/nlopes/slack/security.go rename to vendor/github.com/slack-go/slack/security.go diff --git a/vendor/github.com/nlopes/slack/slack.go b/vendor/github.com/slack-go/slack/slack.go similarity index 97% rename from vendor/github.com/nlopes/slack/slack.go rename to vendor/github.com/slack-go/slack/slack.go index 9423052647..d342a3e86e 100644 --- a/vendor/github.com/nlopes/slack/slack.go +++ b/vendor/github.com/slack-go/slack/slack.go @@ -96,7 +96,7 @@ func New(token string, options ...Option) *Client { token: token, endpoint: APIURL, httpclient: &http.Client{}, - log: log.New(os.Stderr, "nlopes/slack", log.LstdFlags|log.Lshortfile), + log: log.New(os.Stderr, "slack-go/slack", log.LstdFlags|log.Lshortfile), } for _, opt := range options { diff --git a/vendor/github.com/nlopes/slack/slackutilsx/slackutilsx.go b/vendor/github.com/slack-go/slack/slackutilsx/slackutilsx.go similarity index 100% rename from vendor/github.com/nlopes/slack/slackutilsx/slackutilsx.go rename to vendor/github.com/slack-go/slack/slackutilsx/slackutilsx.go diff --git a/vendor/github.com/nlopes/slack/slash.go b/vendor/github.com/slack-go/slack/slash.go similarity index 100% rename from vendor/github.com/nlopes/slack/slash.go rename to vendor/github.com/slack-go/slack/slash.go diff --git a/vendor/github.com/nlopes/slack/stars.go b/vendor/github.com/slack-go/slack/stars.go similarity index 100% rename from vendor/github.com/nlopes/slack/stars.go rename to vendor/github.com/slack-go/slack/stars.go diff --git a/vendor/github.com/nlopes/slack/team.go b/vendor/github.com/slack-go/slack/team.go similarity index 100% rename from vendor/github.com/nlopes/slack/team.go rename to vendor/github.com/slack-go/slack/team.go diff --git a/vendor/github.com/nlopes/slack/usergroups.go b/vendor/github.com/slack-go/slack/usergroups.go similarity index 99% rename from vendor/github.com/nlopes/slack/usergroups.go rename to vendor/github.com/slack-go/slack/usergroups.go index f3206591d1..9417f81774 100644 --- a/vendor/github.com/nlopes/slack/usergroups.go +++ b/vendor/github.com/slack-go/slack/usergroups.go @@ -206,7 +206,7 @@ func (api *Client) UpdateUserGroupContext(ctx context.Context, userGroup UserGro if userGroup.Description != "" { values["description"] = []string{userGroup.Description} } - + if len(userGroup.Prefs.Channels) > 0 { values["channels"] = []string{strings.Join(userGroup.Prefs.Channels, ",")} } diff --git a/vendor/github.com/nlopes/slack/users.go b/vendor/github.com/slack-go/slack/users.go similarity index 99% rename from vendor/github.com/nlopes/slack/users.go rename to vendor/github.com/slack-go/slack/users.go index 4da8e4cecf..6001e0fa23 100644 --- a/vendor/github.com/nlopes/slack/users.go +++ b/vendor/github.com/slack-go/slack/users.go @@ -44,14 +44,14 @@ type UserProfile struct { // UserProfileCustomFields represents user profile's custom fields. // Slack API's response data type is inconsistent so we use the struct. // For detail, please see below. -// https://github.com/nlopes/slack/pull/298#discussion_r185159233 +// https://github.com/slack-go/slack/pull/298#discussion_r185159233 type UserProfileCustomFields struct { fields map[string]UserProfileCustomField } // UnmarshalJSON is the implementation of the json.Unmarshaler interface. func (fields *UserProfileCustomFields) UnmarshalJSON(b []byte) error { - // https://github.com/nlopes/slack/pull/298#discussion_r185159233 + // https://github.com/slack-go/slack/pull/298#discussion_r185159233 if string(b) == "[]" { return nil } diff --git a/vendor/github.com/slack-go/slack/views.go b/vendor/github.com/slack-go/slack/views.go new file mode 100644 index 0000000000..afe391bf12 --- /dev/null +++ b/vendor/github.com/slack-go/slack/views.go @@ -0,0 +1,221 @@ +package slack + +import ( + "context" + "encoding/json" +) + +const ( + VTModal ViewType = "modal" + VTHomeTab ViewType = "home" +) + +type ViewType string + +type View struct { + SlackResponse + ID string `json:"id"` + TeamID string `json:"team_id"` + Type ViewType `json:"type"` + Title *TextBlockObject `json:"title"` + Close *TextBlockObject `json:"close"` + Submit *TextBlockObject `json:"submit"` + Blocks Blocks `json:"blocks"` + PrivateMetadata string `json:"private_metadata"` + CallbackID string `json:"callback_id"` + State interface{} `json:"state"` + Hash string `json:"hash"` + ClearOnClose bool `json:"clear_on_close"` + NotifyOnClose bool `json:"notify_on_close"` + RootViewID string `json:"root_view_id"` + PreviousViewID string `json:"previous_view_id"` + AppID string `json:"app_id"` + ExternalID string `json:"external_id"` + BotID string `json:"bot_id"` +} + +type ModalViewRequest struct { + Type ViewType `json:"type"` + Title *TextBlockObject `json:"title"` + Blocks Blocks `json:"blocks"` + Close *TextBlockObject `json:"close"` + Submit *TextBlockObject `json:"submit"` + PrivateMetadata string `json:"private_metadata"` + CallbackID string `json:"callback_id"` + ClearOnClose bool `json:"clear_on_close"` + NotifyOnClose bool `json:"notify_on_close"` + ExternalID string `json:"external_id"` +} + +func (v *ModalViewRequest) ViewType() ViewType { + return v.Type +} + +type HomeTabViewRequest struct { + Type ViewType `json:"type"` + Blocks Blocks `json:"blocks"` + PrivateMetadata string `json:"private_metadata"` + CallbackID string `json:"callback_id"` + ExternalID string `json:"external_id"` +} + +func (v *HomeTabViewRequest) ViewType() ViewType { + return v.Type +} + +type openViewRequest struct { + TriggerID string `json:"trigger_id"` + View ModalViewRequest `json:"view"` +} + +type publishViewRequest struct { + UserID string `json:"user_id"` + View HomeTabViewRequest `json:"view"` + Hash string `json:"hash"` +} + +type pushViewRequest struct { + TriggerID string `json:"trigger_id"` + View ModalViewRequest `json:"view"` +} + +type updateViewRequest struct { + View ModalViewRequest `json:"view"` + ExternalID string `json:"external_id"` + Hash string `json:"hash"` + ViewID string `json:"view_id"` +} + +type ViewResponse struct { + SlackResponse + View `json:"view"` +} + +// OpenView opens a view for a user. +func (api *Client) OpenView(triggerID string, view ModalViewRequest) (*ViewResponse, error) { + return api.OpenViewContext(context.Background(), triggerID, view) +} + +// OpenViewContext opens a view for a user with a custom context. +func (api *Client) OpenViewContext( + ctx context.Context, + triggerID string, + view ModalViewRequest, +) (*ViewResponse, error) { + if triggerID == "" { + return nil, ErrParametersMissing + } + req := openViewRequest{ + TriggerID: triggerID, + View: view, + } + encoded, err := json.Marshal(req) + if err != nil { + return nil, err + } + endpoint := api.endpoint + "views.open" + resp := &ViewResponse{} + err = postJSON(ctx, api.httpclient, endpoint, api.token, encoded, resp, api) + if err != nil { + return nil, err + } + return resp, resp.Err() +} + +// PublishView publishes a static view for a user. +func (api *Client) PublishView(userID string, view HomeTabViewRequest, hash string) (*ViewResponse, error) { + return api.PublishViewContext(context.Background(), userID, view, hash) +} + +// PublishViewContext publishes a static view for a user with a custom context. +func (api *Client) PublishViewContext( + ctx context.Context, + userID string, + view HomeTabViewRequest, + hash string, +) (*ViewResponse, error) { + if userID == "" { + return nil, ErrParametersMissing + } + req := publishViewRequest{ + UserID: userID, + View: view, + Hash: hash, + } + encoded, err := json.Marshal(req) + if err != nil { + return nil, err + } + endpoint := api.endpoint + "views.publish" + resp := &ViewResponse{} + err = postJSON(ctx, api.httpclient, endpoint, api.token, encoded, resp, api) + if err != nil { + return nil, err + } + return resp, resp.Err() +} + +// PushView pushes a view onto the stack of a root view. +func (api *Client) PushView(triggerID string, view ModalViewRequest) (*ViewResponse, error) { + return api.PushViewContext(context.Background(), triggerID, view) +} + +// PublishViewContext pushes a view onto the stack of a root view with a custom context. +func (api *Client) PushViewContext( + ctx context.Context, + triggerID string, + view ModalViewRequest, +) (*ViewResponse, error) { + if triggerID == "" { + return nil, ErrParametersMissing + } + req := pushViewRequest{ + TriggerID: triggerID, + View: view, + } + encoded, err := json.Marshal(req) + if err != nil { + return nil, err + } + endpoint := api.endpoint + "views.push" + resp := &ViewResponse{} + err = postJSON(ctx, api.httpclient, endpoint, api.token, encoded, resp, api) + if err != nil { + return nil, err + } + return resp, resp.Err() +} + +// UpdateView updates an existing view. +func (api *Client) UpdateView(view ModalViewRequest, externalID, hash, viewID string) (*ViewResponse, error) { + return api.UpdateViewContext(context.Background(), view, externalID, hash, viewID) +} + +// UpdateViewContext updates an existing view with a custom context. +func (api *Client) UpdateViewContext( + ctx context.Context, + view ModalViewRequest, + externalID, hash, + viewID string, +) (*ViewResponse, error) { + if externalID == "" && viewID == "" { + return nil, ErrParametersMissing + } + req := updateViewRequest{ + View: view, + ExternalID: externalID, + Hash: hash, + ViewID: viewID, + } + encoded, err := json.Marshal(req) + if err != nil { + return nil, err + } + endpoint := api.endpoint + "views.update" + resp := &ViewResponse{} + err = postJSON(ctx, api.httpclient, endpoint, api.token, encoded, resp, api) + if err != nil { + return nil, err + } + return resp, resp.Err() +} diff --git a/vendor/github.com/nlopes/slack/webhooks.go b/vendor/github.com/slack-go/slack/webhooks.go similarity index 62% rename from vendor/github.com/nlopes/slack/webhooks.go rename to vendor/github.com/slack-go/slack/webhooks.go index 14e1b8dd98..1016cb4fb0 100644 --- a/vendor/github.com/nlopes/slack/webhooks.go +++ b/vendor/github.com/slack-go/slack/webhooks.go @@ -1,11 +1,8 @@ package slack import ( - "bytes" - "encoding/json" + "context" "net/http" - - "github.com/pkg/errors" ) type WebhookMessage struct { @@ -20,21 +17,13 @@ type WebhookMessage struct { } func PostWebhook(url string, msg *WebhookMessage) error { - return PostWebhookCustomHTTP(url, http.DefaultClient, msg) + return PostWebhookCustomHTTPContext(context.Background(), url, http.DefaultClient, msg) } -func PostWebhookCustomHTTP(url string, httpClient *http.Client, msg *WebhookMessage) error { - raw, err := json.Marshal(msg) - - if err != nil { - return errors.Wrap(err, "marshal failed") - } - - response, err := httpClient.Post(url, "application/json", bytes.NewReader(raw)) - - if err != nil { - return errors.Wrap(err, "failed to post webhook") - } +func PostWebhookContext(ctx context.Context, url string, msg *WebhookMessage) error { + return PostWebhookCustomHTTPContext(ctx, url, http.DefaultClient, msg) +} - return checkStatusCode(response, discard{}) +func PostWebhookCustomHTTP(url string, httpClient *http.Client, msg *WebhookMessage) error { + return PostWebhookCustomHTTPContext(context.Background(), url, httpClient, msg) } diff --git a/vendor/github.com/slack-go/slack/webhooks_go112.go b/vendor/github.com/slack-go/slack/webhooks_go112.go new file mode 100644 index 0000000000..4e0db0e417 --- /dev/null +++ b/vendor/github.com/slack-go/slack/webhooks_go112.go @@ -0,0 +1,34 @@ +// +build !go1.13 + +package slack + +import ( + "bytes" + "context" + "encoding/json" + "net/http" + + "github.com/pkg/errors" +) + +func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *http.Client, msg *WebhookMessage) error { + raw, err := json.Marshal(msg) + if err != nil { + return errors.Wrap(err, "marshal failed") + } + + req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(raw)) + if err != nil { + return errors.Wrap(err, "failed new request") + } + req = req.WithContext(ctx) + req.Header.Set("Content-Type", "application/json") + + resp, err := httpClient.Do(req) + if err != nil { + return errors.Wrap(err, "failed to post webhook") + } + defer resp.Body.Close() + + return checkStatusCode(resp, discard{}) +} diff --git a/vendor/github.com/slack-go/slack/webhooks_go113.go b/vendor/github.com/slack-go/slack/webhooks_go113.go new file mode 100644 index 0000000000..99c243f595 --- /dev/null +++ b/vendor/github.com/slack-go/slack/webhooks_go113.go @@ -0,0 +1,33 @@ +// +build go1.13 + +package slack + +import ( + "bytes" + "context" + "encoding/json" + "net/http" + + "github.com/pkg/errors" +) + +func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *http.Client, msg *WebhookMessage) error { + raw, err := json.Marshal(msg) + if err != nil { + return errors.Wrap(err, "marshal failed") + } + + req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(raw)) + if err != nil { + return errors.Wrap(err, "failed new request") + } + req.Header.Set("Content-Type", "application/json") + + resp, err := httpClient.Do(req) + if err != nil { + return errors.Wrap(err, "failed to post webhook") + } + defer resp.Body.Close() + + return checkStatusCode(resp, discard{}) +} diff --git a/vendor/github.com/nlopes/slack/websocket.go b/vendor/github.com/slack-go/slack/websocket.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket.go rename to vendor/github.com/slack-go/slack/websocket.go diff --git a/vendor/github.com/nlopes/slack/websocket_channels.go b/vendor/github.com/slack-go/slack/websocket_channels.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_channels.go rename to vendor/github.com/slack-go/slack/websocket_channels.go diff --git a/vendor/github.com/nlopes/slack/websocket_desktop_notification.go b/vendor/github.com/slack-go/slack/websocket_desktop_notification.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_desktop_notification.go rename to vendor/github.com/slack-go/slack/websocket_desktop_notification.go diff --git a/vendor/github.com/nlopes/slack/websocket_dm.go b/vendor/github.com/slack-go/slack/websocket_dm.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_dm.go rename to vendor/github.com/slack-go/slack/websocket_dm.go diff --git a/vendor/github.com/nlopes/slack/websocket_dnd.go b/vendor/github.com/slack-go/slack/websocket_dnd.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_dnd.go rename to vendor/github.com/slack-go/slack/websocket_dnd.go diff --git a/vendor/github.com/nlopes/slack/websocket_files.go b/vendor/github.com/slack-go/slack/websocket_files.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_files.go rename to vendor/github.com/slack-go/slack/websocket_files.go diff --git a/vendor/github.com/nlopes/slack/websocket_groups.go b/vendor/github.com/slack-go/slack/websocket_groups.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_groups.go rename to vendor/github.com/slack-go/slack/websocket_groups.go diff --git a/vendor/github.com/nlopes/slack/websocket_internals.go b/vendor/github.com/slack-go/slack/websocket_internals.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_internals.go rename to vendor/github.com/slack-go/slack/websocket_internals.go diff --git a/vendor/github.com/nlopes/slack/websocket_managed_conn.go b/vendor/github.com/slack-go/slack/websocket_managed_conn.go similarity index 99% rename from vendor/github.com/nlopes/slack/websocket_managed_conn.go rename to vendor/github.com/slack-go/slack/websocket_managed_conn.go index dbbf682df1..6395938cda 100644 --- a/vendor/github.com/nlopes/slack/websocket_managed_conn.go +++ b/vendor/github.com/slack-go/slack/websocket_managed_conn.go @@ -10,8 +10,8 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/nlopes/slack/internal/errorsx" - "github.com/nlopes/slack/internal/timex" + "github.com/slack-go/slack/internal/errorsx" + "github.com/slack-go/slack/internal/timex" ) // ManageConnection can be called on a Slack RTM instance returned by the diff --git a/vendor/github.com/nlopes/slack/websocket_misc.go b/vendor/github.com/slack-go/slack/websocket_misc.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_misc.go rename to vendor/github.com/slack-go/slack/websocket_misc.go diff --git a/vendor/github.com/nlopes/slack/websocket_pins.go b/vendor/github.com/slack-go/slack/websocket_pins.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_pins.go rename to vendor/github.com/slack-go/slack/websocket_pins.go diff --git a/vendor/github.com/nlopes/slack/websocket_reactions.go b/vendor/github.com/slack-go/slack/websocket_reactions.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_reactions.go rename to vendor/github.com/slack-go/slack/websocket_reactions.go diff --git a/vendor/github.com/nlopes/slack/websocket_stars.go b/vendor/github.com/slack-go/slack/websocket_stars.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_stars.go rename to vendor/github.com/slack-go/slack/websocket_stars.go diff --git a/vendor/github.com/nlopes/slack/websocket_subteam.go b/vendor/github.com/slack-go/slack/websocket_subteam.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_subteam.go rename to vendor/github.com/slack-go/slack/websocket_subteam.go diff --git a/vendor/github.com/nlopes/slack/websocket_teams.go b/vendor/github.com/slack-go/slack/websocket_teams.go similarity index 100% rename from vendor/github.com/nlopes/slack/websocket_teams.go rename to vendor/github.com/slack-go/slack/websocket_teams.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 1d3a2f216f..ad37c05cfb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -135,11 +135,6 @@ github.com/nicksnyder/go-i18n/i18n github.com/nicksnyder/go-i18n/i18n/bundle github.com/nicksnyder/go-i18n/i18n/language github.com/nicksnyder/go-i18n/i18n/translation -# github.com/nlopes/slack v0.6.0 => github.com/matterbridge/slack v0.1.1-0.20191208194820-95190f11bfb6 -github.com/nlopes/slack -github.com/nlopes/slack/internal/errorsx -github.com/nlopes/slack/internal/timex -github.com/nlopes/slack/slackutilsx # github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c github.com/paulrosania/go-charset/charset github.com/paulrosania/go-charset/data @@ -169,6 +164,11 @@ github.com/sirupsen/logrus github.com/skip2/go-qrcode github.com/skip2/go-qrcode/bitset github.com/skip2/go-qrcode/reedsolomon +# github.com/slack-go/slack v0.6.3-0.20200228121756-f56d616d5901 +github.com/slack-go/slack +github.com/slack-go/slack/internal/errorsx +github.com/slack-go/slack/internal/timex +github.com/slack-go/slack/slackutilsx # github.com/spf13/afero v1.1.2 github.com/spf13/afero github.com/spf13/afero/mem