diff options
author | Wim <wim@42.be> | 2020-07-18 17:27:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-18 17:27:41 +0200 |
commit | 23d8742f0d95096b92f11729fb47f86ac3b68d43 (patch) | |
tree | 7b8acb02b051ae06e5454fda4a9d5118428fe016 /vendor/github.com/slack-go | |
parent | 3b6a8be07b9422714db30fb50977f342057febf3 (diff) | |
download | matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.gz matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.bz2 matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.zip |
Update dependencies for 1.18.0 release (#1175)
Diffstat (limited to 'vendor/github.com/slack-go')
-rw-r--r-- | vendor/github.com/slack-go/slack/.travis.yml | 2 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block.go | 37 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block_conv.go | 14 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block_element.go | 60 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block_image.go | 2 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block_object.go | 6 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/chat.go | 11 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/go.mod | 4 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/go.sum | 2 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/interactions.go | 11 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/oauth.go | 16 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/webhooks.go | 1 |
12 files changed, 116 insertions, 50 deletions
diff --git a/vendor/github.com/slack-go/slack/.travis.yml b/vendor/github.com/slack-go/slack/.travis.yml index 6a968232..f2019d72 100644 --- a/vendor/github.com/slack-go/slack/.travis.yml +++ b/vendor/github.com/slack-go/slack/.travis.yml @@ -32,6 +32,8 @@ matrix: script: go test -v -mod=vendor ./... - go: "1.13.x" script: go test -v -mod=vendor ./... + - go: "1.14.x" + script: go test -v -mod=vendor ./... - go: "tip" script: go test -v -mod=vendor ./... diff --git a/vendor/github.com/slack-go/slack/block.go b/vendor/github.com/slack-go/slack/block.go index dbc34496..4b4b1559 100644 --- a/vendor/github.com/slack-go/slack/block.go +++ b/vendor/github.com/slack-go/slack/block.go @@ -32,23 +32,26 @@ type Blocks struct { // BlockAction is the action callback sent when a block is interacted with type BlockAction struct { - ActionID string `json:"action_id"` - BlockID string `json:"block_id"` - Type actionType `json:"type"` - Text TextBlockObject `json:"text"` - Value string `json:"value"` - ActionTs string `json:"action_ts"` - SelectedOption OptionBlockObject `json:"selected_option"` - SelectedOptions []OptionBlockObject `json:"selected_options"` - SelectedUser string `json:"selected_user"` - SelectedChannel string `json:"selected_channel"` - SelectedConversation string `json:"selected_conversation"` - SelectedDate string `json:"selected_date"` - 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"` + ActionID string `json:"action_id"` + BlockID string `json:"block_id"` + Type actionType `json:"type"` + Text TextBlockObject `json:"text"` + Value string `json:"value"` + ActionTs string `json:"action_ts"` + SelectedOption OptionBlockObject `json:"selected_option"` + SelectedOptions []OptionBlockObject `json:"selected_options"` + SelectedUser string `json:"selected_user"` + SelectedUsers []string `json:"selected_users"` + SelectedChannel string `json:"selected_channel"` + SelectedChannels []string `json:"selected_channels"` + SelectedConversation string `json:"selected_conversation"` + SelectedConversations []string `json:"selected_conversations"` + SelectedDate string `json:"selected_date"` + 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"` } // 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 00d59c3b..3fda5431 100644 --- a/vendor/github.com/slack-go/slack/block_conv.go +++ b/vendor/github.com/slack-go/slack/block_conv.go @@ -2,6 +2,7 @@ package slack import ( "encoding/json" + "fmt" "github.com/pkg/errors" ) @@ -172,10 +173,12 @@ func (b *BlockElements) UnmarshalJSON(data []byte) error { blockElement = &DatePickerBlockElement{} case "plain_text_input": blockElement = &PlainTextInputBlockElement{} + case "checkboxes": + blockElement = &CheckboxGroupsBlockElement{} case "static_select", "external_select", "users_select", "conversations_select", "channels_select": blockElement = &SelectBlockElement{} default: - return errors.New("unsupported block element type") + return fmt.Errorf("unsupported block element type %v", blockElementType) } err = json.Unmarshal(r, blockElement) @@ -275,6 +278,12 @@ func (a *Accessory) UnmarshalJSON(data []byte) error { return err } a.MultiSelectElement = element.(*MultiSelectBlockElement) + case "checkboxes": + element, err := unmarshalBlockElement(r, &CheckboxGroupsBlockElement{}) + if err != nil { + return err + } + a.CheckboxGroupsBlockElement = element.(*CheckboxGroupsBlockElement) default: element, err := unmarshalBlockElement(r, &UnknownBlockElement{}) if err != nil { @@ -313,6 +322,9 @@ func toBlockElement(element *Accessory) BlockElement { if element.RadioButtonsElement != nil { return element.RadioButtonsElement } + if element.CheckboxGroupsBlockElement != nil { + return element.CheckboxGroupsBlockElement + } if element.SelectElement != nil { return element.SelectElement } diff --git a/vendor/github.com/slack-go/slack/block_element.go b/vendor/github.com/slack-go/slack/block_element.go index 50971bfa..bca4e314 100644 --- a/vendor/github.com/slack-go/slack/block_element.go +++ b/vendor/github.com/slack-go/slack/block_element.go @@ -40,15 +40,16 @@ type MixedElement interface { } type Accessory struct { - ImageElement *ImageBlockElement - ButtonElement *ButtonBlockElement - OverflowElement *OverflowBlockElement - DatePickerElement *DatePickerBlockElement - PlainTextInputElement *PlainTextInputBlockElement - RadioButtonsElement *RadioButtonsBlockElement - SelectElement *SelectBlockElement - MultiSelectElement *MultiSelectBlockElement - UnknownElement *UnknownBlockElement + ImageElement *ImageBlockElement + ButtonElement *ButtonBlockElement + OverflowElement *OverflowBlockElement + DatePickerElement *DatePickerBlockElement + PlainTextInputElement *PlainTextInputBlockElement + RadioButtonsElement *RadioButtonsBlockElement + SelectElement *SelectBlockElement + MultiSelectElement *MultiSelectBlockElement + CheckboxGroupsBlockElement *CheckboxGroupsBlockElement + UnknownElement *UnknownBlockElement } // NewAccessory returns a new Accessory for a given block element @@ -70,6 +71,8 @@ func NewAccessory(element BlockElement) *Accessory { return &Accessory{SelectElement: element.(*SelectBlockElement)} case *MultiSelectBlockElement: return &Accessory{MultiSelectElement: element.(*MultiSelectBlockElement)} + case *CheckboxGroupsBlockElement: + return &Accessory{CheckboxGroupsBlockElement: element.(*CheckboxGroupsBlockElement)} default: return &Accessory{UnknownElement: element.(*UnknownBlockElement)} } @@ -152,9 +155,10 @@ func (s ButtonBlockElement) ElementType() MessageElementType { return s.Type } -// add styling to button object -func (s *ButtonBlockElement) WithStyle(style Style) { +// WithStyling adds styling to the button object and returns the modified ButtonBlockElement +func (s *ButtonBlockElement) WithStyle(style Style) *ButtonBlockElement { s.Style = style + return s } // NewButtonBlockElement returns an instance of a new button element to be used within a block @@ -186,17 +190,19 @@ type OptionGroupsResponse struct { // // More Information: https://api.slack.com/reference/messaging/block-elements#select type SelectBlockElement struct { - Type string `json:"type,omitempty"` - Placeholder *TextBlockObject `json:"placeholder,omitempty"` - ActionID string `json:"action_id,omitempty"` - Options []*OptionBlockObject `json:"options,omitempty"` - OptionGroups []*OptionGroupBlockObject `json:"option_groups,omitempty"` - InitialOption *OptionBlockObject `json:"initial_option,omitempty"` - InitialUser string `json:"initial_user,omitempty"` - InitialConversation string `json:"initial_conversation,omitempty"` - InitialChannel string `json:"initial_channel,omitempty"` - MinQueryLength *int `json:"min_query_length,omitempty"` - Confirm *ConfirmationBlockObject `json:"confirm,omitempty"` + Type string `json:"type,omitempty"` + Placeholder *TextBlockObject `json:"placeholder,omitempty"` + ActionID string `json:"action_id,omitempty"` + Options []*OptionBlockObject `json:"options,omitempty"` + OptionGroups []*OptionGroupBlockObject `json:"option_groups,omitempty"` + InitialOption *OptionBlockObject `json:"initial_option,omitempty"` + InitialUser string `json:"initial_user,omitempty"` + InitialConversation string `json:"initial_conversation,omitempty"` + InitialChannel string `json:"initial_channel,omitempty"` + DefaultToCurrentConversation bool `json:"default_to_current_conversation,omitempty"` + ResponseURLEnabled bool `json:"response_url_enabled,omitempty"` + MinQueryLength *int `json:"min_query_length,omitempty"` + Confirm *ConfirmationBlockObject `json:"confirm,omitempty"` } // ElementType returns the type of the Element @@ -315,7 +321,7 @@ func NewOverflowBlockElement(actionID string, options ...*OptionBlockObject) *Ov // More Information: https://api.slack.com/reference/messaging/block-elements#datepicker type DatePickerBlockElement struct { Type MessageElementType `json:"type"` - ActionID string `json:"action_id"` + ActionID string `json:"action_id,omitempty"` Placeholder *TextBlockObject `json:"placeholder,omitempty"` InitialDate string `json:"initial_date,omitempty"` Confirm *ConfirmationBlockObject `json:"confirm,omitempty"` @@ -341,7 +347,7 @@ func NewDatePickerBlockElement(actionID string) *DatePickerBlockElement { // More Information: https://api.slack.com/reference/block-kit/block-elements#input type PlainTextInputBlockElement struct { Type MessageElementType `json:"type"` - ActionID string `json:"action_id"` + ActionID string `json:"action_id,omitempty"` Placeholder *TextBlockObject `json:"placeholder,omitempty"` InitialValue string `json:"initial_value,omitempty"` Multiline bool `json:"multiline,omitempty"` @@ -370,7 +376,7 @@ func NewPlainTextInputBlockElement(placeholder *TextBlockObject, actionID string // More Information: https://api.slack.com/reference/block-kit/block-elements#checkboxes type CheckboxGroupsBlockElement struct { Type MessageElementType `json:"type"` - ActionID string `json:"action_id"` + ActionID string `json:"action_id,omitempty"` Options []*OptionBlockObject `json:"options"` InitialOptions []*OptionBlockObject `json:"initial_options,omitempty"` Confirm *ConfirmationBlockObject `json:"confirm,omitempty"` @@ -381,7 +387,7 @@ func (c CheckboxGroupsBlockElement) ElementType() MessageElementType { return c.Type } -// NewRadioButtonsBlockElement returns an instance of a radio block element +// NewCheckboxGroupsBlockElement returns an instance of a radio block element func NewCheckboxGroupsBlockElement(actionID string, options ...*OptionBlockObject) *CheckboxGroupsBlockElement { return &CheckboxGroupsBlockElement{ Type: METCheckboxGroups, @@ -396,7 +402,7 @@ func NewCheckboxGroupsBlockElement(actionID string, options ...*OptionBlockObjec // More Information: https://api.slack.com/reference/block-kit/block-elements#radio type RadioButtonsBlockElement struct { Type MessageElementType `json:"type"` - ActionID string `json:"action_id"` + ActionID string `json:"action_id,omitempty"` Options []*OptionBlockObject `json:"options"` InitialOption *OptionBlockObject `json:"initial_option,omitempty"` Confirm *ConfirmationBlockObject `json:"confirm,omitempty"` diff --git a/vendor/github.com/slack-go/slack/block_image.go b/vendor/github.com/slack-go/slack/block_image.go index 6de3f63a..90cbd14e 100644 --- a/vendor/github.com/slack-go/slack/block_image.go +++ b/vendor/github.com/slack-go/slack/block_image.go @@ -8,7 +8,7 @@ type ImageBlock struct { ImageURL string `json:"image_url"` AltText string `json:"alt_text"` BlockID string `json:"block_id,omitempty"` - Title *TextBlockObject `json:"title"` + Title *TextBlockObject `json:"title,omitempty"` } // BlockType returns the type of the block diff --git a/vendor/github.com/slack-go/slack/block_object.go b/vendor/github.com/slack-go/slack/block_object.go index cf3536d0..b6f1da4a 100644 --- a/vendor/github.com/slack-go/slack/block_object.go +++ b/vendor/github.com/slack-go/slack/block_object.go @@ -163,6 +163,7 @@ type ConfirmationBlockObject struct { Text *TextBlockObject `json:"text"` Confirm *TextBlockObject `json:"confirm"` Deny *TextBlockObject `json:"deny"` + Style Style `json:"style,omitempty"` } // validateType enforces block objects for element and block parameters @@ -170,6 +171,11 @@ func (s ConfirmationBlockObject) validateType() MessageObjectType { return motConfirmation } +// add styling to confirmation object +func (s *ConfirmationBlockObject) WithStyle(style Style) { + s.Style = style +} + // NewConfirmationBlockObject returns an instance of a new Confirmation Block Object func NewConfirmationBlockObject(title, text, confirm, deny *TextBlockObject) *ConfirmationBlockObject { return &ConfirmationBlockObject{ diff --git a/vendor/github.com/slack-go/slack/chat.go b/vendor/github.com/slack-go/slack/chat.go index c5b524c1..a9f51e1f 100644 --- a/vendor/github.com/slack-go/slack/chat.go +++ b/vendor/github.com/slack-go/slack/chat.go @@ -1,8 +1,10 @@ package slack import ( + "bytes" "context" "encoding/json" + "io/ioutil" "net/http" "net/url" "strconv" @@ -206,6 +208,15 @@ func (api *Client) SendMessageContext(ctx context.Context, channelID string, opt return "", "", "", err } + if api.Debug() { + reqBody, err := ioutil.ReadAll(req.Body) + if err != nil { + return "", "", "", err + } + req.Body = ioutil.NopCloser(bytes.NewBuffer(reqBody)) + api.Debugf("Sending request: %s", string(reqBody)) + } + if err = doPost(ctx, api.httpclient, req, parser(&response), api); err != nil { return "", "", "", err } diff --git a/vendor/github.com/slack-go/slack/go.mod b/vendor/github.com/slack-go/slack/go.mod index 2107e612..32fc4b93 100644 --- a/vendor/github.com/slack-go/slack/go.mod +++ b/vendor/github.com/slack-go/slack/go.mod @@ -1,9 +1,11 @@ module github.com/slack-go/slack require ( + github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-test/deep v1.0.4 - github.com/gorilla/websocket v1.2.0 + github.com/gorilla/websocket v1.4.2 github.com/pkg/errors v0.8.0 + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/testify v1.2.2 ) diff --git a/vendor/github.com/slack-go/slack/go.sum b/vendor/github.com/slack-go/slack/go.sum index 7a0ae46e..a66560ac 100644 --- a/vendor/github.com/slack-go/slack/go.sum +++ b/vendor/github.com/slack-go/slack/go.sum @@ -4,6 +4,8 @@ github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/vendor/github.com/slack-go/slack/interactions.go b/vendor/github.com/slack-go/slack/interactions.go index ec662ee3..c7f59217 100644 --- a/vendor/github.com/slack-go/slack/interactions.go +++ b/vendor/github.com/slack-go/slack/interactions.go @@ -59,8 +59,13 @@ type InteractionCallback struct { } type Container struct { - Type string `json:"type"` - ViewID string `json:"view_id"` + Type string `json:"type"` + ViewID string `json:"view_id"` + MessageTs string `json:"message_ts"` + AttachmentID json.Number `json:"attachment_id"` + ChannelID string `json:"channel_id"` + IsEphemeral bool `json:"is_ephemeral"` + IsAppUnfurl bool `json:"is_app_unfurl"` } // ActionCallback is a convenience struct defined to allow dynamic unmarshalling of @@ -135,7 +140,7 @@ func (a *ActionCallbacks) UnmarshalJSON(data []byte) error { } a.BlockActions = append(a.BlockActions, action.(*BlockAction)) - return nil + continue } action, err := unmarshalAction(r, &AttachmentAction{}) diff --git a/vendor/github.com/slack-go/slack/oauth.go b/vendor/github.com/slack-go/slack/oauth.go index 43139768..4dc23b11 100644 --- a/vendor/github.com/slack-go/slack/oauth.go +++ b/vendor/github.com/slack-go/slack/oauth.go @@ -78,10 +78,26 @@ func GetOAuthTokenContext(ctx context.Context, client httpClient, clientID, clie return response.AccessToken, response.Scope, nil } +// GetBotOAuthToken retrieves top-level and bot AccessToken - https://api.slack.com/legacy/oauth#bot_user_access_tokens +func GetBotOAuthToken(client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, bot OAuthResponseBot, err error) { + return GetBotOAuthTokenContext(context.Background(), client, clientID, clientSecret, code, redirectURI) +} + +// GetBotOAuthTokenContext retrieves top-level and bot AccessToken with a custom context +func GetBotOAuthTokenContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (accessToken string, scope string, bot OAuthResponseBot, err error) { + response, err := GetOAuthResponseContext(ctx, client, clientID, clientSecret, code, redirectURI) + if err != nil { + return "", "", OAuthResponseBot{}, err + } + return response.AccessToken, response.Scope, response.Bot, nil +} + +// GetOAuthResponse retrieves OAuth response func GetOAuthResponse(client httpClient, clientID, clientSecret, code, redirectURI string) (resp *OAuthResponse, err error) { return GetOAuthResponseContext(context.Background(), client, clientID, clientSecret, code, redirectURI) } +// GetOAuthResponseContext retrieves OAuth response with custom context func GetOAuthResponseContext(ctx context.Context, client httpClient, clientID, clientSecret, code, redirectURI string) (resp *OAuthResponse, err error) { values := url.Values{ "client_id": {clientID}, diff --git a/vendor/github.com/slack-go/slack/webhooks.go b/vendor/github.com/slack-go/slack/webhooks.go index 1016cb4f..39fff441 100644 --- a/vendor/github.com/slack-go/slack/webhooks.go +++ b/vendor/github.com/slack-go/slack/webhooks.go @@ -14,6 +14,7 @@ type WebhookMessage struct { Text string `json:"text,omitempty"` Attachments []Attachment `json:"attachments,omitempty"` Parse string `json:"parse,omitempty"` + Blocks *Blocks `json:"blocks,omitempty"` } func PostWebhook(url string, msg *WebhookMessage) error { |