Skip to content

No filter object in multi_conversation_selectΒ #1192

Open
@imamfzn

Description

Hi team, currently there is no filter field in the multi_conversation_select block element type like below:

slack/block_element.go

Lines 270 to 283 in b4b5a64

type MultiSelectBlockElement 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"`
InitialOptions []*OptionBlockObject `json:"initial_options,omitempty"`
InitialUsers []string `json:"initial_users,omitempty"`
InitialConversations []string `json:"initial_conversations,omitempty"`
InitialChannels []string `json:"initial_channels,omitempty"`
MinQueryLength *int `json:"min_query_length,omitempty"`
MaxSelectedItems *int `json:"max_selected_items,omitempty"`
Confirm *ConfirmationBlockObject `json:"confirm,omitempty"`
}

At the moment, only the conversation_select which has the filter object. In the slack documentation, it said the filter object also supported in the multi_conversation_select.

As a workaround to bypass this issue, i create a conversation_select block element, and change the element type once it created to be multi_conversation_select, like:

var modal slack.ModalViewRequest
// omitted code to parsed/unmarshal the json kit to be the the view struct
// ...

block := modal.Blocks.BlockSet[0].(*slack.SectionBlock)
block.Accessory.SelectElement.Type = "multi_conversations_select"
modal.Blocks.BlockSet[0] = block
Example json kit template used
{
  "type": "modal",
  "title": {
    "type": "plain_text",
    "text": "Add to Channel",
    "emoji": true
  },
  "submit": {
    "type": "plain_text",
    "text": "Add",
    "emoji": true
  },
  "close": {
    "type": "plain_text",
    "text": "Close",
    "emoji": true
  },
  "blocks": [
    {
      "type": "section",
      "block_id": "block_add_to_channel",
      "text": {
        "type": "mrkdwn",
        "text": "*Add these people to {{.ChannelName}}*"
      },
      "accessory": {
        "action_id": "action_add_to_channel",
        "type": "conversations_select",
        "placeholder": {
          "type": "plain_text",
          "text": "Add people and/or channels"
        },
        "filter": {
          "include": [
            "im",
            "public"
          ],
          "exclude_bot_users": true
        }
      }
    }
  ]
}

But i think that way is not clean, since we actually can directly create the multi_conversation_select with filter object based on the slack documentation.

I create my own pull request in #1191, please help to review and merge / please help to fix that issue if my PR is not suitable.

Thank you!

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions