summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/views.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-09-04 23:29:13 +0200
committerGitHub <noreply@github.com>2020-09-04 23:29:13 +0200
commit2f59abdda7a1072036ea1fdb4c859cccbb56efa6 (patch)
treee35393f23d12783ae92f0469085efc7dec953f82 /vendor/github.com/slack-go/slack/views.go
parent17747a5c8893fd47ba8eb61dd10477170640caf6 (diff)
downloadmatterbridge-msglm-2f59abdda7a1072036ea1fdb4c859cccbb56efa6.tar.gz
matterbridge-msglm-2f59abdda7a1072036ea1fdb4c859cccbb56efa6.tar.bz2
matterbridge-msglm-2f59abdda7a1072036ea1fdb4c859cccbb56efa6.zip
Update vendor (#1228)
Diffstat (limited to 'vendor/github.com/slack-go/slack/views.go')
-rw-r--r--vendor/github.com/slack-go/slack/views.go22
1 files changed, 22 insertions, 0 deletions
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,