Repository navigation
v2.31.0
Migration guide: optional action_id
Slack accepts most interactive Block Kit elements without action_id, so the field is optional in the models now. A block from Block Kit Builder without action_id deserializes to its typed variant instead of SlackBlock::Unknown.
action_id is Option<SlackActionId> on these elements, and their new() constructors do not take it as an argument anymore:
SlackBlockButtonElement, SlackBlockStaticSelectElement, SlackBlockMultiStaticSelectElement, SlackBlockExternalSelectElement, SlackBlockMultiExternalSelectElement, SlackBlockUsersSelectElement, SlackBlockMultiUsersSelectElement, SlackBlockConversationsSelectElement, SlackBlockMultiConversationsSelectElement, SlackBlockChannelsSelectElement, SlackBlockMultiChannelsSelectElement, SlackBlockOverflowElement, SlackBlockDatePickerElement, SlackBlockTimePickerElement, SlackBlockDateTimePickerElement, SlackBlockPlainTextInputElement, SlackBlockNumberInputElement, SlackBlockUrlInputElement, SlackBlockEmailInputElement, SlackBlockRadioButtonsElement, SlackBlockCheckboxesElement, SlackBlockFileInputElement, SlackBlockFeedbackButtonsElement and SlackBlockIconButtonElement.
Set it with with_action_id instead:
// Before
SlackBlockButtonElement::new("approve".into(), pt!("Approve"))
SlackBlockStaticSelectElement::new("region".into())
SlackBlockIconButtonElement::new("delete".into(), "trash".into(), pt!("Delete"))
// After
SlackBlockButtonElement::new(pt!("Approve")).with_action_id("approve".into())
SlackBlockStaticSelectElement::new().with_action_id("region".into())
SlackBlockIconButtonElement::new("trash".into(), pt!("Delete")).with_action_id("delete".into())Code that reads action_id from these elements gets an Option<SlackActionId>. SlackBlockRichTextInputElement and SlackBlockWorkflowButtonElement still require it, as Slack documents it as required for them.
Feedback buttons match Slack's element
SlackBlockFeedbackButtonsElement now follows the shape Slack documents for the feedback_buttons element, so Slack's own example deserializes to SlackContextActionBlockElement::FeedbackButtons instead of SlackBlock::Unknown:
positiveandnegativeare renamed topositive_buttonandnegative_button, the keys Slack sends.SlackFeedbackButtonItemhas noaction_idand noconfirm. The element'saction_ididentifies the source in interaction payloads, andvaluetells the two buttons apart.SlackFeedbackButtonItemhasaccessibility_label: Option<SlackAccessibilityLabel>.
// Before
SlackBlockFeedbackButtonsElement::new(
"feedback".into(),
SlackFeedbackButtonItem::new("good".into(), "positive_feedback".into(), pt!("Good")),
SlackFeedbackButtonItem::new("bad".into(), "negative_feedback".into(), pt!("Bad")),
)
// After
SlackBlockFeedbackButtonsElement::new(
SlackFeedbackButtonItem::new(pt!("Good"), "positive_feedback".into())
.with_accessibility_label("Mark this response as good".into()),
SlackFeedbackButtonItem::new(pt!("Bad"), "negative_feedback".into()),
)
.with_action_id("feedback".into())What's Changed
- feat: make action_id optional on interactive Block Kit elements by @abdolence in #392
Full Changelog: v2.30.0...v2.31.0