diff options
author | Wim <wim@42.be> | 2021-05-05 22:03:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 22:03:28 +0200 |
commit | a0bca42a7ad98a37f4bdc4d7adc419471163edfb (patch) | |
tree | 3e87fdb61128039b016adb4e586636484c63ed52 /vendor | |
parent | af543dcd05cfb5341311e2e214727e26411d2f92 (diff) | |
download | matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.tar.gz matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.tar.bz2 matterbridge-msglm-a0bca42a7ad98a37f4bdc4d7adc419471163edfb.zip |
Update vendor (#1461)
* Update vendored libs
* Fix slack api changes
Diffstat (limited to 'vendor')
42 files changed, 406 insertions, 1629 deletions
diff --git a/vendor/github.com/SevereCloud/vksdk/v2/.golangci.yml b/vendor/github.com/SevereCloud/vksdk/v2/.golangci.yml index 97b7a3fe..3887ceb7 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/.golangci.yml +++ b/vendor/github.com/SevereCloud/vksdk/v2/.golangci.yml @@ -39,6 +39,13 @@ linters: - tparallel - errorlint - paralleltest + - forbidigo + - makezero + - thelper + - predeclared + - ifshort + - revive + - durationcheck # - wrapcheck # TODO: v3 Fix # - testpackage # TODO: Fix testpackage @@ -62,6 +69,7 @@ linters: # - nlreturn # - gci # - exhaustivestruct +# - cyclop issues: exclude-rules: diff --git a/vendor/github.com/SevereCloud/vksdk/v2/doc.go b/vendor/github.com/SevereCloud/vksdk/v2/doc.go index 7bb83d0c..778f2ecf 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/doc.go +++ b/vendor/github.com/SevereCloud/vksdk/v2/doc.go @@ -7,6 +7,6 @@ package vksdk // Module constants. const ( - Version = "2.9.0" + Version = "2.9.1" API = "5.126" ) diff --git a/vendor/github.com/SevereCloud/vksdk/v2/events/objects.go b/vendor/github.com/SevereCloud/vksdk/v2/events/objects.go index 8cd94a91..8ee261ac 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/events/objects.go +++ b/vendor/github.com/SevereCloud/vksdk/v2/events/objects.go @@ -316,40 +316,40 @@ type LikeRemoveObject struct { // DonutSubscriptionCreateObject struct. type DonutSubscriptionCreateObject struct { - Amount int `json:"amount"` + Amount float64 `json:"amount"` AmountWithoutFee float64 `json:"amount_without_fee"` - UserID int `json:"user_id"` + UserID float64 `json:"user_id"` } // DonutSubscriptionProlongedObject struct. type DonutSubscriptionProlongedObject struct { - Amount int `json:"amount"` + Amount float64 `json:"amount"` AmountWithoutFee float64 `json:"amount_without_fee"` - UserID int `json:"user_id"` + UserID float64 `json:"user_id"` } // DonutSubscriptionExpiredObject struct. type DonutSubscriptionExpiredObject struct { - UserID int `json:"user_id"` + UserID float64 `json:"user_id"` } // DonutSubscriptionCancelledObject struct. type DonutSubscriptionCancelledObject struct { - UserID int `json:"user_id"` + UserID float64 `json:"user_id"` } // DonutSubscriptionPriceChangedObject struct. type DonutSubscriptionPriceChangedObject struct { - AmountOld int `json:"amount_old"` - AmountNew int `json:"amount_new"` + AmountOld float64 `json:"amount_old"` + AmountNew float64 `json:"amount_new"` AmountDiff float64 `json:"amount_diff"` AmountDiffWithoutFee float64 `json:"amount_diff_without_fee"` - UserID int `json:"user_id"` + UserID float64 `json:"user_id"` } // DonutMoneyWithdrawObject struct. type DonutMoneyWithdrawObject struct { - Amount int `json:"amount"` + Amount float64 `json:"amount"` AmountWithoutFee float64 `json:"amount_without_fee"` } diff --git a/vendor/github.com/SevereCloud/vksdk/v2/go.mod b/vendor/github.com/SevereCloud/vksdk/v2/go.mod index 27f7256f..622b04ad 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/go.mod +++ b/vendor/github.com/SevereCloud/vksdk/v2/go.mod @@ -5,6 +5,6 @@ go 1.13 require ( github.com/gorilla/schema v1.2.0 github.com/gorilla/websocket v1.4.2 - github.com/stretchr/testify v1.6.1 - golang.org/x/text v0.3.4 + github.com/stretchr/testify v1.7.0 + golang.org/x/text v0.3.5 ) diff --git a/vendor/github.com/SevereCloud/vksdk/v2/go.sum b/vendor/github.com/SevereCloud/vksdk/v2/go.sum index a9885d73..aea36340 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/go.sum +++ b/vendor/github.com/SevereCloud/vksdk/v2/go.sum @@ -7,10 +7,10 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad 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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/vendor/github.com/SevereCloud/vksdk/v2/object/ads.go b/vendor/github.com/SevereCloud/vksdk/v2/object/ads.go index b2d7f135..e0c379b4 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/object/ads.go +++ b/vendor/github.com/SevereCloud/vksdk/v2/object/ads.go @@ -207,8 +207,7 @@ type AdsStatsSexAge struct { } // AdsTargSettings struct. -type AdsTargSettings struct { -} +type AdsTargSettings struct{} // AdsTargStats struct. type AdsTargStats struct { diff --git a/vendor/github.com/SevereCloud/vksdk/v2/object/messages.go b/vendor/github.com/SevereCloud/vksdk/v2/object/messages.go index dc2648b1..65c65f53 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/object/messages.go +++ b/vendor/github.com/SevereCloud/vksdk/v2/object/messages.go @@ -721,8 +721,7 @@ type MessagesPinnedMessage struct { } // MessagesUserXtrInvitedBy struct. -type MessagesUserXtrInvitedBy struct { -} +type MessagesUserXtrInvitedBy struct{} // MessagesForward struct. type MessagesForward struct { diff --git a/vendor/github.com/SevereCloud/vksdk/v2/object/newsfeed.go b/vendor/github.com/SevereCloud/vksdk/v2/object/newsfeed.go index e9bda35a..857fb4c5 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/object/newsfeed.go +++ b/vendor/github.com/SevereCloud/vksdk/v2/object/newsfeed.go @@ -87,11 +87,11 @@ type NewsfeedItemStoriesBlock struct { } // NewsfeedItemTopic struct. -type NewsfeedItemTopic struct { - // Comments BaseCommentsInfo `json:"comments"` - // Likes BaseLikesInfo `json:"likes"` - // Text string `json:"text"` // Post text -} +// +// Comments BaseCommentsInfo `json:"comments"` +// Likes BaseLikesInfo `json:"likes"` +// Text string `json:"text"` // Post text. +type NewsfeedItemTopic struct{} // NewsfeedItemVideo struct. type NewsfeedItemVideo struct { diff --git a/vendor/github.com/SevereCloud/vksdk/v2/object/wall.go b/vendor/github.com/SevereCloud/vksdk/v2/object/wall.go index 5345fc5c..3dc2ad4f 100644 --- a/vendor/github.com/SevereCloud/vksdk/v2/object/wall.go +++ b/vendor/github.com/SevereCloud/vksdk/v2/object/wall.go @@ -142,7 +142,7 @@ type WallWallpost struct { FriendsOnly int `json:"friends_only"` Comments BaseCommentsInfo `json:"comments"` Likes BaseLikesInfo `json:"likes"` // Count of likes - Reposts BaseRepostsInfo `json:"reposts"` // Count of views + Reposts BaseRepostsInfo `json:"reposts"` // Count of reposts Views WallViews `json:"views"` // Count of views PostType string `json:"post_type"` PostSource WallPostSource `json:"post_source"` diff --git a/vendor/github.com/gomarkdown/markdown/html/doc.go b/vendor/github.com/gomarkdown/markdown/html/doc.go index b8d498d6..93a2cf55 100644 --- a/vendor/github.com/gomarkdown/markdown/html/doc.go +++ b/vendor/github.com/gomarkdown/markdown/html/doc.go @@ -9,7 +9,7 @@ A renderer can be configured with multiple options: flags := html.CommonFlags | html.CompletePage | html.HrefTargetBlank opts := html.RendererOptions{ - TItle: "A custom title", + Title: "A custom title", Flags: flags, } renderer := html.NewRenderer(opts) diff --git a/vendor/github.com/gomarkdown/markdown/html/renderer.go b/vendor/github.com/gomarkdown/markdown/html/renderer.go index c57d7eb6..1b466876 100644 --- a/vendor/github.com/gomarkdown/markdown/html/renderer.go +++ b/vendor/github.com/gomarkdown/markdown/html/renderer.go @@ -43,6 +43,7 @@ const ( SmartypantsAngledQuotes // Enable angled double quotes (with Smartypants) for double quotes rendering SmartypantsQuotesNBSP // Enable « French guillemets » (with Smartypants) TOC // Generate a table of contents + LazyLoadImages // Include loading="lazy" with images CommonFlags Flags = Smartypants | SmartypantsFractions | SmartypantsDashes | SmartypantsLatexDashes ) @@ -589,7 +590,11 @@ func (r *Renderer) imageEnter(w io.Writer, image *ast.Image) { //if options.safe && potentiallyUnsafe(dest) { //out(w, `<img src="" alt="`) //} else { - r.Outs(w, `<img src="`) + if r.opts.Flags&LazyLoadImages != 0 { + r.Outs(w, `<img loading="lazy" src="`) + } else { + r.Outs(w, `<img src="`) + } escLink(w, dest) r.Outs(w, `" alt="`) //} diff --git a/vendor/github.com/google/gops/agent/agent.go b/vendor/github.com/google/gops/agent/agent.go index 80be4bb6..5fde1fd1 100644 --- a/vendor/github.com/google/gops/agent/agent.go +++ b/vendor/github.com/google/gops/agent/agent.go @@ -59,7 +59,7 @@ type Options struct { ShutdownCleanup bool // ReuseSocketAddrAndPort determines whether the SO_REUSEADDR and - // SO_REUSEADDR socket options should be set on the listening socket of + // SO_REUSEPORT socket options should be set on the listening socket of // the agent. This option is only effective on unix-like OSes and if // Addr is set to a fixed host:port. // Optional. diff --git a/vendor/github.com/labstack/echo/v4/CHANGELOG.md b/vendor/github.com/labstack/echo/v4/CHANGELOG.md index b5047883..c1be77a9 100644 --- a/vendor/github.com/labstack/echo/v4/CHANGELOG.md +++ b/vendor/github.com/labstack/echo/v4/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## v4.2.2 - 2020-04-07 + +**Fixes** + +* Allow proxy middleware to use query part in rewrite (#1802) +* Fix timeout middleware not sending status code when handler returns an error (#1805) +* Fix Bind() when target is array/slice and path/query params complains bind target not being struct (#1835) +* Fix panic in redirect middleware on short host name (#1813) +* Fix timeout middleware docs (#1836) + ## v4.2.1 - 2020-03-08 **Important notes** diff --git a/vendor/github.com/labstack/echo/v4/bind.go b/vendor/github.com/labstack/echo/v4/bind.go index 16c3b7ad..08d39891 100644 --- a/vendor/github.com/labstack/echo/v4/bind.go +++ b/vendor/github.com/labstack/echo/v4/bind.go @@ -134,6 +134,10 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri // !struct if typ.Kind() != reflect.Struct { + if tag == "param" || tag == "query" { + // incompatible type, data is probably to be found in the body + return nil + } return errors.New("binding element must be a struct") } diff --git a/vendor/github.com/labstack/echo/v4/echo.go b/vendor/github.com/labstack/echo/v4/echo.go index 3fccaf64..a24e3977 100644 --- a/vendor/github.com/labstack/echo/v4/echo.go +++ b/vendor/github.com/labstack/echo/v4/echo.go @@ -234,7 +234,7 @@ const ( const ( // Version of Echo - Version = "4.2.1" + Version = "4.2.2" website = "https://echo.labstack.com" // http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo banner = ` diff --git a/vendor/github.com/labstack/echo/v4/middleware/middleware.go b/vendor/github.com/labstack/echo/v4/middleware/middleware.go index 6bdb0eb7..a7ad73a5 100644 --- a/vendor/github.com/labstack/echo/v4/middleware/middleware.go +++ b/vendor/github.com/labstack/echo/v4/middleware/middleware.go @@ -2,7 +2,6 @@ package middleware import ( "net/http" - "net/url" "regexp" "strconv" "strings" @@ -49,30 +48,39 @@ func rewriteRulesRegex(rewrite map[string]string) map[*regexp.Regexp]string { return rulesRegex } -func rewritePath(rewriteRegex map[*regexp.Regexp]string, req *http.Request) { - for k, v := range rewriteRegex { - rawPath := req.URL.RawPath - if rawPath != "" { - // RawPath is only set when there has been escaping done. In that case Path must be deduced from rewritten RawPath - // because encoded Path could match rules that RawPath did not - if replacer := captureTokens(k, rawPath); replacer != nil { - rawPath = replacer.Replace(v) - - req.URL.RawPath = rawPath - req.URL.Path, _ = url.PathUnescape(rawPath) - - return // rewrite only once - } +func rewriteURL(rewriteRegex map[*regexp.Regexp]string, req *http.Request) error { + if len(rewriteRegex) == 0 { + return nil + } - continue + // Depending how HTTP request is sent RequestURI could contain Scheme://Host/path or be just /path. + // We only want to use path part for rewriting and therefore trim prefix if it exists + rawURI := req.RequestURI + if rawURI != "" && rawURI[0] != '/' { + prefix := "" + if req.URL.Scheme != "" { + prefix = req.URL.Scheme + "://" } + if req.URL.Host != "" { + prefix += req.URL.Host // host or host:port + } + if prefix != "" { + rawURI = strings.TrimPrefix(rawURI, prefix) + } + } - if replacer := captureTokens(k, req.URL.Path); replacer != nil { - req.URL.Path = replacer.Replace(v) + for k, v := range rewriteRegex { + if replacer := captureTokens(k, rawURI); replacer != nil { + url, err := req.URL.Parse(replacer.Replace(v)) + if err != nil { + return err + } + req.URL = url - return // rewrite only once + return nil // rewrite only once } } + return nil } // DefaultSkipper returns false which processes the middleware. diff --git a/vendor/github.com/labstack/echo/v4/middleware/proxy.go b/vendor/github.com/labstack/echo/v4/middleware/proxy.go index 63eec5a2..6f01f3a7 100644 --- a/vendor/github.com/labstack/echo/v4/middleware/proxy.go +++ b/vendor/github.com/labstack/echo/v4/middleware/proxy.go @@ -231,8 +231,9 @@ func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc { tgt := config.Balancer.Next(c) c.Set(config.ContextKey, tgt) - // Set rewrite path and raw path - rewritePath(config.RegexRewrite, req) + if err := rewriteURL(config.RegexRewrite, req); err != nil { + return err + } // Fix header // Basically it's not good practice to unconditionally pass incoming x-real-ip header to upstream. diff --git a/vendor/github.com/labstack/echo/v4/middleware/redirect.go b/vendor/github.com/labstack/echo/v4/middleware/redirect.go index 813e5b85..13877db3 100644 --- a/vendor/github.com/labstack/echo/v4/middleware/redirect.go +++ b/vendor/github.com/labstack/echo/v4/middleware/redirect.go @@ -2,6 +2,7 @@ package middleware import ( "net/http" + "strings" "github.com/labstack/echo/v4" ) @@ -40,11 +41,11 @@ func HTTPSRedirect() echo.MiddlewareFunc { // HTTPSRedirectWithConfig returns an HTTPSRedirect middleware with config. // See `HTTPSRedirect()`. func HTTPSRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = scheme != "https"; ok { - url = "https://" + host + uri + return redirect(config, func(scheme, host, uri string) (bool, string) { + if scheme != "https" { + return true, "https://" + host + uri } - return + return false, "" }) } @@ -59,11 +60,11 @@ func HTTPSWWWRedirect() echo.MiddlewareFunc { // HTTPSWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. // See `HTTPSWWWRedirect()`. func HTTPSWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = scheme != "https" && host[:4] != www; ok { - url = "https://www." + host + uri + return redirect(config, func(scheme, host, uri string) (bool, string) { + if scheme != "https" && !strings.HasPrefix(host, www) { + return true, "https://www." + host + uri } - return + return false, "" }) } @@ -79,13 +80,11 @@ func HTTPSNonWWWRedirect() echo.MiddlewareFunc { // See `HTTPSNonWWWRedirect()`. func HTTPSNonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = scheme != "https"; ok { - if host[:4] == www { - host = host[4:] - } - url = "https://" + host + uri + if scheme != "https" { + host = strings.TrimPrefix(host, www) + return true, "https://" + host + uri } - return + return false, "" }) } @@ -100,11 +99,11 @@ func WWWRedirect() echo.MiddlewareFunc { // WWWRedirectWithConfig returns an HTTPSRedirect middleware with config. // See `WWWRedirect()`. func WWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = host[:4] != www; ok { - url = scheme + "://www." + host + uri + return redirect(config, func(scheme, host, uri string) (bool, string) { + if !strings.HasPrefix(host, www) { + return true, scheme + "://www." + host + uri } - return + return false, "" }) } @@ -119,17 +118,17 @@ func NonWWWRedirect() echo.MiddlewareFunc { // NonWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. // See `NonWWWRedirect()`. func NonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = host[:4] == www; ok { - url = scheme + "://" + host[4:] + uri + return redirect(config, func(scheme, host, uri string) (bool, string) { + if strings.HasPrefix(host, www) { + return true, scheme + "://" + host[4:] + uri } - return + return false, "" }) } func redirect(config RedirectConfig, cb redirectLogic) echo.MiddlewareFunc { if config.Skipper == nil { - config.Skipper = DefaultTrailingSlashConfig.Skipper + config.Skipper = DefaultRedirectConfig.Skipper } if config.Code == 0 { config.Code = DefaultRedirectConfig.Code diff --git a/vendor/github.com/labstack/echo/v4/middleware/rewrite.go b/vendor/github.com/labstack/echo/v4/middleware/rewrite.go index c05d5d84..e5b0a6b5 100644 --- a/vendor/github.com/labstack/echo/v4/middleware/rewrite.go +++ b/vendor/github.com/labstack/echo/v4/middleware/rewrite.go @@ -72,9 +72,9 @@ func RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc { return next(c) } - req := c.Request() - // Set rewrite path and raw path - rewritePath(config.RegexRules, req) + if err := rewriteURL(config.RegexRules, c.Request()); err != nil { + return err + } return next(c) } } diff --git a/vendor/github.com/labstack/echo/v4/middleware/timeout.go b/vendor/github.com/labstack/echo/v4/middleware/timeout.go index 68f464e4..5d23ff45 100644 --- a/vendor/github.com/labstack/echo/v4/middleware/timeout.go +++ b/vendor/github.com/labstack/echo/v4/middleware/timeout.go @@ -42,8 +42,8 @@ var ( } ) -// Timeout returns a middleware which recovers from panics anywhere in the chain -// and handles the control to the centralized HTTPErrorHandler. +// Timeout returns a middleware which returns error (503 Service Unavailable error) to client immediately when handler +// call runs for longer than its time limit. NB: timeout does not stop handler execution. func Timeout() echo.MiddlewareFunc { return TimeoutWithConfig(DefaultTimeoutConfig) } @@ -106,6 +106,11 @@ func (t echoHandlerFuncWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Reques // so on timeout writer stays what http.TimeoutHandler uses and prevents writing headers/body t.ctx.Response().Writer = originalWriter if err != nil { + // call global error handler to write error to the client. This is needed or `http.TimeoutHandler` will send status code by itself + // and after that our tries to write status code will not work anymore + t.ctx.Error(err) + // we pass error from handler to middlewares up in handler chain to act on it if needed. But this means that + // global error handler is probably be called twice as `t.ctx.Error` already does that. t.errChan <- err } } diff --git a/vendor/github.com/slack-go/slack/README.md b/vendor/github.com/slack-go/slack/README.md index 7be89066..dc83eaa8 100644 --- a/vendor/github.com/slack-go/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/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) +Slack API in Go [![Go Reference](https://pkg.go.dev/badge/github.com/slack-go/slack.svg)](https://pkg.go.dev/github.com/slack-go/slack) =============== + This is the original Slack library for Go created by Norberto Lopes, 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) @@ -14,7 +15,7 @@ a fully managed way. There is currently no major version released. Therefore, minor version releases may include backward incompatible changes. -See [CHANGELOG.md](https://github.com/slack-go/slack/blob/master/CHANGELOG.md) for more information about the changes. +See [CHANGELOG.md](https://github.com/slack-go/slack/blob/master/CHANGELOG.md) or [Releases](https://github.com/slack-go/slack/releases) for more information about the changes. ## Installing diff --git a/vendor/github.com/slack-go/slack/apps.go b/vendor/github.com/slack-go/slack/apps.go index d9749438..4f60da0a 100644 --- a/vendor/github.com/slack-go/slack/apps.go +++ b/vendor/github.com/slack-go/slack/apps.go @@ -45,14 +45,13 @@ func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventCont func (api *Client) UninstallApp(clientID, clientSecret string) error { values := url.Values{ - "token": {api.token}, "client_id": {clientID}, "client_secret": {clientSecret}, } response := SlackResponse{} - err := api.getMethod(context.Background(), "apps.uninstall", values, &response) + err := api.getMethod(context.Background(), "apps.uninstall", api.token, values, &response) if err != nil { return err } diff --git a/vendor/github.com/slack-go/slack/attachments.go b/vendor/github.com/slack-go/slack/attachments.go index 69b223a2..f4eb9b93 100644 --- a/vendor/github.com/slack-go/slack/attachments.go +++ b/vendor/github.com/slack-go/slack/attachments.go @@ -17,7 +17,7 @@ type AttachmentAction struct { Name string `json:"name"` // Required. Text string `json:"text"` // Required. Style string `json:"style,omitempty"` // Optional. Allowed values: "default", "primary", "danger". - Type actionType `json:"type"` // Required. Must be set to "button" or "select". + Type ActionType `json:"type"` // Required. Must be set to "button" or "select". Value string `json:"value,omitempty"` // Optional. DataSource string `json:"data_source,omitempty"` // Optional. MinQueryLength int `json:"min_query_length,omitempty"` // Optional. Default value is 1. @@ -29,7 +29,7 @@ type AttachmentAction struct { } // actionType returns the type of the action -func (a AttachmentAction) actionType() actionType { +func (a AttachmentAction) actionType() ActionType { return a.Type } diff --git a/vendor/github.com/slack-go/slack/block.go b/vendor/github.com/slack-go/slack/block.go index 9946a294..3686db85 100644 --- a/vendor/github.com/slack-go/slack/block.go +++ b/vendor/github.com/slack-go/slack/block.go @@ -35,7 +35,7 @@ type Blocks struct { type BlockAction struct { ActionID string `json:"action_id"` BlockID string `json:"block_id"` - Type actionType `json:"type"` + Type ActionType `json:"type"` Text TextBlockObject `json:"text"` Value string `json:"value"` ActionTs string `json:"action_ts"` @@ -58,7 +58,7 @@ type BlockAction struct { } // actionType returns the type of the action -func (b BlockAction) actionType() actionType { +func (b BlockAction) actionType() ActionType { return b.Type } diff --git a/vendor/github.com/slack-go/slack/block_conv.go b/vendor/github.com/slack-go/slack/block_conv.go index f2d744c4..6936700a 100644 --- a/vendor/github.com/slack-go/slack/block_conv.go +++ b/vendor/github.com/slack-go/slack/block_conv.go @@ -181,6 +181,8 @@ func (b *BlockElements) UnmarshalJSON(data []byte) error { blockElement = &OverflowBlockElement{} case "datepicker": blockElement = &DatePickerBlockElement{} + case "timepicker": + blockElement = &TimePickerBlockElement{} case "plain_text_input": blockElement = &PlainTextInputBlockElement{} case "checkboxes": diff --git a/vendor/github.com/slack-go/slack/channels.go b/vendor/github.com/slack-go/slack/channels.go index c05521d0..2fca8b92 100644 --- a/vendor/github.com/slack-go/slack/channels.go +++ b/vendor/github.com/slack-go/slack/channels.go @@ -3,8 +3,6 @@ package slack import ( "context" "net/url" - "strconv" - "time" ) type channelResponseFull struct { @@ -19,12 +17,6 @@ type channelResponseFull struct { } // Channel contains information about the channel -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api type Channel struct { GroupConversation IsChannel bool `json:"is_channel"` @@ -42,673 +34,3 @@ func (api *Client) channelRequest(ctx context.Context, path string, values url.V return response, response.Err() } - -// GetChannelsOption option provided when getting channels. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -type GetChannelsOption func(*ChannelPagination) error - -// GetChannelsOptionExcludeMembers excludes the members collection from each channel. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func GetChannelsOptionExcludeMembers() GetChannelsOption { - return func(p *ChannelPagination) error { - p.excludeMembers = true - return nil - } -} - -// GetChannelsOptionExcludeArchived excludes archived channels from results. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func GetChannelsOptionExcludeArchived() GetChannelsOption { - return func(p *ChannelPagination) error { - p.excludeArchived = true - return nil - } -} - -// ArchiveChannel archives the given channel -// see https://api.slack.com/methods/channels.archive -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) ArchiveChannel(channelID string) error { - return api.ArchiveChannelContext(context.Background(), channelID) -} - -// ArchiveChannelContext archives the given channel with a custom context -// see https://api.slack.com/methods/channels.archive -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) ArchiveChannelContext(ctx context.Context, channelID string) (err error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - } - - _, err = api.channelRequest(ctx, "channels.archive", values) - return err -} - -// UnarchiveChannel unarchives the given channel -// see https://api.slack.com/methods/channels.unarchive -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) UnarchiveChannel(channelID string) error { - return api.UnarchiveChannelContext(context.Background(), channelID) -} - -// UnarchiveChannelContext unarchives the given channel with a custom context -// see https://api.slack.com/methods/channels.unarchive -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) UnarchiveChannelContext(ctx context.Context, channelID string) (err error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - } - - _, err = api.channelRequest(ctx, "channels.unarchive", values) - return err -} - -// CreateChannel creates a channel with the given name and returns a *Channel -// see https://api.slack.com/methods/channels.create -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CreateChannel(channelName string) (*Channel, error) { - return api.CreateChannelContext(context.Background(), channelName) -} - -// CreateChannelContext creates a channel with the given name and returns a *Channel with a custom context -// see https://api.slack.com/methods/channels.create -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CreateChannelContext(ctx context.Context, channelName string) (*Channel, error) { - values := url.Values{ - "token": {api.token}, - "name": {channelName}, - } - - response, err := api.channelRequest(ctx, "channels.create", values) - if err != nil { - return nil, err - } - return &response.Channel, nil -} - -// GetChannelHistory retrieves the channel history -// see https://api.slack.com/methods/channels.history -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelHistory(channelID string, params HistoryParameters) (*History, error) { - return api.GetChannelHistoryContext(context.Background(), channelID, params) -} - -// GetChannelHistoryContext retrieves the channel history with a custom context -// see https://api.slack.com/methods/channels.history -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelHistoryContext(ctx context.Context, channelID string, params HistoryParameters) (*History, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - } - if params.Latest != DEFAULT_HISTORY_LATEST { - values.Add("latest", params.Latest) - } - if params.Oldest != DEFAULT_HISTORY_OLDEST { - values.Add("oldest", params.Oldest) - } - if params.Count != DEFAULT_HISTORY_COUNT { - values.Add("count", strconv.Itoa(params.Count)) - } - if params.Inclusive != DEFAULT_HISTORY_INCLUSIVE { - if params.Inclusive { - values.Add("inclusive", "1") - } else { - values.Add("inclusive", "0") - } - } - - if params.Unreads != DEFAULT_HISTORY_UNREADS { - if params.Unreads { - values.Add("unreads", "1") - } else { - values.Add("unreads", "0") - } - } - - response, err := api.channelRequest(ctx, "channels.history", values) - if err != nil { - return nil, err - } - return &response.History, nil -} - -// GetChannelInfo retrieves the given channel -// see https://api.slack.com/methods/channels.info -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelInfo(channelID string) (*Channel, error) { - return api.GetChannelInfoContext(context.Background(), channelID) -} - -// GetChannelInfoContext retrieves the given channel with a custom context -// see https://api.slack.com/methods/channels.info -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelInfoContext(ctx context.Context, channelID string) (*Channel, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "include_locale": {strconv.FormatBool(true)}, - } - - response, err := api.channelRequest(ctx, "channels.info", values) - if err != nil { - return nil, err - } - return &response.Channel, nil -} - -// InviteUserToChannel invites a user to a given channel and returns a *Channel -// see https://api.slack.com/methods/channels.invite -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) InviteUserToChannel(channelID, user string) (*Channel, error) { - return api.InviteUserToChannelContext(context.Background(), channelID, user) -} - -// InviteUserToChannelContext invites a user to a given channel and returns a *Channel with a custom context -// see https://api.slack.com/methods/channels.invite -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) InviteUserToChannelContext(ctx context.Context, channelID, user string) (*Channel, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "user": {user}, - } - - response, err := api.channelRequest(ctx, "channels.invite", values) - if err != nil { - return nil, err - } - return &response.Channel, nil -} - -// JoinChannel joins the currently authenticated user to a channel -// see https://api.slack.com/methods/channels.join -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) JoinChannel(channelName string) (*Channel, error) { - return api.JoinChannelContext(context.Background(), channelName) -} - -// JoinChannelContext joins the currently authenticated user to a channel with a custom context -// see https://api.slack.com/methods/channels.join -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) JoinChannelContext(ctx context.Context, channelName string) (*Channel, error) { - values := url.Values{ - "token": {api.token}, - "name": {channelName}, - } - - response, err := api.channelRequest(ctx, "channels.join", values) - if err != nil { - return nil, err - } - return &response.Channel, nil -} - -// LeaveChannel makes the authenticated user leave the given channel -// see https://api.slack.com/methods/channels.leave -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) LeaveChannel(channelID string) (bool, error) { - return api.LeaveChannelContext(context.Background(), channelID) -} - -// LeaveChannelContext makes the authenticated user leave the given channel with a custom context -// see https://api.slack.com/methods/channels.leave -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) LeaveChannelContext(ctx context.Context, channelID string) (bool, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - } - - response, err := api.channelRequest(ctx, "channels.leave", values) - if err != nil { - return false, err - } - - return response.NotInChannel, nil -} - -// KickUserFromChannel kicks a user from a given channel -// see https://api.slack.com/methods/channels.kick -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) KickUserFromChannel(channelID, user string) error { - return api.KickUserFromChannelContext(context.Background(), channelID, user) -} - -// KickUserFromChannelContext kicks a user from a given channel with a custom context -// see https://api.slack.com/methods/channels.kick -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) KickUserFromChannelContext(ctx context.Context, channelID, user string) (err error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "user": {user}, - } - - _, err = api.channelRequest(ctx, "channels.kick", values) - return err -} - -func newChannelPagination(c *Client, options ...GetChannelsOption) (cp ChannelPagination) { - cp = ChannelPagination{ - c: c, - limit: 200, // per slack api documentation. - } - - for _, opt := range options { - opt(&cp) - } - - return cp -} - -// ChannelPagination allows for paginating over the channels -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -type ChannelPagination struct { - Channels []Channel - limit int - excludeArchived bool - excludeMembers bool - previousResp *ResponseMetadata - c *Client -} - -// Done checks if the pagination has completed -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (ChannelPagination) Done(err error) bool { - return err == errPaginationComplete -} - -// Failure checks if pagination failed. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (t ChannelPagination) Failure(err error) error { - if t.Done(err) { - return nil - } - - return err -} - -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (t ChannelPagination) Next(ctx context.Context) (_ ChannelPagination, err error) { - var ( - resp *channelResponseFull - ) - - if t.c == nil || (t.previousResp != nil && t.previousResp.Cursor == "") { - return t, errPaginationComplete - } - - t.previousResp = t.previousResp.initialize() - - values := url.Values{ - "limit": {strconv.Itoa(t.limit)}, - "exclude_archived": {strconv.FormatBool(t.excludeArchived)}, - "exclude_members": {strconv.FormatBool(t.excludeMembers)}, - "token": {t.c.token}, - "cursor": {t.previousResp.Cursor}, - } - - if resp, err = t.c.channelRequest(ctx, "channels.list", values); err != nil { - return t, err - } - - t.c.Debugf("GetChannelsContext: got %d channels; metadata %v", len(resp.Channels), resp.Metadata) - t.Channels = resp.Channels - t.previousResp = &resp.Metadata - - return t, nil -} - -// GetChannelsPaginated fetches channels in a paginated fashion, see GetChannelsContext for usage. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelsPaginated(options ...GetChannelsOption) ChannelPagination { - return newChannelPagination(api, options...) -} - -// GetChannels retrieves all the channels -// see https://api.slack.com/methods/channels.list -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannels(excludeArchived bool, options ...GetChannelsOption) ([]Channel, error) { - return api.GetChannelsContext(context.Background(), excludeArchived, options...) -} - -// GetChannelsContext retrieves all the channels with a custom context -// see https://api.slack.com/methods/channels.list -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelsContext(ctx context.Context, excludeArchived bool, options ...GetChannelsOption) (results []Channel, err error) { - if excludeArchived { - options = append(options, GetChannelsOptionExcludeArchived()) - } - - p := api.GetChannelsPaginated(options...) - for err == nil { - p, err = p.Next(ctx) - if err == nil { - results = append(results, p.Channels...) - } else if rateLimitedError, ok := err.(*RateLimitedError); ok { - select { - case <-ctx.Done(): - err = ctx.Err() - case <-time.After(rateLimitedError.RetryAfter): - err = nil - } - } - } - - return results, p.Failure(err) -} - -// SetChannelReadMark sets the read mark of a given channel to a specific point -// Clients should try to avoid making this call too often. When needing to mark a read position, a client should set a -// timer before making the call. In this way, any further updates needed during the timeout will not generate extra calls -// (just one per channel). This is useful for when reading scroll-back history, or following a busy live channel. A -// timeout of 5 seconds is a good starting point. Be sure to flush these calls on shutdown/logout. -// see https://api.slack.com/methods/channels.mark -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetChannelReadMark(channelID, ts string) error { - return api.SetChannelReadMarkContext(context.Background(), channelID, ts) -} - -// SetChannelReadMarkContext sets the read mark of a given channel to a specific point with a custom context -// For more details see SetChannelReadMark documentation -// see https://api.slack.com/methods/channels.mark -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetChannelReadMarkContext(ctx context.Context, channelID, ts string) (err error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "ts": {ts}, - } - - _, err = api.channelRequest(ctx, "channels.mark", values) - return err -} - -// RenameChannel renames a given channel -// see https://api.slack.com/methods/channels.rename -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) RenameChannel(channelID, name string) (*Channel, error) { - return api.RenameChannelContext(context.Background(), channelID, name) -} - -// RenameChannelContext renames a given channel with a custom context -// see https://api.slack.com/methods/channels.rename -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) RenameChannelContext(ctx context.Context, channelID, name string) (*Channel, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "name": {name}, - } - - // XXX: the created entry in this call returns a string instead of a number - // so I may have to do some workaround to solve it. - response, err := api.channelRequest(ctx, "channels.rename", values) - if err != nil { - return nil, err - } - return &response.Channel, nil -} - -// SetChannelPurpose sets the channel purpose and returns the purpose that was successfully set -// see https://api.slack.com/methods/channels.setPurpose -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetChannelPurpose(channelID, purpose string) (string, error) { - return api.SetChannelPurposeContext(context.Background(), channelID, purpose) -} - -// SetChannelPurposeContext sets the channel purpose and returns the purpose that was successfully set with a custom context -// see https://api.slack.com/methods/channels.setPurpose -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetChannelPurposeContext(ctx context.Context, channelID, purpose string) (string, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "purpose": {purpose}, - } - - response, err := api.channelRequest(ctx, "channels.setPurpose", values) - if err != nil { - return "", err - } - return response.Purpose, nil -} - -// SetChannelTopic sets the channel topic and returns the topic that was successfully set -// see https://api.slack.com/methods/channels.setTopic -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetChannelTopic(channelID, topic string) (string, error) { - return api.SetChannelTopicContext(context.Background(), channelID, topic) -} - -// SetChannelTopicContext sets the channel topic and returns the topic that was successfully set with a custom context -// see https://api.slack.com/methods/channels.setTopic -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetChannelTopicContext(ctx context.Context, channelID, topic string) (string, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "topic": {topic}, - } - - response, err := api.channelRequest(ctx, "channels.setTopic", values) - if err != nil { - return "", err - } - return response.Topic, nil -} - -// GetChannelReplies gets an entire thread (a message plus all the messages in reply to it). -// see https://api.slack.com/methods/channels.replies -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelReplies(channelID, thread_ts string) ([]Message, error) { - return api.GetChannelRepliesContext(context.Background(), channelID, thread_ts) -} - -// GetChannelRepliesContext gets an entire thread (a message plus all the messages in reply to it) with a custom context -// see https://api.slack.com/methods/channels.replies -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetChannelRepliesContext(ctx context.Context, channelID, thread_ts string) ([]Message, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "thread_ts": {thread_ts}, - } - response, err := api.channelRequest(ctx, "channels.replies", values) - if err != nil { - return nil, err - } - return response.History.Messages, nil -} diff --git a/vendor/github.com/slack-go/slack/chat.go b/vendor/github.com/slack-go/slack/chat.go index f5b80346..2a1e452e 100644 --- a/vendor/github.com/slack-go/slack/chat.go +++ b/vendor/github.com/slack-go/slack/chat.go @@ -744,7 +744,6 @@ func (api *Client) GetPermalink(params *PermalinkParameters) (string, error) { // GetPermalinkContext returns the permalink for a message using a custom context. func (api *Client) GetPermalinkContext(ctx context.Context, params *PermalinkParameters) (string, error) { values := url.Values{ - "token": {api.token}, "channel": {params.Channel}, "message_ts": {params.Ts}, } @@ -754,7 +753,7 @@ func (api *Client) GetPermalinkContext(ctx context.Context, params *PermalinkPar Permalink string `json:"permalink"` SlackResponse }{} - err := api.getMethod(ctx, "chat.getPermalink", values, &response) + err := api.getMethod(ctx, "chat.getPermalink", api.token, values, &response) if err != nil { return "", err } diff --git a/vendor/github.com/slack-go/slack/conversation.go b/vendor/github.com/slack-go/slack/conversation.go index 6fc4a083..17b6d8a4 100644 --- a/vendor/github.com/slack-go/slack/conversation.go +++ b/vendor/github.com/slack-go/slack/conversation.go @@ -455,7 +455,7 @@ func (api *Client) GetConversationRepliesContext(ctx context.Context, params *Ge type GetConversationsParameters struct { Cursor string - ExcludeArchived string + ExcludeArchived bool Limit int Types []string } @@ -479,8 +479,8 @@ func (api *Client) GetConversationsContext(ctx context.Context, params *GetConve if params.Types != nil { values.Add("types", strings.Join(params.Types, ",")) } - if params.ExcludeArchived == "true" { - values.Add("exclude_archived", "true") + if params.ExcludeArchived { + values.Add("exclude_archived", strconv.FormatBool(params.ExcludeArchived)) } response := struct { diff --git a/vendor/github.com/slack-go/slack/files.go b/vendor/github.com/slack-go/slack/files.go index 713038f0..3889fe1d 100644 --- a/vendor/github.com/slack-go/slack/files.go +++ b/vendor/github.com/slack-go/slack/files.go @@ -295,9 +295,7 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam return nil, err } response := &fileResponseFull{} - values := url.Values{ - "token": {api.token}, - } + values := url.Values{} if params.Filetype != "" { values.Add("filetype", params.Filetype) } @@ -320,12 +318,12 @@ func (api *Client) UploadFileContext(ctx context.Context, params FileUploadParam values.Add("content", params.Content) err = api.postMethod(ctx, "files.upload", values, response) } else if params.File != "" { - err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", values, response, api) + err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.File, "file", api.token, values, response, api) } else if params.Reader != nil { if params.Filename == "" { return nil, fmt.Errorf("files.upload: FileUploadParameters.Filename is mandatory when using FileUploadParameters.Reader") } - err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", values, params.Reader, response, api) + err = postWithMultipartResponse(ctx, api.httpclient, api.endpoint+"files.upload", params.Filename, "file", api.token, values, params.Reader, response, api) } if err != nil { diff --git a/vendor/github.com/slack-go/slack/go.mod b/vendor/github.com/slack-go/slack/go.mod index 32fc4b93..e93a8a4a 100644 --- a/vendor/github.com/slack-go/slack/go.mod +++ b/vendor/github.com/slack-go/slack/go.mod @@ -9,4 +9,4 @@ require ( github.com/stretchr/testify v1.2.2 ) -go 1.13 +go 1.16 diff --git a/vendor/github.com/slack-go/slack/groups.go b/vendor/github.com/slack-go/slack/groups.go index 4c5793dc..b77f909d 100644 --- a/vendor/github.com/slack-go/slack/groups.go +++ b/vendor/github.com/slack-go/slack/groups.go @@ -1,574 +1,7 @@ package slack -import ( - "context" - "net/url" - "strconv" -) - // Group contains all the information for a group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api type Group struct { GroupConversation IsGroup bool `json:"is_group"` } - -type groupResponseFull struct { - Group Group `json:"group"` - Groups []Group `json:"groups"` - Purpose string `json:"purpose"` - Topic string `json:"topic"` - NotInGroup bool `json:"not_in_group"` - NoOp bool `json:"no_op"` - AlreadyClosed bool `json:"already_closed"` - AlreadyOpen bool `json:"already_open"` - AlreadyInGroup bool `json:"already_in_group"` - Channel Channel `json:"channel"` - History - SlackResponse -} - -func (api *Client) groupRequest(ctx context.Context, path string, values url.Values) (*groupResponseFull, error) { - response := &groupResponseFull{} - err := api.postMethod(ctx, path, values, response) - if err != nil { - return nil, err - } - - return response, response.Err() -} - -// ArchiveGroup archives a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) ArchiveGroup(group string) error { - return api.ArchiveGroupContext(context.Background(), group) -} - -// ArchiveGroupContext archives a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) ArchiveGroupContext(ctx context.Context, group string) error { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - } - - _, err := api.groupRequest(ctx, "groups.archive", values) - return err -} - -// UnarchiveGroup unarchives a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) UnarchiveGroup(group string) error { - return api.UnarchiveGroupContext(context.Background(), group) -} - -// UnarchiveGroupContext unarchives a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) UnarchiveGroupContext(ctx context.Context, group string) error { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - } - - _, err := api.groupRequest(ctx, "groups.unarchive", values) - return err -} - -// CreateGroup creates a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CreateGroup(group string) (*Group, error) { - return api.CreateGroupContext(context.Background(), group) -} - -// CreateGroupContext creates a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CreateGroupContext(ctx context.Context, group string) (*Group, error) { - values := url.Values{ - "token": {api.token}, - "name": {group}, - } - - response, err := api.groupRequest(ctx, "groups.create", values) - if err != nil { - return nil, err - } - return &response.Group, nil -} - -// CreateChildGroup creates a new private group archiving the old one -// This method takes an existing private group and performs the following steps: -// 1. Renames the existing group (from "example" to "example-archived"). -// 2. Archives the existing group. -// 3. Creates a new group with the name of the existing group. -// 4. Adds all members of the existing group to the new group. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CreateChildGroup(group string) (*Group, error) { - return api.CreateChildGroupContext(context.Background(), group) -} - -// CreateChildGroupContext creates a new private group archiving the old one with a custom context -// For more information see CreateChildGroup -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CreateChildGroupContext(ctx context.Context, group string) (*Group, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - } - - response, err := api.groupRequest(ctx, "groups.createChild", values) - if err != nil { - return nil, err - } - return &response.Group, nil -} - -// GetGroupHistory fetches all the history for a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroupHistory(group string, params HistoryParameters) (*History, error) { - return api.GetGroupHistoryContext(context.Background(), group, params) -} - -// GetGroupHistoryContext fetches all the history for a private group with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroupHistoryContext(ctx context.Context, group string, params HistoryParameters) (*History, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - } - if params.Latest != DEFAULT_HISTORY_LATEST { - values.Add("latest", params.Latest) - } - if params.Oldest != DEFAULT_HISTORY_OLDEST { - values.Add("oldest", params.Oldest) - } - if params.Count != DEFAULT_HISTORY_COUNT { - values.Add("count", strconv.Itoa(params.Count)) - } - if params.Inclusive != DEFAULT_HISTORY_INCLUSIVE { - if params.Inclusive { - values.Add("inclusive", "1") - } else { - values.Add("inclusive", "0") - } - } - if params.Unreads != DEFAULT_HISTORY_UNREADS { - if params.Unreads { - values.Add("unreads", "1") - } else { - values.Add("unreads", "0") - } - } - - response, err := api.groupRequest(ctx, "groups.history", values) - if err != nil { - return nil, err - } - return &response.History, nil -} - -// InviteUserToGroup invites a specific user to a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) InviteUserToGroup(group, user string) (*Group, bool, error) { - return api.InviteUserToGroupContext(context.Background(), group, user) -} - -// InviteUserToGroupContext invites a specific user to a private group with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) InviteUserToGroupContext(ctx context.Context, group, user string) (*Group, bool, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - "user": {user}, - } - - response, err := api.groupRequest(ctx, "groups.invite", values) - if err != nil { - return nil, false, err - } - return &response.Group, response.AlreadyInGroup, nil -} - -// LeaveGroup makes authenticated user leave the group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) LeaveGroup(group string) error { - return api.LeaveGroupContext(context.Background(), group) -} - -// LeaveGroupContext makes authenticated user leave the group with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) LeaveGroupContext(ctx context.Context, group string) (err error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - } - - _, err = api.groupRequest(ctx, "groups.leave", values) - return err -} - -// KickUserFromGroup kicks a user from a group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) KickUserFromGroup(group, user string) error { - return api.KickUserFromGroupContext(context.Background(), group, user) -} - -// KickUserFromGroupContext kicks a user from a group with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) KickUserFromGroupContext(ctx context.Context, group, user string) (err error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - "user": {user}, - } - - _, err = api.groupRequest(ctx, "groups.kick", values) - return err -} - -// GetGroups retrieves all groups -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroups(excludeArchived bool) ([]Group, error) { - return api.GetGroupsContext(context.Background(), excludeArchived) -} - -// GetGroupsContext retrieves all groups with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroupsContext(ctx context.Context, excludeArchived bool) ([]Group, error) { - values := url.Values{ - "token": {api.token}, - } - if excludeArchived { - values.Add("exclude_archived", "1") - } - - response, err := api.groupRequest(ctx, "groups.list", values) - if err != nil { - return nil, err - } - return response.Groups, nil -} - -// GetGroupInfo retrieves the given group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroupInfo(group string) (*Group, error) { - return api.GetGroupInfoContext(context.Background(), group) -} - -// GetGroupInfoContext retrieves the given group with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroupInfoContext(ctx context.Context, group string) (*Group, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - "include_locale": {strconv.FormatBool(true)}, - } - - response, err := api.groupRequest(ctx, "groups.info", values) - if err != nil { - return nil, err - } - return &response.Group, nil -} - -// SetGroupReadMark sets the read mark on a private group -// Clients should try to avoid making this call too often. When needing to mark a read position, a client should set a -// timer before making the call. In this way, any further updates needed during the timeout will not generate extra -// calls (just one per channel). This is useful for when reading scroll-back history, or following a busy live -// channel. A timeout of 5 seconds is a good starting point. Be sure to flush these calls on shutdown/logout. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetGroupReadMark(group, ts string) error { - return api.SetGroupReadMarkContext(context.Background(), group, ts) -} - -// SetGroupReadMarkContext sets the read mark on a private group with a custom context -// For more details see SetGroupReadMark -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetGroupReadMarkContext(ctx context.Context, group, ts string) (err error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - "ts": {ts}, - } - - _, err = api.groupRequest(ctx, "groups.mark", values) - return err -} - -// OpenGroup opens a private group -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) OpenGroup(group string) (bool, bool, error) { - return api.OpenGroupContext(context.Background(), group) -} - -// OpenGroupContext opens a private group with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) OpenGroupContext(ctx context.Context, group string) (bool, bool, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - } - - response, err := api.groupRequest(ctx, "groups.open", values) - if err != nil { - return false, false, err - } - return response.NoOp, response.AlreadyOpen, nil -} - -// RenameGroup renames a group -// XXX: They return a channel, not a group. What is this crap? :( -// Inconsistent api it seems. -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) RenameGroup(group, name string) (*Channel, error) { - return api.RenameGroupContext(context.Background(), group, name) -} - -// RenameGroupContext renames a group with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) RenameGroupContext(ctx context.Context, group, name string) (*Channel, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - "name": {name}, - } - - // XXX: the created entry in this call returns a string instead of a number - // so I may have to do some workaround to solve it. - response, err := api.groupRequest(ctx, "groups.rename", values) - if err != nil { - return nil, err - } - return &response.Channel, nil -} - -// SetGroupPurpose sets the group purpose -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetGroupPurpose(group, purpose string) (string, error) { - return api.SetGroupPurposeContext(context.Background(), group, purpose) -} - -// SetGroupPurposeContext sets the group purpose with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetGroupPurposeContext(ctx context.Context, group, purpose string) (string, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - "purpose": {purpose}, - } - - response, err := api.groupRequest(ctx, "groups.setPurpose", values) - if err != nil { - return "", err - } - return response.Purpose, nil -} - -// SetGroupTopic sets the group topic -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetGroupTopic(group, topic string) (string, error) { - return api.SetGroupTopicContext(context.Background(), group, topic) -} - -// SetGroupTopicContext sets the group topic with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) SetGroupTopicContext(ctx context.Context, group, topic string) (string, error) { - values := url.Values{ - "token": {api.token}, - "channel": {group}, - "topic": {topic}, - } - - response, err := api.groupRequest(ctx, "groups.setTopic", values) - if err != nil { - return "", err - } - return response.Topic, nil -} - -// GetGroupReplies gets an entire thread (a message plus all the messages in reply to it). -// see https://api.slack.com/methods/groups.replies -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroupReplies(channelID, thread_ts string) ([]Message, error) { - return api.GetGroupRepliesContext(context.Background(), channelID, thread_ts) -} - -// GetGroupRepliesContext gets an entire thread (a message plus all the messages in reply to it) with a custom context -// see https://api.slack.com/methods/groups.replies -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetGroupRepliesContext(ctx context.Context, channelID, thread_ts string) ([]Message, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channelID}, - "thread_ts": {thread_ts}, - } - response, err := api.groupRequest(ctx, "groups.replies", values) - if err != nil { - return nil, err - } - return response.History.Messages, nil -} diff --git a/vendor/github.com/slack-go/slack/im.go b/vendor/github.com/slack-go/slack/im.go index a884b295..7c4bc257 100644 --- a/vendor/github.com/slack-go/slack/im.go +++ b/vendor/github.com/slack-go/slack/im.go @@ -1,11 +1,5 @@ package slack -import ( - "context" - "net/url" - "strconv" -) - type imChannel struct { ID string `json:"id"` } @@ -21,200 +15,7 @@ type imResponseFull struct { } // IM contains information related to the Direct Message channel -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api type IM struct { Conversation IsUserDeleted bool `json:"is_user_deleted"` } - -func (api *Client) imRequest(ctx context.Context, path string, values url.Values) (*imResponseFull, error) { - response := &imResponseFull{} - err := api.postMethod(ctx, path, values, response) - if err != nil { - return nil, err - } - - return response, response.Err() -} - -// CloseIMChannel closes the direct message channel -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CloseIMChannel(channel string) (bool, bool, error) { - return api.CloseIMChannelContext(context.Background(), channel) -} - -// CloseIMChannelContext closes the direct message channel with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) CloseIMChannelContext(ctx context.Context, channel string) (bool, bool, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channel}, - } - - response, err := api.imRequest(ctx, "im.close", values) - if err != nil { - return false, false, err - } - return response.NoOp, response.AlreadyClosed, nil -} - -// OpenIMChannel opens a direct message channel to the user provided as argument -// Returns some status and the channel ID -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) OpenIMChannel(user string) (bool, bool, string, error) { - return api.OpenIMChannelContext(context.Background(), user) -} - -// OpenIMChannelContext opens a direct message channel to the user provided as argument with a custom context -// Returns some status and the channel ID -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) OpenIMChannelContext(ctx context.Context, user string) (bool, bool, string, error) { - values := url.Values{ - "token": {api.token}, - "user": {user}, - } - - response, err := api.imRequest(ctx, "im.open", values) - if err != nil { - return false, false, "", err - } - return response.NoOp, response.AlreadyOpen, response.Channel.ID, nil -} - -// MarkIMChannel sets the read mark of a direct message channel to a specific point -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) MarkIMChannel(channel, ts string) (err error) { - return api.MarkIMChannelContext(context.Background(), channel, ts) -} - -// MarkIMChannelContext sets the read mark of a direct message channel to a specific point with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) MarkIMChannelContext(ctx context.Context, channel, ts string) error { - values := url.Values{ - "token": {api.token}, - "channel": {channel}, - "ts": {ts}, - } - - _, err := api.imRequest(ctx, "im.mark", values) - return err -} - -// GetIMHistory retrieves the direct message channel history -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetIMHistory(channel string, params HistoryParameters) (*History, error) { - return api.GetIMHistoryContext(context.Background(), channel, params) -} - -// GetIMHistoryContext retrieves the direct message channel history with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetIMHistoryContext(ctx context.Context, channel string, params HistoryParameters) (*History, error) { - values := url.Values{ - "token": {api.token}, - "channel": {channel}, - } - if params.Latest != DEFAULT_HISTORY_LATEST { - values.Add("latest", params.Latest) - } - if params.Oldest != DEFAULT_HISTORY_OLDEST { - values.Add("oldest", params.Oldest) - } - if params.Count != DEFAULT_HISTORY_COUNT { - values.Add("count", strconv.Itoa(params.Count)) - } - if params.Inclusive != DEFAULT_HISTORY_INCLUSIVE { - if params.Inclusive { - values.Add("inclusive", "1") - } else { - values.Add("inclusive", "0") - } - } - if params.Unreads != DEFAULT_HISTORY_UNREADS { - if params.Unreads { - values.Add("unreads", "1") - } else { - values.Add("unreads", "0") - } - } - - response, err := api.imRequest(ctx, "im.history", values) - if err != nil { - return nil, err - } - return &response.History, nil -} - -// GetIMChannels returns the list of direct message channels -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetIMChannels() ([]IM, error) { - return api.GetIMChannelsContext(context.Background()) -} - -// GetIMChannelsContext returns the list of direct message channels with a custom context -// -// Deprecated: channels.*, groups.* im.* and mpim.* methods will be deprecated in the next version. -// In Slack, these API are no longer available for newly Apps created after June 10th, 2020. -// Also, existing applications will not be able to use these APIs after February 24th, 2021. -// -// See also: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api -func (api *Client) GetIMChannelsContext(ctx context.Context) ([]IM, error) { - values := url.Values{ - "token": {api.token}, - } - - response, err := api.imRequest(ctx, "im.list", values) - if err != nil { - return nil, err - } - return response.IMs, nil -} diff --git a/vendor/github.com/slack-go/slack/info.go b/vendor/github.com/slack-go/slack/info.go index ec706240..16fa667b 100644 --- a/vendor/github.com/slack-go/slack/info.go +++ b/vendor/github.com/slack-go/slack/info.go @@ -321,10 +321,9 @@ type UserPrefs struct { } func (api *Client) GetUserPrefs() (*UserPrefsCarrier, error) { - values := url.Values{"token": {api.token}} response := UserPrefsCarrier{} - err := api.getMethod(context.Background(), "users.prefs.get", values, &response) + err := api.getMethod(context.Background(), "users.prefs.get", api.token, url.Values{}, &response) if err != nil { return nil, err } diff --git a/vendor/github.com/slack-go/slack/interactions.go b/vendor/github.com/slack-go/slack/interactions.go index 2515e290..60d74704 100644 --- a/vendor/github.com/slack-go/slack/interactions.go +++ b/vendor/github.com/slack-go/slack/interactions.go @@ -9,11 +9,11 @@ import ( type InteractionType string // ActionType type represents the type of action (attachment, block, etc.) -type actionType string +type ActionType string // action is an interface that should be implemented by all callback action types type action interface { - actionType() actionType + actionType() ActionType } // Types of interactions that can be received. diff --git a/vendor/github.com/slack-go/slack/misc.go b/vendor/github.com/slack-go/slack/misc.go index 821bda86..8c50305b 100644 --- a/vendor/github.com/slack-go/slack/misc.go +++ b/vendor/github.com/slack-go/slack/misc.go @@ -135,7 +135,7 @@ func parseResponseBody(body io.ReadCloser, intf interface{}, d Debug) error { return json.Unmarshal(response, intf) } -func postLocalWithMultipartResponse(ctx context.Context, client httpClient, method, fpath, fieldname string, values url.Values, intf interface{}, d Debug) error { +func postLocalWithMultipartResponse(ctx context.Context, client httpClient, method, fpath, fieldname, token string, values url.Values, intf interface{}, d Debug) error { fullpath, err := filepath.Abs(fpath) if err != nil { return err @@ -146,10 +146,10 @@ func postLocalWithMultipartResponse(ctx context.Context, client httpClient, meth } defer file.Close() - return postWithMultipartResponse(ctx, client, method, filepath.Base(fpath), fieldname, values, file, intf, d) + return postWithMultipartResponse(ctx, client, method, filepath.Base(fpath), fieldname, token, values, file, intf, d) } -func postWithMultipartResponse(ctx context.Context, client httpClient, path, name, fieldname string, values url.Values, r io.Reader, intf interface{}, d Debug) error { +func postWithMultipartResponse(ctx context.Context, client httpClient, path, name, fieldname, token string, values url.Values, r io.Reader, intf interface{}, d Debug) error { pipeReader, pipeWriter := io.Pipe() wr := multipart.NewWriter(pipeWriter) errc := make(chan error) @@ -175,6 +175,7 @@ func postWithMultipartResponse(ctx context.Context, client httpClient, path, nam return err } req.Header.Add("Content-Type", wr.FormDataContentType()) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) req = req.WithContext(ctx) resp, err := client.Do(req) @@ -236,12 +237,14 @@ func postForm(ctx context.Context, client httpClient, endpoint string, values ur return doPost(ctx, client, req, newJSONParser(intf), d) } -func getResource(ctx context.Context, client httpClient, endpoint string, values url.Values, intf interface{}, d Debug) error { +func getResource(ctx context.Context, client httpClient, endpoint, token string, values url.Values, intf interface{}, d Debug) error { req, err := http.NewRequest("GET", endpoint, nil) if err != nil { return err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) + req.URL.RawQuery = values.Encode() return doPost(ctx, client, req, newJSONParser(intf), d) diff --git a/vendor/github.com/slack-go/slack/slack.go b/vendor/github.com/slack-go/slack/slack.go index 14367365..ea3aab6d 100644 --- a/vendor/github.com/slack-go/slack/slack.go +++ b/vendor/github.com/slack-go/slack/slack.go @@ -157,6 +157,6 @@ func (api *Client) postMethod(ctx context.Context, path string, values url.Value } // get a slack web method. -func (api *Client) getMethod(ctx context.Context, path string, values url.Values, intf interface{}) error { - return getResource(ctx, api.httpclient, api.endpoint+path, values, intf, api) +func (api *Client) getMethod(ctx context.Context, path string, token string, values url.Values, intf interface{}) error { + return getResource(ctx, api.httpclient, api.endpoint+path, token, values, intf, api) } diff --git a/vendor/github.com/slack-go/slack/users.go b/vendor/github.com/slack-go/slack/users.go index 82657d76..3696e37f 100644 --- a/vendor/github.com/slack-go/slack/users.go +++ b/vendor/github.com/slack-go/slack/users.go @@ -482,7 +482,7 @@ func (api *Client) SetUserPhotoContext(ctx context.Context, image string, params values.Add("crop_w", strconv.Itoa(params.CropW)) } - err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"users.setPhoto", image, "image", values, response, api) + err = postLocalWithMultipartResponse(ctx, api.httpclient, api.endpoint+"users.setPhoto", image, "image", api.token, values, response, api) if err != nil { return err } @@ -632,9 +632,15 @@ func (api *Client) UnsetUserCustomStatusContext(ctx context.Context) error { return api.SetUserCustomStatusContext(ctx, "", "", 0) } +// GetUserProfileParameters are the parameters required to get user profile +type GetUserProfileParameters struct { + UserID string + IncludeLabels bool +} + // GetUserProfile retrieves a user's profile information. -func (api *Client) GetUserProfile(userID string, includeLabels bool) (*UserProfile, error) { - return api.GetUserProfileContext(context.Background(), userID, includeLabels) +func (api *Client) GetUserProfile(params *GetUserProfileParameters) (*UserProfile, error) { + return api.GetUserProfileContext(context.Background(), params) } type getUserProfileResponse struct { @@ -643,13 +649,14 @@ type getUserProfileResponse struct { } // GetUserProfileContext retrieves a user's profile information with a context. -func (api *Client) GetUserProfileContext(ctx context.Context, userID string, includeLabels bool) (*UserProfile, error) { +func (api *Client) GetUserProfileContext(ctx context.Context, params *GetUserProfileParameters) (*UserProfile, error) { values := url.Values{"token": {api.token}} - if includeLabels { - values.Add("include_labels", "true") + + if params.UserID != "" { + values.Add("user", params.UserID) } - if userID != "" { - values.Add("user", userID) + if params.IncludeLabels { + values.Add("include_labels", "true") } resp := &getUserProfileResponse{} diff --git a/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go b/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go index eb3157f0..e15b7bf6 100644 --- a/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go +++ b/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go @@ -57,7 +57,7 @@ loop: err = transform.ErrShortSrc break loop } - r = utf8.RuneError + r, size = utf8.RuneError, 1 goto write } size = 2 diff --git a/vendor/golang.org/x/text/internal/language/parse.go b/vendor/golang.org/x/text/internal/language/parse.go index 2be83e1d..a2fdad89 100644 --- a/vendor/golang.org/x/text/internal/language/parse.go +++ b/vendor/golang.org/x/text/internal/language/parse.go @@ -133,14 +133,15 @@ func (s *scanner) resizeRange(oldStart, oldEnd, newSize int) { s.start = oldStart if end := oldStart + newSize; end != oldEnd { diff := end - oldEnd - if end < cap(s.b) { - b := make([]byte, len(s.b)+diff) + var b []byte + if n := len(s.b) + diff; n > cap(s.b) { + b = make([]byte, n) copy(b, s.b[:oldStart]) - copy(b[end:], s.b[oldEnd:]) - s.b = b } else { - s.b = append(s.b[end:], s.b[oldEnd:]...) + b = s.b[:n:n] } + copy(b[end:], s.b[oldEnd:]) + s.b = b s.next = end + (s.next - s.end) s.end = end } diff --git a/vendor/golang.org/x/text/unicode/bidi/bidi.go b/vendor/golang.org/x/text/unicode/bidi/bidi.go index e8edc54c..fd057601 100644 --- a/vendor/golang.org/x/text/unicode/bidi/bidi.go +++ b/vendor/golang.org/x/text/unicode/bidi/bidi.go @@ -12,15 +12,14 @@ // and without notice. package bidi // import "golang.org/x/text/unicode/bidi" -// TODO: -// The following functionality would not be hard to implement, but hinges on -// the definition of a Segmenter interface. For now this is up to the user. -// - Iterate over paragraphs -// - Segmenter to iterate over runs directly from a given text. -// Also: +// TODO // - Transformer for reordering? // - Transformer (validator, really) for Bidi Rule. +import ( + "bytes" +) + // This API tries to avoid dealing with embedding levels for now. Under the hood // these will be computed, but the question is to which extent the user should // know they exist. We should at some point allow the user to specify an @@ -49,7 +48,9 @@ const ( Neutral ) -type options struct{} +type options struct { + defaultDirection Direction +} // An Option is an option for Bidi processing. type Option func(*options) @@ -66,12 +67,62 @@ type Option func(*options) // DefaultDirection sets the default direction for a Paragraph. The direction is // overridden if the text contains directional characters. func DefaultDirection(d Direction) Option { - panic("unimplemented") + return func(opts *options) { + opts.defaultDirection = d + } } // A Paragraph holds a single Paragraph for Bidi processing. type Paragraph struct { - // buffers + p []byte + o Ordering + opts []Option + types []Class + pairTypes []bracketType + pairValues []rune + runes []rune + options options +} + +// Initialize the p.pairTypes, p.pairValues and p.types from the input previously +// set by p.SetBytes() or p.SetString(). Also limit the input up to (and including) a paragraph +// separator (bidi class B). +// +// The function p.Order() needs these values to be set, so this preparation could be postponed. +// But since the SetBytes and SetStrings functions return the length of the input up to the paragraph +// separator, the whole input needs to be processed anyway and should not be done twice. +// +// The function has the same return values as SetBytes() / SetString() +func (p *Paragraph) prepareInput() (n int, err error) { + p.runes = bytes.Runes(p.p) + bytecount := 0 + // clear slices from previous SetString or SetBytes + p.pairTypes = nil + p.pairValues = nil + p.types = nil + + for _, r := range p.runes { + props, i := LookupRune(r) + bytecount += i + cls := props.Class() + if cls == B { + return bytecount, nil + } + p.types = append(p.types, cls) + if props.IsOpeningBracket() { + p.pairTypes = append(p.pairTypes, bpOpen) + p.pairValues = append(p.pairValues, r) + } else if props.IsBracket() { + // this must be a closing bracket, + // since IsOpeningBracket is not true + p.pairTypes = append(p.pairTypes, bpClose) + p.pairValues = append(p.pairValues, r) + } else { + p.pairTypes = append(p.pairTypes, bpNone) + p.pairValues = append(p.pairValues, 0) + } + } + return bytecount, nil } // SetBytes configures p for the given paragraph text. It replaces text @@ -80,70 +131,150 @@ type Paragraph struct { // consumed from b including this separator. Error may be non-nil if options are // given. func (p *Paragraph) SetBytes(b []byte, opts ...Option) (n int, err error) { - panic("unimplemented") + p.p = b + p.opts = opts + return p.prepareInput() } -// SetString configures p for the given paragraph text. It replaces text -// previously set by SetBytes or SetString. If b contains a paragraph separator +// SetString configures s for the given paragraph text. It replaces text +// previously set by SetBytes or SetString. If s contains a paragraph separator // it will only process the first paragraph and report the number of bytes -// consumed from b including this separator. Error may be non-nil if options are +// consumed from s including this separator. Error may be non-nil if options are // given. func (p *Paragraph) SetString(s string, opts ...Option) (n int, err error) { - panic("unimplemented") + p.p = []byte(s) + p.opts = opts + return p.prepareInput() } // IsLeftToRight reports whether the principle direction of rendering for this // paragraphs is left-to-right. If this returns false, the principle direction // of rendering is right-to-left. func (p *Paragraph) IsLeftToRight() bool { - panic("unimplemented") + return p.Direction() == LeftToRight } // Direction returns the direction of the text of this paragraph. // // The direction may be LeftToRight, RightToLeft, Mixed, or Neutral. func (p *Paragraph) Direction() Direction { - panic("unimplemented") + return p.o.Direction() } +// TODO: what happens if the position is > len(input)? This should return an error. + // RunAt reports the Run at the given position of the input text. // // This method can be used for computing line breaks on paragraphs. func (p *Paragraph) RunAt(pos int) Run { - panic("unimplemented") + c := 0 + runNumber := 0 + for i, r := range p.o.runes { + c += len(r) + if pos < c { + runNumber = i + } + } + return p.o.Run(runNumber) +} + +func calculateOrdering(levels []level, runes []rune) Ordering { + var curDir Direction + + prevDir := Neutral + prevI := 0 + + o := Ordering{} + // lvl = 0,2,4,...: left to right + // lvl = 1,3,5,...: right to left + for i, lvl := range levels { + if lvl%2 == 0 { + curDir = LeftToRight + } else { + curDir = RightToLeft + } + if curDir != prevDir { + if i > 0 { + o.runes = append(o.runes, runes[prevI:i]) + o.directions = append(o.directions, prevDir) + o.startpos = append(o.startpos, prevI) + } + prevI = i + prevDir = curDir + } + } + o.runes = append(o.runes, runes[prevI:]) + o.directions = append(o.directions, prevDir) + o.startpos = append(o.startpos, prevI) + return o } // Order computes the visual ordering of all the runs in a Paragraph. func (p *Paragraph) Order() (Ordering, error) { - panic("unimplemented") + if len(p.types) == 0 { + return Ordering{}, nil + } + + for _, fn := range p.opts { + fn(&p.options) + } + lvl := level(-1) + if p.options.defaultDirection == RightToLeft { + lvl = 1 + } + para, err := newParagraph(p.types, p.pairTypes, p.pairValues, lvl) + if err != nil { + return Ordering{}, err + } + + levels := para.getLevels([]int{len(p.types)}) + + p.o = calculateOrdering(levels, p.runes) + return p.o, nil } // Line computes the visual ordering of runs for a single line starting and // ending at the given positions in the original text. func (p *Paragraph) Line(start, end int) (Ordering, error) { - panic("unimplemented") + lineTypes := p.types[start:end] + para, err := newParagraph(lineTypes, p.pairTypes[start:end], p.pairValues[start:end], -1) + if err != nil { + return Ordering{}, err + } + levels := para.getLevels([]int{len(lineTypes)}) + o := calculateOrdering(levels, p.runes[start:end]) + return o, nil } // An Ordering holds the computed visual order of runs of a Paragraph. Calling // SetBytes or SetString on the originating Paragraph invalidates an Ordering. // The methods of an Ordering should only be called by one goroutine at a time. -type Ordering struct{} +type Ordering struct { + runes [][]rune + directions []Direction + startpos []int +} // Direction reports the directionality of the runs. // // The direction may be LeftToRight, RightToLeft, Mixed, or Neutral. func (o *Ordering) Direction() Direction { - panic("unimplemented") + return o.directions[0] } // NumRuns returns the number of runs. func (o *Ordering) NumRuns() int { - panic("unimplemented") + return len(o.runes) } // Run returns the ith run within the ordering. func (o *Ordering) Run(i int) Run { - panic("unimplemented") + r := Run{ + runes: o.runes[i], + direction: o.directions[i], + startpos: o.startpos[i], + } + return r } // TODO: perhaps with options. @@ -155,16 +286,19 @@ func (o *Ordering) Run(i int) Run { // A Run is a continuous sequence of characters of a single direction. type Run struct { + runes []rune + direction Direction + startpos int } // String returns the text of the run in its original order. func (r *Run) String() string { - panic("unimplemented") + return string(r.runes) } // Bytes returns the text of the run in its original order. func (r *Run) Bytes() []byte { - panic("unimplemented") + return []byte(r.String()) } // TODO: methods for @@ -174,25 +308,52 @@ func (r *Run) Bytes() []byte { // Direction reports the direction of the run. func (r *Run) Direction() Direction { - panic("unimplemented") + return r.direction } -// Position of the Run within the text passed to SetBytes or SetString of the +// Pos returns the position of the Run within the text passed to SetBytes or SetString of the // originating Paragraph value. func (r *Run) Pos() (start, end int) { - panic("unimplemented") + return r.startpos, r.startpos + len(r.runes) - 1 } // AppendReverse reverses the order of characters of in, appends them to out, // and returns the result. Modifiers will still follow the runes they modify. // Brackets are replaced with their counterparts. func AppendReverse(out, in []byte) []byte { - panic("unimplemented") + ret := make([]byte, len(in)+len(out)) + copy(ret, out) + inRunes := bytes.Runes(in) + + for i, r := range inRunes { + prop, _ := LookupRune(r) + if prop.IsBracket() { + inRunes[i] = prop.reverseBracket(r) + } + } + + for i, j := 0, len(inRunes)-1; i < j; i, j = i+1, j-1 { + inRunes[i], inRunes[j] = inRunes[j], inRunes[i] + } + copy(ret[len(out):], string(inRunes)) + + return ret } // ReverseString reverses the order of characters in s and returns a new string. // Modifiers will still follow the runes they modify. Brackets are replaced with // their counterparts. func ReverseString(s string) string { - panic("unimplemented") + input := []rune(s) + li := len(input) + ret := make([]rune, li) + for i, r := range input { + prop, _ := LookupRune(r) + if prop.IsBracket() { + ret[li-i-1] = prop.reverseBracket(r) + } else { + ret[li-i-1] = r + } + } + return string(ret) } diff --git a/vendor/golang.org/x/text/unicode/bidi/core.go b/vendor/golang.org/x/text/unicode/bidi/core.go index 50deb660..e4c08110 100644 --- a/vendor/golang.org/x/text/unicode/bidi/core.go +++ b/vendor/golang.org/x/text/unicode/bidi/core.go @@ -4,7 +4,10 @@ package bidi -import "log" +import ( + "fmt" + "log" +) // This implementation is a port based on the reference implementation found at: // https://www.unicode.org/Public/PROGRAMS/BidiReferenceJava/ @@ -97,13 +100,20 @@ type paragraph struct { // rune (suggested is the rune of the open bracket for opening and matching // close brackets, after normalization). The embedding levels are optional, but // may be supplied to encode embedding levels of styled text. -// -// TODO: return an error. -func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, levels level) *paragraph { - validateTypes(types) - validatePbTypes(pairTypes) - validatePbValues(pairValues, pairTypes) - validateParagraphEmbeddingLevel(levels) +func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, levels level) (*paragraph, error) { + var err error + if err = validateTypes(types); err != nil { + return nil, err + } + if err = validatePbTypes(pairTypes); err != nil { + return nil, err + } + if err = validatePbValues(pairValues, pairTypes); err != nil { + return nil, err + } + if err = validateParagraphEmbeddingLevel(levels); err != nil { + return nil, err + } p := ¶graph{ initialTypes: append([]Class(nil), types...), @@ -115,7 +125,7 @@ func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, lev resultTypes: append([]Class(nil), types...), } p.run() - return p + return p, nil } func (p *paragraph) Len() int { return len(p.initialTypes) } @@ -1001,58 +1011,61 @@ func typeForLevel(level level) Class { return R } -// TODO: change validation to not panic - -func validateTypes(types []Class) { +func validateTypes(types []Class) error { if len(types) == 0 { - log.Panic("types is null") + return fmt.Errorf("types is null") } for i, t := range types[:len(types)-1] { if t == B { - log.Panicf("B type before end of paragraph at index: %d", i) + return fmt.Errorf("B type before end of paragraph at index: %d", i) } } + return nil } -func validateParagraphEmbeddingLevel(embeddingLevel level) { +func validateParagraphEmbeddingLevel(embeddingLevel level) error { if embeddingLevel != implicitLevel && embeddingLevel != 0 && embeddingLevel != 1 { - log.Panicf("illegal paragraph embedding level: %d", embeddingLevel) + return fmt.Errorf("illegal paragraph embedding level: %d", embeddingLevel) } + return nil } -func validateLineBreaks(linebreaks []int, textLength int) { +func validateLineBreaks(linebreaks []int, textLength int) error { prev := 0 for i, next := range linebreaks { if next <= prev { - log.Panicf("bad linebreak: %d at index: %d", next, i) + return fmt.Errorf("bad linebreak: %d at index: %d", next, i) } prev = next } if prev != textLength { - log.Panicf("last linebreak was %d, want %d", prev, textLength) + return fmt.Errorf("last linebreak was %d, want %d", prev, textLength) } + return nil } -func validatePbTypes(pairTypes []bracketType) { +func validatePbTypes(pairTypes []bracketType) error { if len(pairTypes) == 0 { - log.Panic("pairTypes is null") + return fmt.Errorf("pairTypes is null") } for i, pt := range pairTypes { switch pt { case bpNone, bpOpen, bpClose: default: - log.Panicf("illegal pairType value at %d: %v", i, pairTypes[i]) + return fmt.Errorf("illegal pairType value at %d: %v", i, pairTypes[i]) } } + return nil } -func validatePbValues(pairValues []rune, pairTypes []bracketType) { +func validatePbValues(pairValues []rune, pairTypes []bracketType) error { if pairValues == nil { - log.Panic("pairValues is null") + return fmt.Errorf("pairValues is null") } if len(pairTypes) != len(pairValues) { - log.Panic("pairTypes is different length from pairValues") + return fmt.Errorf("pairTypes is different length from pairValues") } + return nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index d83d4732..b94a1791 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -28,7 +28,7 @@ github.com/Rhymen/go-whatsapp/binary/token github.com/Rhymen/go-whatsapp/crypto/cbc github.com/Rhymen/go-whatsapp/crypto/curve25519 github.com/Rhymen/go-whatsapp/crypto/hkdf -# github.com/SevereCloud/vksdk/v2 v2.9.0 +# github.com/SevereCloud/vksdk/v2 v2.9.1 ## explicit github.com/SevereCloud/vksdk/v2 github.com/SevereCloud/vksdk/v2/api @@ -67,13 +67,13 @@ github.com/go-telegram-bot-api/telegram-bot-api # github.com/golang/protobuf v1.4.2 github.com/golang/protobuf/proto github.com/golang/protobuf/protoc-gen-go/descriptor -# github.com/gomarkdown/markdown v0.0.0-20210208175418-bda154fe17d8 +# github.com/gomarkdown/markdown v0.0.0-20210408062403-ad838ccf8cdd ## explicit github.com/gomarkdown/markdown github.com/gomarkdown/markdown/ast github.com/gomarkdown/markdown/html github.com/gomarkdown/markdown/parser -# github.com/google/gops v0.3.17 +# github.com/google/gops v0.3.18 ## explicit github.com/google/gops/agent github.com/google/gops/internal @@ -121,7 +121,7 @@ github.com/keybase/go-keybase-chat-bot/kbchat/types/stellar1 # github.com/kyokomi/emoji/v2 v2.2.8 ## explicit github.com/kyokomi/emoji/v2 -# github.com/labstack/echo/v4 v4.2.1 +# github.com/labstack/echo/v4 v4.2.2 ## explicit github.com/labstack/echo/v4 github.com/labstack/echo/v4/middleware @@ -242,7 +242,7 @@ 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.8.2 +# github.com/slack-go/slack v0.9.0 ## explicit github.com/slack-go/slack github.com/slack-go/slack/internal/backoff @@ -352,7 +352,7 @@ golang.org/x/net/http2/h2c golang.org/x/net/http2/hpack golang.org/x/net/idna golang.org/x/net/websocket -# golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 +# golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c ## explicit golang.org/x/oauth2 golang.org/x/oauth2/clientcredentials @@ -363,7 +363,7 @@ golang.org/x/sys/cpu golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/text v0.3.4 +# golang.org/x/text v0.3.5 golang.org/x/text/encoding golang.org/x/text/encoding/charmap golang.org/x/text/encoding/internal |