4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-03 18:57:45 +00:00

Update vendor (#1228)

This commit is contained in:
Wim
2020-09-04 23:29:13 +02:00
committed by GitHub
parent 17747a5c88
commit 2f59abdda7
1436 changed files with 21840 additions and 3466 deletions

View File

@ -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"`

View File

@ -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

View File

@ -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:

38
vendor/github.com/slack-go/slack/block_header.go generated vendored Normal file
View File

@ -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
}

View File

@ -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")

View File

@ -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
}

View File

@ -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,