diff --git a/src/hyper_tokio/listener/interaction_events.rs b/src/hyper_tokio/listener/interaction_events.rs index 54be18e..2f77b6c 100644 --- a/src/hyper_tokio/listener/interaction_events.rs +++ b/src/hyper_tokio/listener/interaction_events.rs @@ -85,6 +85,21 @@ impl SlackClientEventsHyperListener< } } + } + Ok(block_suggestion_event@SlackInteractionEvent::BlockSuggestion(_)) => { + match interaction_service_fn(block_suggestion_event.clone(), sc.clone(), thread_user_state_storage.clone()).await { + Ok(response) => { + response.to_http_response(&block_suggestion_event) + } + Err(err) => { + let status_code = thread_error_handler(err, sc, thread_user_state_storage); + Response::builder() + .status(status_code) + .body(Empty::new().boxed()) + .map_err(|e| e.into()) + } + } + } Ok(interaction_event) => { match interaction_service_fn(interaction_event.clone(), sc.clone(), thread_user_state_storage.clone()).await { @@ -145,3 +160,13 @@ impl SlackInteractionEventResponse for SlackViewSubmissionResponse { .body(Full::new(json_str.into()).boxed())?) } } + +impl SlackInteractionEventResponse for SlackBlockSuggestionResponse { + fn to_http_response(&self, _event: &SlackInteractionEvent) -> AnyStdResult> { + let json_str = serde_json::to_string(&self)?; + Ok(Response::builder() + .status(StatusCode::OK) + .header("content-type", "application/json; charset=utf-8") + .body(Full::new(json_str.into()).boxed())?) + } +} diff --git a/src/models/events/interaction.rs b/src/models/events/interaction.rs index f579565..44f7e1b 100644 --- a/src/models/events/interaction.rs +++ b/src/models/events/interaction.rs @@ -12,6 +12,8 @@ use std::collections::HashMap; pub enum SlackInteractionEvent { #[serde(rename = "block_actions")] BlockActions(SlackInteractionBlockActionsEvent), + #[serde(rename = "block_suggestion")] + BlockSuggestion(SlackInteractionBlockSuggestionEvent), #[serde(rename = "dialog_submission")] DialogSubmission(SlackInteractionDialogueSubmissionEvent), #[serde(rename = "message_action")] @@ -40,6 +42,20 @@ pub struct SlackInteractionBlockActionsEvent { pub state: Option, } +#[skip_serializing_none] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)] +pub struct SlackInteractionBlockSuggestionEvent { + pub team: SlackBasicTeamInfo, + pub user: SlackBasicUserInfo, + pub api_app_id: SlackAppId, + pub block_id: SlackBlockId, + pub action_id: SlackActionId, + pub container: SlackInteractionActionContainer, + pub view: Option, + pub value: String, + pub message: Option, +} + #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[serde(tag = "type")] pub enum SlackInteractionActionContainer { @@ -131,3 +147,22 @@ pub struct SlackInteractionViewClosedEvent { pub view: SlackStatefulView, pub trigger_id: Option, } + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SlackBlockSuggestionResponse { + Options(SlackBlockSuggestionOptions), + OptionGroups(SlackBlockSuggestionOptionGroups), +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)] +pub struct SlackBlockSuggestionOptions { + pub options: Vec>, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)] +pub struct SlackBlockSuggestionOptionGroups { + pub option_groups: Vec>, +}