mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Replace Option<bool>
with bool
in LinkPreviewOptions
This commit is contained in:
parent
ae88d60b4e
commit
4870338a75
4 changed files with 80 additions and 76 deletions
|
@ -305,11 +305,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
caption_entities: None,
|
||||
|
@ -359,11 +359,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
caption_entities: None,
|
||||
|
@ -414,11 +414,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
caption_entities: None,
|
||||
|
@ -473,11 +473,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
thumbnail_url: Some(reqwest::Url::parse("http://thumb_url/").unwrap()),
|
||||
|
@ -527,11 +527,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
});
|
||||
|
@ -588,11 +588,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
});
|
||||
|
@ -639,11 +639,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
});
|
||||
|
@ -700,11 +700,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
});
|
||||
|
@ -753,11 +753,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
});
|
||||
|
@ -812,11 +812,11 @@ mod tests {
|
|||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
});
|
||||
|
@ -855,11 +855,11 @@ mod tests {
|
|||
entities: None,
|
||||
parse_mode: Some(ParseMode::MarkdownV2),
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
});
|
||||
|
@ -1095,11 +1095,11 @@ mod tests {
|
|||
message_text: String::from("message_text"),
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
parse_mode: None,
|
||||
}),
|
||||
|
@ -1129,11 +1129,11 @@ mod tests {
|
|||
entities: None,
|
||||
parse_mode: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
}),
|
||||
reply_markup: Some(InlineKeyboardMarkup::default()),
|
||||
|
@ -1188,11 +1188,11 @@ mod tests {
|
|||
entities: None,
|
||||
parse_mode: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
|
||||
|
@ -1280,11 +1280,11 @@ mod tests {
|
|||
entities: None,
|
||||
parse_mode: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
|
||||
|
@ -1343,11 +1343,11 @@ mod tests {
|
|||
entities: None,
|
||||
parse_mode: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
})),
|
||||
thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
|
||||
|
|
|
@ -590,11 +590,11 @@ mod tests {
|
|||
parse_mode: None,
|
||||
entities: None,
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ use serde::{Deserialize, Serialize};
|
|||
#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct LinkPreviewOptions {
|
||||
/// `true`, if the link preview is disabled
|
||||
pub is_disabled: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub is_disabled: bool,
|
||||
|
||||
/// URL to use for the link preview. If empty, then the first URL found in
|
||||
/// the message text will be used
|
||||
|
@ -14,16 +15,19 @@ pub struct LinkPreviewOptions {
|
|||
/// `true`, if the media in the link preview is suppposed to be shrunk;
|
||||
/// ignored if the URL isn't explicitly specified or media size change isn't
|
||||
/// supported for the preview
|
||||
pub prefer_small_media: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub prefer_small_media: bool,
|
||||
|
||||
/// `true`, if the media in the link preview is suppposed to be enlarged;
|
||||
/// ignored if the URL isn't explicitly specified or media size change isn't
|
||||
/// supported for the preview
|
||||
pub prefer_large_media: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub prefer_large_media: bool,
|
||||
|
||||
/// `true`, if the link preview must be shown above the message text;
|
||||
/// otherwise, the link preview will be shown below the message text
|
||||
pub show_above_text: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub show_above_text: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -553,11 +553,11 @@ mod test {
|
|||
text: String::from("hello there"),
|
||||
entities: vec![],
|
||||
link_preview_options: Some(LinkPreviewOptions {
|
||||
is_disabled: Some(true),
|
||||
is_disabled: true,
|
||||
url: None,
|
||||
prefer_small_media: None,
|
||||
prefer_large_media: None,
|
||||
show_above_text: None,
|
||||
prefer_small_media: false,
|
||||
prefer_large_media: false,
|
||||
show_above_text: false,
|
||||
}),
|
||||
}),
|
||||
reply_markup: None,
|
||||
|
|
Loading…
Reference in a new issue