Use upstream slack-go/slack again (#1018)
This commit is contained in:
parent
e9edbfc051
commit
250b3bb579
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
4
go.mod
4
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
|
||||
|
8
go.sum
8
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=
|
||||
|
@ -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)
|
||||
|
14
vendor/github.com/nlopes/slack/block_unknown.go
generated
vendored
14
vendor/github.com/nlopes/slack/block_unknown.go
generated
vendored
@ -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
|
||||
}
|
22
vendor/github.com/nlopes/slack/go.sum
generated
vendored
22
vendor/github.com/nlopes/slack/go.sum
generated
vendored
@ -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=
|
0
vendor/github.com/nlopes/slack/LICENSE → vendor/github.com/slack-go/slack/LICENSE
generated
vendored
0
vendor/github.com/nlopes/slack/LICENSE → vendor/github.com/slack-go/slack/LICENSE
generated
vendored
36
vendor/github.com/slack-go/slack/Makefile
generated
vendored
Normal file
36
vendor/github.com/slack-go/slack/Makefile
generated
vendored
Normal file
@ -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
|
23
vendor/github.com/nlopes/slack/README.md → vendor/github.com/slack-go/slack/README.md
generated
vendored
23
vendor/github.com/nlopes/slack/README.md → vendor/github.com/slack-go/slack/README.md
generated
vendored
@ -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
|
0
vendor/github.com/nlopes/slack/TODO.txt → vendor/github.com/slack-go/slack/TODO.txt
generated
vendored
0
vendor/github.com/nlopes/slack/TODO.txt → vendor/github.com/slack-go/slack/TODO.txt
generated
vendored
0
vendor/github.com/nlopes/slack/admin.go → vendor/github.com/slack-go/slack/admin.go
generated
vendored
0
vendor/github.com/nlopes/slack/admin.go → vendor/github.com/slack-go/slack/admin.go
generated
vendored
@ -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"`
|
0
vendor/github.com/nlopes/slack/auth.go → vendor/github.com/slack-go/slack/auth.go
generated
vendored
0
vendor/github.com/nlopes/slack/auth.go → vendor/github.com/slack-go/slack/auth.go
generated
vendored
1
vendor/github.com/nlopes/slack/block.go → vendor/github.com/slack-go/slack/block.go
generated
vendored
1
vendor/github.com/nlopes/slack/block.go → vendor/github.com/slack-go/slack/block.go
generated
vendored
@ -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
|
@ -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)
|
@ -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,
|
||||
}
|
||||
}
|
30
vendor/github.com/slack-go/slack/block_input.go
generated
vendored
Normal file
30
vendor/github.com/slack-go/slack/block_input.go
generated
vendored
Normal file
@ -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,
|
||||
}
|
||||
}
|
0
vendor/github.com/nlopes/slack/bots.go → vendor/github.com/slack-go/slack/bots.go
generated
vendored
0
vendor/github.com/nlopes/slack/bots.go → vendor/github.com/slack-go/slack/bots.go
generated
vendored
6
vendor/github.com/nlopes/slack/chat.go → vendor/github.com/slack-go/slack/chat.go
generated
vendored
6
vendor/github.com/nlopes/slack/chat.go → vendor/github.com/slack-go/slack/chat.go
generated
vendored
@ -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
|
||||
}
|
0
vendor/github.com/nlopes/slack/dnd.go → vendor/github.com/slack-go/slack/dnd.go
generated
vendored
0
vendor/github.com/nlopes/slack/dnd.go → vendor/github.com/slack-go/slack/dnd.go
generated
vendored
0
vendor/github.com/nlopes/slack/emoji.go → vendor/github.com/slack-go/slack/emoji.go
generated
vendored
0
vendor/github.com/nlopes/slack/emoji.go → vendor/github.com/slack-go/slack/emoji.go
generated
vendored
@ -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 (
|
0
vendor/github.com/nlopes/slack/files.go → vendor/github.com/slack-go/slack/files.go
generated
vendored
0
vendor/github.com/nlopes/slack/files.go → vendor/github.com/slack-go/slack/files.go
generated
vendored
5
vendor/github.com/nlopes/slack/go.mod → vendor/github.com/slack-go/slack/go.mod
generated
vendored
5
vendor/github.com/nlopes/slack/go.mod → vendor/github.com/slack-go/slack/go.mod
generated
vendored
@ -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
|
12
vendor/github.com/slack-go/slack/go.sum
generated
vendored
Normal file
12
vendor/github.com/slack-go/slack/go.sum
generated
vendored
Normal file
@ -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=
|
0
vendor/github.com/nlopes/slack/im.go → vendor/github.com/slack-go/slack/im.go
generated
vendored
0
vendor/github.com/nlopes/slack/im.go → vendor/github.com/slack-go/slack/im.go
generated
vendored
0
vendor/github.com/nlopes/slack/info.go → vendor/github.com/slack-go/slack/info.go
generated
vendored
0
vendor/github.com/nlopes/slack/info.go → vendor/github.com/slack-go/slack/info.go
generated
vendored
@ -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
|
||||
}
|
||||
|
0
vendor/github.com/nlopes/slack/item.go → vendor/github.com/slack-go/slack/item.go
generated
vendored
0
vendor/github.com/nlopes/slack/item.go → vendor/github.com/slack-go/slack/item.go
generated
vendored
@ -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"`
|
0
vendor/github.com/nlopes/slack/misc.go → vendor/github.com/slack-go/slack/misc.go
generated
vendored
0
vendor/github.com/nlopes/slack/misc.go → vendor/github.com/slack-go/slack/misc.go
generated
vendored
0
vendor/github.com/nlopes/slack/oauth.go → vendor/github.com/slack-go/slack/oauth.go
generated
vendored
0
vendor/github.com/nlopes/slack/oauth.go → vendor/github.com/slack-go/slack/oauth.go
generated
vendored
0
vendor/github.com/nlopes/slack/pins.go → vendor/github.com/slack-go/slack/pins.go
generated
vendored
0
vendor/github.com/nlopes/slack/pins.go → vendor/github.com/slack-go/slack/pins.go
generated
vendored
0
vendor/github.com/nlopes/slack/rtm.go → vendor/github.com/slack-go/slack/rtm.go
generated
vendored
0
vendor/github.com/nlopes/slack/rtm.go → vendor/github.com/slack-go/slack/rtm.go
generated
vendored
2
vendor/github.com/nlopes/slack/slack.go → vendor/github.com/slack-go/slack/slack.go
generated
vendored
2
vendor/github.com/nlopes/slack/slack.go → vendor/github.com/slack-go/slack/slack.go
generated
vendored
@ -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 {
|
0
vendor/github.com/nlopes/slack/slash.go → vendor/github.com/slack-go/slack/slash.go
generated
vendored
0
vendor/github.com/nlopes/slack/slash.go → vendor/github.com/slack-go/slack/slash.go
generated
vendored
0
vendor/github.com/nlopes/slack/stars.go → vendor/github.com/slack-go/slack/stars.go
generated
vendored
0
vendor/github.com/nlopes/slack/stars.go → vendor/github.com/slack-go/slack/stars.go
generated
vendored
0
vendor/github.com/nlopes/slack/team.go → vendor/github.com/slack-go/slack/team.go
generated
vendored
0
vendor/github.com/nlopes/slack/team.go → vendor/github.com/slack-go/slack/team.go
generated
vendored
4
vendor/github.com/nlopes/slack/users.go → vendor/github.com/slack-go/slack/users.go
generated
vendored
4
vendor/github.com/nlopes/slack/users.go → vendor/github.com/slack-go/slack/users.go
generated
vendored
@ -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
|
||||
}
|
221
vendor/github.com/slack-go/slack/views.go
generated
vendored
Normal file
221
vendor/github.com/slack-go/slack/views.go
generated
vendored
Normal file
@ -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()
|
||||
}
|
@ -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 PostWebhookContext(ctx context.Context, url string, msg *WebhookMessage) error {
|
||||
return PostWebhookCustomHTTPContext(ctx, 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")
|
||||
}
|
||||
|
||||
return checkStatusCode(response, discard{})
|
||||
return PostWebhookCustomHTTPContext(context.Background(), url, httpClient, msg)
|
||||
}
|
34
vendor/github.com/slack-go/slack/webhooks_go112.go
generated
vendored
Normal file
34
vendor/github.com/slack-go/slack/webhooks_go112.go
generated
vendored
Normal file
@ -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{})
|
||||
}
|
33
vendor/github.com/slack-go/slack/webhooks_go113.go
generated
vendored
Normal file
33
vendor/github.com/slack-go/slack/webhooks_go113.go
generated
vendored
Normal file
@ -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{})
|
||||
}
|
@ -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
|
10
vendor/modules.txt
vendored
10
vendor/modules.txt
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user