summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack
diff options
context:
space:
mode:
authorWim <wim@42.be>2021-02-01 21:29:04 +0100
committerGitHub <noreply@github.com>2021-02-01 21:29:04 +0100
commit0452be0cb383ff560e340b643b60a35c6e228639 (patch)
tree41b91af43c2e321d6498a6b56594b1d0c71c516e /vendor/github.com/slack-go/slack
parent1624f107739b8ed7b142732430e5295764388de2 (diff)
downloadmatterbridge-msglm-0452be0cb383ff560e340b643b60a35c6e228639.tar.gz
matterbridge-msglm-0452be0cb383ff560e340b643b60a35c6e228639.tar.bz2
matterbridge-msglm-0452be0cb383ff560e340b643b60a35c6e228639.zip
Update vendor (#1384)
Diffstat (limited to 'vendor/github.com/slack-go/slack')
-rw-r--r--vendor/github.com/slack-go/slack/.gometalinter.json14
-rw-r--r--vendor/github.com/slack-go/slack/apps.go18
-rw-r--r--vendor/github.com/slack-go/slack/block.go2
-rw-r--r--vendor/github.com/slack-go/slack/block_conv.go13
-rw-r--r--vendor/github.com/slack-go/slack/block_element.go36
-rw-r--r--vendor/github.com/slack-go/slack/block_object.go2
-rw-r--r--vendor/github.com/slack-go/slack/chat.go48
-rw-r--r--vendor/github.com/slack-go/slack/internal/backoff/backoff.go (renamed from vendor/github.com/slack-go/slack/backoff.go)13
-rw-r--r--vendor/github.com/slack-go/slack/internal/misc/misc.go28
-rw-r--r--vendor/github.com/slack-go/slack/misc.go26
-rw-r--r--vendor/github.com/slack-go/slack/socket_mode.go34
-rw-r--r--vendor/github.com/slack-go/slack/users.go1
-rw-r--r--vendor/github.com/slack-go/slack/websocket_managed_conn.go13
13 files changed, 199 insertions, 49 deletions
diff --git a/vendor/github.com/slack-go/slack/.gometalinter.json b/vendor/github.com/slack-go/slack/.gometalinter.json
deleted file mode 100644
index 5fa629d4..00000000
--- a/vendor/github.com/slack-go/slack/.gometalinter.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "DisableAll": true,
- "Enable": [
- "structcheck",
- "vet",
- "misspell",
- "unconvert",
- "interfacer",
- "goimports"
- ],
- "Vendor": true,
- "Exclude": ["vendor"],
- "Deadline": "300s"
-}
diff --git a/vendor/github.com/slack-go/slack/apps.go b/vendor/github.com/slack-go/slack/apps.go
index cb26ad8e..d9749438 100644
--- a/vendor/github.com/slack-go/slack/apps.go
+++ b/vendor/github.com/slack-go/slack/apps.go
@@ -3,6 +3,7 @@ package slack
import (
"context"
"encoding/json"
+ "net/url"
)
type listEventAuthorizationsResponse struct {
@@ -41,3 +42,20 @@ func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventCont
return resp.Authorizations, nil
}
+
+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)
+ if err != nil {
+ return err
+ }
+
+ return response.Err()
+}
diff --git a/vendor/github.com/slack-go/slack/block.go b/vendor/github.com/slack-go/slack/block.go
index dd4b8715..9946a294 100644
--- a/vendor/github.com/slack-go/slack/block.go
+++ b/vendor/github.com/slack-go/slack/block.go
@@ -48,11 +48,13 @@ type BlockAction struct {
SelectedConversation string `json:"selected_conversation"`
SelectedConversations []string `json:"selected_conversations"`
SelectedDate string `json:"selected_date"`
+ SelectedTime string `json:"selected_time"`
InitialOption OptionBlockObject `json:"initial_option"`
InitialUser string `json:"initial_user"`
InitialChannel string `json:"initial_channel"`
InitialConversation string `json:"initial_conversation"`
InitialDate string `json:"initial_date"`
+ InitialTime string `json:"initial_time"`
}
// actionType returns the type of the action
diff --git a/vendor/github.com/slack-go/slack/block_conv.go b/vendor/github.com/slack-go/slack/block_conv.go
index 656a9ab1..f2d744c4 100644
--- a/vendor/github.com/slack-go/slack/block_conv.go
+++ b/vendor/github.com/slack-go/slack/block_conv.go
@@ -59,6 +59,8 @@ func (b *Blocks) UnmarshalJSON(data []byte) error {
block = &DividerBlock{}
case "file":
block = &FileBlock{}
+ case "header":
+ block = &HeaderBlock{}
case "image":
block = &ImageBlock{}
case "input":
@@ -105,6 +107,8 @@ func (b *InputBlock) UnmarshalJSON(data []byte) error {
switch s.TypeVal {
case "datepicker":
e = &DatePickerBlockElement{}
+ case "timepicker":
+ e = &TimePickerBlockElement{}
case "plain_text_input":
e = &PlainTextInputBlockElement{}
case "static_select", "external_select", "users_select", "conversations_select", "channels_select":
@@ -262,6 +266,12 @@ func (a *Accessory) UnmarshalJSON(data []byte) error {
return err
}
a.DatePickerElement = element.(*DatePickerBlockElement)
+ case "timepicker":
+ element, err := unmarshalBlockElement(r, &TimePickerBlockElement{})
+ if err != nil {
+ return err
+ }
+ a.TimePickerElement = element.(*TimePickerBlockElement)
case "plain_text_input":
element, err := unmarshalBlockElement(r, &PlainTextInputBlockElement{})
if err != nil {
@@ -324,6 +334,9 @@ func toBlockElement(element *Accessory) BlockElement {
if element.DatePickerElement != nil {
return element.DatePickerElement
}
+ if element.TimePickerElement != nil {
+ return element.TimePickerElement
+ }
if element.PlainTextInputElement != nil {
return element.PlainTextInputElement
}
diff --git a/vendor/github.com/slack-go/slack/block_element.go b/vendor/github.com/slack-go/slack/block_element.go
index 91b6adc4..4157016c 100644
--- a/vendor/github.com/slack-go/slack/block_element.go
+++ b/vendor/github.com/slack-go/slack/block_element.go
@@ -8,6 +8,7 @@ const (
METButton MessageElementType = "button"
METOverflow MessageElementType = "overflow"
METDatepicker MessageElementType = "datepicker"
+ METTimepicker MessageElementType = "timepicker"
METPlainTextInput MessageElementType = "plain_text_input"
METRadioButtons MessageElementType = "radio_buttons"
@@ -44,6 +45,7 @@ type Accessory struct {
ButtonElement *ButtonBlockElement
OverflowElement *OverflowBlockElement
DatePickerElement *DatePickerBlockElement
+ TimePickerElement *TimePickerBlockElement
PlainTextInputElement *PlainTextInputBlockElement
RadioButtonsElement *RadioButtonsBlockElement
SelectElement *SelectBlockElement
@@ -63,6 +65,8 @@ func NewAccessory(element BlockElement) *Accessory {
return &Accessory{OverflowElement: element.(*OverflowBlockElement)}
case *DatePickerBlockElement:
return &Accessory{DatePickerElement: element.(*DatePickerBlockElement)}
+ case *TimePickerBlockElement:
+ return &Accessory{TimePickerElement: element.(*TimePickerBlockElement)}
case *PlainTextInputBlockElement:
return &Accessory{PlainTextInputElement: element.(*PlainTextInputBlockElement)}
case *RadioButtonsBlockElement:
@@ -127,10 +131,12 @@ func NewImageBlockElement(imageURL, altText string) *ImageBlockElement {
}
}
+// Style is a style of Button element
+// https://api.slack.com/reference/block-kit/block-elements#button__fields
type Style string
const (
- StyleDefault Style = "default"
+ StyleDefault Style = ""
StylePrimary Style = "primary"
StyleDanger Style = "danger"
)
@@ -155,7 +161,7 @@ func (s ButtonBlockElement) ElementType() MessageElementType {
return s.Type
}
-// WithStyling adds styling to the button object and returns the modified ButtonBlockElement
+// WithStyle adds styling to the button object and returns the modified ButtonBlockElement
func (s *ButtonBlockElement) WithStyle(style Style) *ButtonBlockElement {
s.Style = style
return s
@@ -350,6 +356,32 @@ func NewDatePickerBlockElement(actionID string) *DatePickerBlockElement {
}
}
+// TimePickerBlockElement defines an element which lets users easily select a
+// time from nice UI. Time picker elements can be used inside of
+// section and actions blocks.
+//
+// More Information: https://api.slack.com/reference/messaging/block-elements#timepicker
+type TimePickerBlockElement struct {
+ Type MessageElementType `json:"type"`
+ ActionID string `json:"action_id,omitempty"`
+ Placeholder *TextBlockObject `json:"placeholder,omitempty"`
+ InitialTime string `json:"initial_time,omitempty"`
+ Confirm *ConfirmationBlockObject `json:"confirm,omitempty"`
+}
+
+// ElementType returns the type of the Element
+func (s TimePickerBlockElement) ElementType() MessageElementType {
+ return s.Type
+}
+
+// NewTimePickerBlockElement returns an instance of a date picker element
+func NewTimePickerBlockElement(actionID string) *TimePickerBlockElement {
+ return &TimePickerBlockElement{
+ Type: METTimepicker,
+ ActionID: actionID,
+ }
+}
+
// PlainTextInputBlockElement creates a field where a user can enter freeform
// data.
// Plain-text input elements are currently only available in modals.
diff --git a/vendor/github.com/slack-go/slack/block_object.go b/vendor/github.com/slack-go/slack/block_object.go
index cc510b21..d17806ca 100644
--- a/vendor/github.com/slack-go/slack/block_object.go
+++ b/vendor/github.com/slack-go/slack/block_object.go
@@ -171,7 +171,7 @@ func (s ConfirmationBlockObject) validateType() MessageObjectType {
return motConfirmation
}
-// add styling to confirmation object
+// WithStyle add styling to confirmation object
func (s *ConfirmationBlockObject) WithStyle(style Style) {
s.Style = style
}
diff --git a/vendor/github.com/slack-go/slack/chat.go b/vendor/github.com/slack-go/slack/chat.go
index 439f9373..f5b80346 100644
--- a/vendor/github.com/slack-go/slack/chat.go
+++ b/vendor/github.com/slack-go/slack/chat.go
@@ -191,6 +191,22 @@ func (api *Client) UnfurlMessage(channelID, timestamp string, unfurls map[string
return api.SendMessageContext(context.Background(), channelID, MsgOptionUnfurl(timestamp, unfurls), MsgOptionCompose(options...))
}
+// UnfurlMessageWithAuthURL sends an unfurl request containing an
+// authentication URL.
+// For more details see:
+// https://api.slack.com/reference/messaging/link-unfurling#authenticated_unfurls
+func (api *Client) UnfurlMessageWithAuthURL(channelID, timestamp string, userAuthURL string, options ...MsgOption) (string, string, string, error) {
+ return api.UnfurlMessageWithAuthURLContext(context.Background(), channelID, timestamp, userAuthURL, options...)
+}
+
+// UnfurlMessageWithAuthURLContext sends an unfurl request containing an
+// authentication URL.
+// For more details see:
+// https://api.slack.com/reference/messaging/link-unfurling#authenticated_unfurls
+func (api *Client) UnfurlMessageWithAuthURLContext(ctx context.Context, channelID, timestamp string, userAuthURL string, options ...MsgOption) (string, string, string, error) {
+ return api.SendMessageContext(ctx, channelID, MsgOptionUnfurlAuthURL(timestamp, userAuthURL), MsgOptionCompose(options...))
+}
+
// SendMessage more flexible method for configuring messages.
func (api *Client) SendMessage(channel string, options ...MsgOption) (string, string, string, error) {
return api.SendMessageContext(context.Background(), channel, options...)
@@ -413,6 +429,38 @@ func MsgOptionUnfurl(timestamp string, unfurls map[string]Attachment) MsgOption
}
}
+// MsgOptionUnfurlAuthURL unfurls a message using an auth url based on the timestamp.
+func MsgOptionUnfurlAuthURL(timestamp string, userAuthURL string) MsgOption {
+ return func(config *sendConfig) error {
+ config.endpoint = config.apiurl + string(chatUnfurl)
+ config.values.Add("ts", timestamp)
+ config.values.Add("user_auth_url", userAuthURL)
+ return nil
+ }
+}
+
+// MsgOptionUnfurlAuthRequired requests that the user installs the
+// Slack app for unfurling.
+func MsgOptionUnfurlAuthRequired(timestamp string) MsgOption {
+ return func(config *sendConfig) error {
+ config.endpoint = config.apiurl + string(chatUnfurl)
+ config.values.Add("ts", timestamp)
+ config.values.Add("user_auth_required", "true")
+ return nil
+ }
+}
+
+// MsgOptionUnfurlAuthMessage attaches a message inviting the user to
+// authenticate.
+func MsgOptionUnfurlAuthMessage(timestamp string, msg string) MsgOption {
+ return func(config *sendConfig) error {
+ config.endpoint = config.apiurl + string(chatUnfurl)
+ config.values.Add("ts", timestamp)
+ config.values.Add("user_auth_message", msg)
+ return nil
+ }
+}
+
// MsgOptionResponseURL supplies a url to use as the endpoint.
func MsgOptionResponseURL(url string, responseType string) MsgOption {
return func(config *sendConfig) error {
diff --git a/vendor/github.com/slack-go/slack/backoff.go b/vendor/github.com/slack-go/slack/internal/backoff/backoff.go
index 2ba697e7..df210f80 100644
--- a/vendor/github.com/slack-go/slack/backoff.go
+++ b/vendor/github.com/slack-go/slack/internal/backoff/backoff.go
@@ -1,4 +1,4 @@
-package slack
+package backoff
import (
"math/rand"
@@ -11,7 +11,7 @@ import (
// call to Duration() it is multiplied by Factor. It is capped at
// Max. It returns to Min on every call to Reset(). Used in
// conjunction with the time package.
-type backoff struct {
+type Backoff struct {
attempts int
// Initial value to scale out
Initial time.Duration
@@ -23,7 +23,7 @@ type backoff struct {
// Returns the current value of the counter and then multiplies it
// Factor
-func (b *backoff) Duration() (dur time.Duration) {
+func (b *Backoff) Duration() (dur time.Duration) {
// Zero-values are nonsensical, so we use
// them to apply defaults
if b.Max == 0 {
@@ -52,6 +52,11 @@ func (b *backoff) Duration() (dur time.Duration) {
}
//Resets the current value of the counter back to Min
-func (b *backoff) Reset() {
+func (b *Backoff) Reset() {
b.attempts = 0
}
+
+// Attempts returns the number of attempts that we had done so far
+func (b *Backoff) Attempts() int {
+ return b.attempts
+}
diff --git a/vendor/github.com/slack-go/slack/internal/misc/misc.go b/vendor/github.com/slack-go/slack/internal/misc/misc.go
new file mode 100644
index 00000000..eab8cdd8
--- /dev/null
+++ b/vendor/github.com/slack-go/slack/internal/misc/misc.go
@@ -0,0 +1,28 @@
+package misc
+
+import (
+ "fmt"
+ "net/http"
+)
+
+// StatusCodeError represents an http response error.
+// type httpStatusCode interface { HTTPStatusCode() int } to handle it.
+type StatusCodeError struct {
+ Code int
+ Status string
+}
+
+func (t StatusCodeError) Error() string {
+ return fmt.Sprintf("slack server error: %s", t.Status)
+}
+
+func (t StatusCodeError) HTTPStatusCode() int {
+ return t.Code
+}
+
+func (t StatusCodeError) Retryable() bool {
+ if t.Code >= 500 || t.Code == http.StatusTooManyRequests {
+ return true
+ }
+ return false
+}
diff --git a/vendor/github.com/slack-go/slack/misc.go b/vendor/github.com/slack-go/slack/misc.go
index 336f0afb..821bda86 100644
--- a/vendor/github.com/slack-go/slack/misc.go
+++ b/vendor/github.com/slack-go/slack/misc.go
@@ -18,6 +18,8 @@ import (
"strconv"
"strings"
"time"
+
+ "github.com/slack-go/slack/internal/misc"
)
// SlackResponse handles parsing out errors from the web api.
@@ -42,28 +44,6 @@ func (t SlackResponse) Err() error {
return errors.New(t.Error)
}
-// StatusCodeError represents an http response error.
-// type httpStatusCode interface { HTTPStatusCode() int } to handle it.
-type statusCodeError struct {
- Code int
- Status string
-}
-
-func (t statusCodeError) Error() string {
- return fmt.Sprintf("slack server error: %s", t.Status)
-}
-
-func (t statusCodeError) HTTPStatusCode() int {
- return t.Code
-}
-
-func (t statusCodeError) Retryable() bool {
- if t.Code >= 500 || t.Code == http.StatusTooManyRequests {
- return true
- }
- return false
-}
-
// RateLimitedError represents the rate limit respond from slack
type RateLimitedError struct {
RetryAfter time.Duration
@@ -312,7 +292,7 @@ func checkStatusCode(resp *http.Response, d Debug) error {
// Slack seems to send an HTML body along with 5xx error codes. Don't parse it.
if resp.StatusCode != http.StatusOK {
logResponse(resp, d)
- return statusCodeError{Code: resp.StatusCode, Status: resp.Status}
+ return misc.StatusCodeError{Code: resp.StatusCode, Status: resp.Status}
}
return nil
diff --git a/vendor/github.com/slack-go/slack/socket_mode.go b/vendor/github.com/slack-go/slack/socket_mode.go
new file mode 100644
index 00000000..69e40d99
--- /dev/null
+++ b/vendor/github.com/slack-go/slack/socket_mode.go
@@ -0,0 +1,34 @@
+package slack
+
+import (
+ "context"
+)
+
+// SocketModeConnection contains various details about the SocketMode connection.
+// It is returned by an "apps.connections.open" API call.
+type SocketModeConnection struct {
+ URL string `json:"url,omitempty"`
+ Data map[string]interface{} `json:"-"`
+}
+
+type openResponseFull struct {
+ SlackResponse
+ SocketModeConnection
+}
+
+// StartSocketModeContext calls the "apps.connections.open" endpoint and returns the provided URL and the full Info block with a custom context.
+//
+// To have a fully managed Socket Mode connection, use `socketmode.New()`, and call `Run()` on it.
+func (api *Client) StartSocketModeContext(ctx context.Context) (info *SocketModeConnection, websocketURL string, err error) {
+ response := &openResponseFull{}
+ err = postJSON(ctx, api.httpclient, api.endpoint+"apps.connections.open", api.appLevelToken, nil, response, api)
+ if err != nil {
+ return nil, "", err
+ }
+
+ if response.Err() == nil {
+ api.Debugln("Using URL:", response.SocketModeConnection.URL)
+ }
+
+ return &response.SocketModeConnection, response.SocketModeConnection.URL, response.Err()
+}
diff --git a/vendor/github.com/slack-go/slack/users.go b/vendor/github.com/slack-go/slack/users.go
index c2ee8713..5d8cb35f 100644
--- a/vendor/github.com/slack-go/slack/users.go
+++ b/vendor/github.com/slack-go/slack/users.go
@@ -31,6 +31,7 @@ type UserProfile struct {
Image48 string `json:"image_48"`
Image72 string `json:"image_72"`
Image192 string `json:"image_192"`
+ Image512 string `json:"image_512"`
ImageOriginal string `json:"image_original"`
Title string `json:"title"`
BotID string `json:"bot_id,omitempty"`
diff --git a/vendor/github.com/slack-go/slack/websocket_managed_conn.go b/vendor/github.com/slack-go/slack/websocket_managed_conn.go
index 8607b3a3..fe6802e4 100644
--- a/vendor/github.com/slack-go/slack/websocket_managed_conn.go
+++ b/vendor/github.com/slack-go/slack/websocket_managed_conn.go
@@ -9,6 +9,9 @@ import (
"reflect"
"time"
+ "github.com/slack-go/slack/internal/backoff"
+ "github.com/slack-go/slack/internal/misc"
+
"github.com/gorilla/websocket"
"github.com/slack-go/slack/internal/errorsx"
"github.com/slack-go/slack/internal/timex"
@@ -92,7 +95,7 @@ func (rtm *RTM) connect(connectionCount int, useRTMStart bool) (*Info, *websocke
// used to provide exponential backoff wait time with jitter before trying
// to connect to slack again
- boff := &backoff{
+ boff := &backoff.Backoff{
Max: 5 * time.Minute,
}
@@ -103,7 +106,7 @@ func (rtm *RTM) connect(connectionCount int, useRTMStart bool) (*Info, *websocke
// send connecting event
rtm.IncomingEvents <- RTMEvent{"connecting", &ConnectingEvent{
- Attempt: boff.attempts + 1,
+ Attempt: boff.Attempts() + 1,
ConnectionCount: connectionCount,
}}
@@ -123,7 +126,7 @@ func (rtm *RTM) connect(connectionCount int, useRTMStart bool) (*Info, *websocke
}
switch actual := err.(type) {
- case statusCodeError:
+ case misc.StatusCodeError:
if actual.Code == http.StatusNotFound {
rtm.Debugf("invalid auth when connecting with RTM: %s", err)
rtm.IncomingEvents <- RTMEvent{"invalid_auth", &InvalidAuthEvent{}}
@@ -138,13 +141,13 @@ func (rtm *RTM) connect(connectionCount int, useRTMStart bool) (*Info, *websocke
// any other errors are treated as recoverable and we try again after
// sending the event along the IncomingEvents channel
rtm.IncomingEvents <- RTMEvent{"connection_error", &ConnectionErrorEvent{
- Attempt: boff.attempts,
+ Attempt: boff.Attempts(),
Backoff: backoff,
ErrorObj: err,
}}
// get time we should wait before attempting to connect again
- rtm.Debugf("reconnection %d failed: %s reconnecting in %v\n", boff.attempts, err, backoff)
+ rtm.Debugf("reconnection %d failed: %s reconnecting in %v\n", boff.Attempts(), err, backoff)
// wait for one of the following to occur,
// backoff duration has elapsed, killChannel is signalled, or