diff options
Diffstat (limited to 'vendor/github.com/slack-go')
-rw-r--r-- | vendor/github.com/slack-go/slack/attachments.go | 2 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block.go | 1 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block_conv.go | 8 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/block_header.go | 38 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/errors.go | 1 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/oauth.go | 17 | ||||
-rw-r--r-- | vendor/github.com/slack-go/slack/views.go | 22 |
7 files changed, 80 insertions, 9 deletions
diff --git a/vendor/github.com/slack-go/slack/attachments.go b/vendor/github.com/slack-go/slack/attachments.go index b5b79f9f..5f388e9f 100644 --- a/vendor/github.com/slack-go/slack/attachments.go +++ b/vendor/github.com/slack-go/slack/attachments.go @@ -75,7 +75,7 @@ type Attachment struct { Title string `json:"title,omitempty"` TitleLink string `json:"title_link,omitempty"` Pretext string `json:"pretext,omitempty"` - Text string `json:"text,omitempty"` + Text string `json:"text"` // Required ImageURL string `json:"image_url,omitempty"` ThumbURL string `json:"thumb_url,omitempty"` diff --git a/vendor/github.com/slack-go/slack/block.go b/vendor/github.com/slack-go/slack/block.go index 4b4b1559..dd4b8715 100644 --- a/vendor/github.com/slack-go/slack/block.go +++ b/vendor/github.com/slack-go/slack/block.go @@ -16,6 +16,7 @@ const ( MBTContext MessageBlockType = "context" MBTFile MessageBlockType = "file" MBTInput MessageBlockType = "input" + MBTHeader MessageBlockType = "header" ) // Block defines an interface all block types should implement diff --git a/vendor/github.com/slack-go/slack/block_conv.go b/vendor/github.com/slack-go/slack/block_conv.go index 3fda5431..656a9ab1 100644 --- a/vendor/github.com/slack-go/slack/block_conv.go +++ b/vendor/github.com/slack-go/slack/block_conv.go @@ -111,6 +111,12 @@ func (b *InputBlock) UnmarshalJSON(data []byte) error { e = &SelectBlockElement{} case "multi_static_select", "multi_external_select", "multi_users_select", "multi_conversations_select", "multi_channels_select": e = &MultiSelectBlockElement{} + case "checkboxes": + e = &CheckboxGroupsBlockElement{} + case "overflow": + e = &OverflowBlockElement{} + case "radio_buttons": + e = &RadioButtonsBlockElement{} default: return errors.New("unsupported block element type") } @@ -175,6 +181,8 @@ func (b *BlockElements) UnmarshalJSON(data []byte) error { blockElement = &PlainTextInputBlockElement{} case "checkboxes": blockElement = &CheckboxGroupsBlockElement{} + case "radio_buttons": + blockElement = &RadioButtonsBlockElement{} case "static_select", "external_select", "users_select", "conversations_select", "channels_select": blockElement = &SelectBlockElement{} default: diff --git a/vendor/github.com/slack-go/slack/block_header.go b/vendor/github.com/slack-go/slack/block_header.go new file mode 100644 index 00000000..6dff4b88 --- /dev/null +++ b/vendor/github.com/slack-go/slack/block_header.go @@ -0,0 +1,38 @@ +package slack + +// HeaderBlock defines a new block of type header +// +// More Information: https://api.slack.com/reference/messaging/blocks#header +type HeaderBlock struct { + Type MessageBlockType `json:"type"` + Text *TextBlockObject `json:"text,omitempty"` + BlockID string `json:"block_id,omitempty"` +} + +// BlockType returns the type of the block +func (s HeaderBlock) BlockType() MessageBlockType { + return s.Type +} + +// HeaderBlockOption allows configuration of options for a new header block +type HeaderBlockOption func(*HeaderBlock) + +func HeaderBlockOptionBlockID(blockID string) HeaderBlockOption { + return func(block *HeaderBlock) { + block.BlockID = blockID + } +} + +// NewHeaderBlock returns a new instance of a header block to be rendered +func NewHeaderBlock(textObj *TextBlockObject, options ...HeaderBlockOption) *HeaderBlock { + block := HeaderBlock{ + Type: MBTHeader, + Text: textObj, + } + + for _, option := range options { + option(&block) + } + + return &block +} diff --git a/vendor/github.com/slack-go/slack/errors.go b/vendor/github.com/slack-go/slack/errors.go index a1dfec25..8be22a65 100644 --- a/vendor/github.com/slack-go/slack/errors.go +++ b/vendor/github.com/slack-go/slack/errors.go @@ -9,6 +9,7 @@ const ( ErrRTMGoodbye = errorsx.String("goodbye detected") ErrRTMDeadman = errorsx.String("deadman switch triggered") ErrParametersMissing = errorsx.String("received empty parameters") + ErrBlockIDNotUnique = errorsx.String("Block ID needs to be unique") ErrInvalidConfiguration = errorsx.String("invalid configuration") ErrMissingHeaders = errorsx.String("missing headers") ErrExpiredTimestamp = errorsx.String("timestamp is too old") diff --git a/vendor/github.com/slack-go/slack/oauth.go b/vendor/github.com/slack-go/slack/oauth.go index 4dc23b11..707ccc6b 100644 --- a/vendor/github.com/slack-go/slack/oauth.go +++ b/vendor/github.com/slack-go/slack/oauth.go @@ -33,14 +33,15 @@ type OAuthResponse struct { // OAuthV2Response ... type OAuthV2Response struct { - AccessToken string `json:"access_token"` - TokenType string `json:"token_type"` - Scope string `json:"scope"` - BotUserID string `json:"bot_user_id"` - AppID string `json:"app_id"` - Team OAuthV2ResponseTeam `json:"team"` - Enterprise OAuthV2ResponseEnterprise `json:"enterprise"` - AuthedUser OAuthV2ResponseAuthedUser `json:"authed_user"` + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + Scope string `json:"scope"` + BotUserID string `json:"bot_user_id"` + AppID string `json:"app_id"` + Team OAuthV2ResponseTeam `json:"team"` + IncomingWebhook OAuthResponseIncomingWebhook `json:"incoming_webhook"` + Enterprise OAuthV2ResponseEnterprise `json:"enterprise"` + AuthedUser OAuthV2ResponseAuthedUser `json:"authed_user"` SlackResponse } diff --git a/vendor/github.com/slack-go/slack/views.go b/vendor/github.com/slack-go/slack/views.go index c34feece..ee197ad8 100644 --- a/vendor/github.com/slack-go/slack/views.go +++ b/vendor/github.com/slack-go/slack/views.go @@ -150,6 +150,23 @@ func (api *Client) OpenView(triggerID string, view ModalViewRequest) (*ViewRespo return api.OpenViewContext(context.Background(), triggerID, view) } +// ValidateUniqueBlockID will verify if each input block has a unique block ID if set +func ValidateUniqueBlockID(view ModalViewRequest) bool { + + uniqueBlockID := map[string]bool{} + + for _, b := range view.Blocks.BlockSet { + if inputBlock, ok := b.(*InputBlock); ok { + if _, ok := uniqueBlockID[inputBlock.BlockID]; ok { + return false + } + uniqueBlockID[inputBlock.BlockID] = true + } + } + + return true +} + // OpenViewContext opens a view for a user with a custom context. func (api *Client) OpenViewContext( ctx context.Context, @@ -159,6 +176,11 @@ func (api *Client) OpenViewContext( if triggerID == "" { return nil, ErrParametersMissing } + + if !ValidateUniqueBlockID(view) { + return nil, ErrBlockIDNotUnique + } + req := openViewRequest{ TriggerID: triggerID, View: view, |