From b03c08874297cbedc9b3e83941145e5525270cd6 Mon Sep 17 00:00:00 2001 From: Abdulla Abdurakhmanov Date: Wed, 15 May 2024 21:42:46 +0200 Subject: [PATCH] Restrict SlackHeaderBlock to accept plan text only block (#273) * Restrict SlackHeaderBlock to accept plan text only block * Fix new cargo clippy warnings --- src/api/files.rs | 5 +---- src/models/blocks/datetime.rs | 1 + src/models/blocks/kit.rs | 6 +++--- src/models/common/mod.rs | 13 +++++++++++++ src/socket_mode/wss_client_id.rs | 1 + src/token.rs | 1 + 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/api/files.rs b/src/api/files.rs index b7f8b10c..df2f7787 100644 --- a/src/api/files.rs +++ b/src/api/files.rs @@ -87,10 +87,7 @@ pub struct SlackApiFilesUploadResponse { pub file: SlackFile, } -fn to_csv(x: &Option>, s: S) -> Result -where - S: Serializer, -{ +fn to_csv(x: &Option>, s: S) -> Result { match x { None => s.serialize_none(), Some(ids) => { diff --git a/src/models/blocks/datetime.rs b/src/models/blocks/datetime.rs index 42056197..6bc34253 100644 --- a/src/models/blocks/datetime.rs +++ b/src/models/blocks/datetime.rs @@ -13,6 +13,7 @@ pub enum SlackDateTimeFormats { TimeSecs, } +#[allow(clippy::to_string_trait_impl)] impl ToString for SlackDateTimeFormats { fn to_string(&self) -> String { match self { diff --git a/src/models/blocks/kit.rs b/src/models/blocks/kit.rs index e20474f1..b85f405f 100644 --- a/src/models/blocks/kit.rs +++ b/src/models/blocks/kit.rs @@ -56,7 +56,7 @@ impl From for SlackBlock { #[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)] pub struct SlackHeaderBlock { pub block_id: Option, - pub text: SlackBlockText, + pub text: SlackBlockPlainTextOnly, } impl From for SlackBlock { @@ -874,8 +874,8 @@ impl From for SlackActionBlockElement { } /** -* 'plain_text' type of https://api.slack.com/reference/block-kit/composition-objects#text -*/ + * 'plain_text' type of https://api.slack.com/reference/block-kit/composition-objects#text + */ #[skip_serializing_none] #[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)] pub struct SlackBlockPlainText { diff --git a/src/models/common/mod.rs b/src/models/common/mod.rs index 7f641dee..3947c3e5 100644 --- a/src/models/common/mod.rs +++ b/src/models/common/mod.rs @@ -9,23 +9,35 @@ use std::*; use url::Url; mod user; + pub use user::*; + mod team; + pub use team::*; + mod channel; + pub use channel::*; + mod reaction; + pub use reaction::*; + mod star; + pub use star::*; mod bot; + pub use bot::*; mod icon; + pub use icon::*; mod formatters; + pub use formatters::*; #[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)] @@ -178,6 +190,7 @@ pub enum SlackConversationType { Public, } +#[allow(clippy::to_string_trait_impl)] impl ToString for SlackConversationType { fn to_string(&self) -> String { match self { diff --git a/src/socket_mode/wss_client_id.rs b/src/socket_mode/wss_client_id.rs index c7157c88..71b8441b 100644 --- a/src/socket_mode/wss_client_id.rs +++ b/src/socket_mode/wss_client_id.rs @@ -24,6 +24,7 @@ impl SlackSocketModeWssClientId { } } +#[allow(clippy::to_string_trait_impl)] impl ToString for SlackSocketModeWssClientId { fn to_string(&self) -> String { format!( diff --git a/src/token.rs b/src/token.rs index 596aa1f6..8acba0ab 100644 --- a/src/token.rs +++ b/src/token.rs @@ -24,6 +24,7 @@ pub enum SlackApiTokenType { App, } +#[allow(clippy::to_string_trait_impl)] impl ToString for SlackApiTokenType { fn to_string(&self) -> String { match self {