Remove disable_web_page_preview field from everywhere

This commit is contained in:
Andrey Brusnik 2024-07-18 23:15:38 +04:00
parent 1e25bf1c96
commit 599d8fac8a
No known key found for this signature in database
GPG key ID: D33232F28CFF442C
5 changed files with 12 additions and 57 deletions

View file

@ -252,11 +252,6 @@ Schema(
ty: Option(ArrayOf(RawTy("MessageEntity"))), ty: Option(ArrayOf(RawTy("MessageEntity"))),
descr: Doc(md: "List of special entities that appear in the message text, which can be specified instead of _parse\\_mode_"), descr: Doc(md: "List of special entities that appear in the message text, which can be specified instead of _parse\\_mode_"),
), ),
Param(
name: "disable_web_page_preview",
ty: Option(bool),
descr: Doc(md: "Disables link previews for links in this message")
),
Param( Param(
name: "disable_notification", name: "disable_notification",
ty: Option(bool), ty: Option(bool),
@ -3273,11 +3268,6 @@ Schema(
ty: Option(ArrayOf(RawTy("MessageEntity"))), ty: Option(ArrayOf(RawTy("MessageEntity"))),
descr: Doc(md: "List of special entities that appear in message text, which can be specified instead of _parse\\_mode_"), descr: Doc(md: "List of special entities that appear in message text, which can be specified instead of _parse\\_mode_"),
), ),
Param(
name: "disable_web_page_preview",
ty: Option(bool),
descr: Doc(md: "Disables link previews for links in this message")
),
Param( Param(
name: "reply_markup", name: "reply_markup",
ty: Option(RawTy("InlineKeyboardMarkup")), ty: Option(RawTy("InlineKeyboardMarkup")),

View file

@ -28,8 +28,6 @@ impl_payload! {
pub parse_mode: ParseMode, pub parse_mode: ParseMode,
/// List of special entities that appear in message text, which can be specified instead of _parse\_mode_ /// List of special entities that appear in message text, which can be specified instead of _parse\_mode_
pub entities: Vec<MessageEntity> [collect], pub entities: Vec<MessageEntity> [collect],
/// Disables link previews for links in this message
pub disable_web_page_preview: bool,
/// A JSON-serialized object for an [inline keyboard]. /// A JSON-serialized object for an [inline keyboard].
/// ///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating

View file

@ -27,8 +27,6 @@ impl_payload! {
pub parse_mode: ParseMode, pub parse_mode: ParseMode,
/// List of special entities that appear in the message text, which can be specified instead of _parse\_mode_ /// List of special entities that appear in the message text, which can be specified instead of _parse\_mode_
pub entities: Vec<MessageEntity> [collect], pub entities: Vec<MessageEntity> [collect],
/// Disables link previews for links in this message
pub disable_web_page_preview: bool,
/// Sends the message [silently]. Users will receive a notification with no sound. /// Sends the message [silently]. Users will receive a notification with no sound.
/// ///
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages

View file

@ -303,13 +303,12 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
caption_entities: None, caption_entities: None,
}); });
let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -351,7 +350,6 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
caption_entities: None, caption_entities: None,
@ -359,7 +357,7 @@ mod tests {
audio_duration: Some(Seconds::from_seconds(1)), audio_duration: Some(Seconds::from_seconds(1)),
}); });
let expected_json = r#"{"type":"audio","id":"id","audio_url":"http://audio_url/","title":"title","caption":"caption","parse_mode":"HTML","performer":"performer","audio_duration":1,"reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"audio","id":"id","audio_url":"http://audio_url/","title":"title","caption":"caption","parse_mode":"HTML","performer":"performer","audio_duration":1,"reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -400,13 +398,12 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
caption_entities: None, caption_entities: None,
}); });
let expected_json = r#"{"type":"document","id":"id","title":"title","document_file_id":"document_file_id","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"document","id":"id","title":"title","document_file_id":"document_file_id","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -453,7 +450,6 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
thumbnail_url: Some(reqwest::Url::parse("http://thumb_url/").unwrap()), thumbnail_url: Some(reqwest::Url::parse("http://thumb_url/").unwrap()),
@ -461,7 +457,7 @@ mod tests {
thumbnail_height: Some(1), thumbnail_height: Some(1),
}); });
let expected_json = r#"{"type":"document","id":"id","title":"title","caption":"caption","parse_mode":"HTML","document_url":"http://document_url/","mime_type":"application/pdf","description":"description","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true},"thumbnail_url":"http://thumb_url/","thumbnail_width":1,"thumbnail_height":1}"#; let expected_json = r#"{"type":"document","id":"id","title":"title","caption":"caption","parse_mode":"HTML","document_url":"http://document_url/","mime_type":"application/pdf","description":"description","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"},"thumbnail_url":"http://thumb_url/","thumbnail_width":1,"thumbnail_height":1}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -501,12 +497,11 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
}); });
let expected_json = r#"{"type":"gif","id":"id","gif_file_id":"gif_file_id","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"gif","id":"id","gif_file_id":"gif_file_id","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -556,12 +551,11 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
}); });
let expected_json = r#"{"type":"gif","id":"id","gif_url":"http://gif_url/","gif_width":1,"gif_height":1,"gif_duration":1,"thumbnail_url":"http://thumb_url/","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"gif","id":"id","gif_url":"http://gif_url/","gif_width":1,"gif_height":1,"gif_duration":1,"thumbnail_url":"http://thumb_url/","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -601,12 +595,11 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
}); });
let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_file_id":"mpeg4_file_id","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_file_id":"mpeg4_file_id","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -656,12 +649,11 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
}); });
let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_url":"http://mpeg4_url/","mpeg4_width":1,"mpeg4_height":1,"mpeg4_duration":1,"thumbnail_url":"http://thumb_url/","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_url":"http://mpeg4_url/","mpeg4_width":1,"mpeg4_height":1,"mpeg4_duration":1,"thumbnail_url":"http://thumb_url/","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -703,12 +695,11 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
}); });
let expected_json = r#"{"type":"photo","id":"id","photo_file_id":"photo_file_id","title":"title","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"photo","id":"id","photo_file_id":"photo_file_id","title":"title","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -756,12 +747,11 @@ mod tests {
input_message_content: Some(InputMessageContent::Text(InputMessageContentText { input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"), message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None, entities: None,
})), })),
}); });
let expected_json = r#"{"type":"photo","id":"id","photo_url":"http://photo_url/","thumbnail_url":"http://thumb_url/","photo_width":1,"photo_height":1,"title":"title","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"photo","id":"id","photo_url":"http://photo_url/","thumbnail_url":"http://thumb_url/","photo_width":1,"photo_height":1,"title":"title","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -794,11 +784,10 @@ mod tests {
message_text: String::from("message_text"), message_text: String::from("message_text"),
entities: None, entities: None,
parse_mode: Some(ParseMode::MarkdownV2), parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
})), })),
}); });
let expected_json = r#"{"type":"sticker","id":"id","sticker_file_id":"sticker_file_id","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let expected_json = r#"{"type":"sticker","id":"id","sticker_file_id":"sticker_file_id","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2"}}"#;
let actual_json = serde_json::to_string(&structure).unwrap(); let actual_json = serde_json::to_string(&structure).unwrap();
assert_eq!(expected_json, actual_json); assert_eq!(expected_json, actual_json);
@ -1029,7 +1018,6 @@ mod tests {
message_text: String::from("message_text"), message_text: String::from("message_text"),
entities: None, entities: None,
parse_mode: None, parse_mode: None,
disable_web_page_preview: None,
}), }),
reply_markup: None, reply_markup: None,
url: None, url: None,
@ -1056,7 +1044,6 @@ mod tests {
message_text: String::from("message_text"), message_text: String::from("message_text"),
entities: None, entities: None,
parse_mode: None, parse_mode: None,
disable_web_page_preview: None,
}), }),
reply_markup: Some(InlineKeyboardMarkup::default()), reply_markup: Some(InlineKeyboardMarkup::default()),
url: Some(Url::parse("http://url/").unwrap()), url: Some(Url::parse("http://url/").unwrap()),
@ -1109,7 +1096,6 @@ mod tests {
message_text: String::from("message_text"), message_text: String::from("message_text"),
entities: None, entities: None,
parse_mode: None, parse_mode: None,
disable_web_page_preview: None,
})), })),
thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()), thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
thumbnail_width: Some(1), thumbnail_width: Some(1),
@ -1195,7 +1181,6 @@ mod tests {
message_text: String::from("message_text"), message_text: String::from("message_text"),
entities: None, entities: None,
parse_mode: None, parse_mode: None,
disable_web_page_preview: None,
})), })),
thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()), thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
thumbnail_width: Some(1), thumbnail_width: Some(1),
@ -1252,7 +1237,6 @@ mod tests {
message_text: String::from("message_text"), message_text: String::from("message_text"),
entities: None, entities: None,
parse_mode: None, parse_mode: None,
disable_web_page_preview: None,
})), })),
thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()), thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
thumbnail_width: Some(1), thumbnail_width: Some(1),

View file

@ -35,9 +35,6 @@ pub struct InputMessageContentText {
/// List of special entities that appear in message text, which can be /// List of special entities that appear in message text, which can be
/// specified instead of `parse_mode`. /// specified instead of `parse_mode`.
pub entities: Option<Vec<MessageEntity>>, pub entities: Option<Vec<MessageEntity>>,
/// Disables link previews for links in the sent message.
pub disable_web_page_preview: Option<bool>,
} }
impl InputMessageContentText { impl InputMessageContentText {
@ -45,12 +42,7 @@ impl InputMessageContentText {
where where
S: Into<String>, S: Into<String>,
{ {
Self { Self { message_text: message_text.into(), parse_mode: None, entities: None }
message_text: message_text.into(),
parse_mode: None,
disable_web_page_preview: None,
entities: None,
}
} }
pub fn message_text<S>(mut self, val: S) -> Self pub fn message_text<S>(mut self, val: S) -> Self
@ -74,12 +66,6 @@ impl InputMessageContentText {
self.entities = Some(val.into_iter().collect()); self.entities = Some(val.into_iter().collect());
self self
} }
#[must_use]
pub fn disable_web_page_preview(mut self, val: bool) -> Self {
self.disable_web_page_preview = Some(val);
self
}
} }
/// Represents the content of a location message to be sent as the result of an /// Represents the content of a location message to be sent as the result of an
@ -587,7 +573,6 @@ mod tests {
let text_content = InputMessageContent::Text(InputMessageContentText { let text_content = InputMessageContent::Text(InputMessageContentText {
message_text: String::from("text"), message_text: String::from("text"),
parse_mode: None, parse_mode: None,
disable_web_page_preview: None,
entities: None, entities: None,
}); });