mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
set empty url in WebhookInfo to None
This commit is contained in:
parent
3ccb8f0cde
commit
ba2305dbe5
1 changed files with 8 additions and 0 deletions
|
@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
|
|||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct WebhookInfo {
|
||||
#[serde(deserialize_with = "empty_string_to_url")]
|
||||
/// Webhook URL, `None` if webhook is not set up.
|
||||
pub url: Option<reqwest::Url>,
|
||||
|
||||
|
@ -37,3 +38,10 @@ pub struct WebhookInfo {
|
|||
/// types.
|
||||
pub allowed_updates: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
fn empty_string_to_url<'de, D>(deserializer: D) -> Result<Option<reqwest::Url>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
Ok(reqwest::Url::deserialize(deserializer).ok())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue