mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 17:52:12 +01:00
Fix parsing for posts in private channels
This commit is contained in:
parent
868f39c2e8
commit
423495d1c7
3 changed files with 6 additions and 6 deletions
|
@ -35,7 +35,7 @@ pub enum MessageKind {
|
||||||
Common {
|
Common {
|
||||||
/// Sender, empty for messages sent to channels.
|
/// Sender, empty for messages sent to channels.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
from: Sender,
|
from: Option<Sender>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
forward_kind: ForwardKind,
|
forward_kind: ForwardKind,
|
||||||
|
@ -352,7 +352,7 @@ mod getters {
|
||||||
/// NOTE: this is getter for both `from` and `author_signature`
|
/// NOTE: this is getter for both `from` and `author_signature`
|
||||||
pub fn from(&self) -> Option<&Sender> {
|
pub fn from(&self) -> Option<&Sender> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common { from, .. } => Some(from),
|
Common { from, .. } => from.as_ref(),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,14 +116,14 @@ mod tests {
|
||||||
photo: None,
|
photo: None,
|
||||||
},
|
},
|
||||||
kind: MessageKind::Common {
|
kind: MessageKind::Common {
|
||||||
from: Sender::User(User {
|
from: Some(Sender::User(User {
|
||||||
id: 0,
|
id: 0,
|
||||||
is_bot: false,
|
is_bot: false,
|
||||||
first_name: "".to_string(),
|
first_name: "".to_string(),
|
||||||
last_name: None,
|
last_name: None,
|
||||||
username: None,
|
username: None,
|
||||||
language_code: None,
|
language_code: None,
|
||||||
}),
|
})),
|
||||||
forward_kind: ForwardKind::Origin {
|
forward_kind: ForwardKind::Origin {
|
||||||
reply_to_message: None,
|
reply_to_message: None,
|
||||||
},
|
},
|
||||||
|
|
|
@ -158,14 +158,14 @@ mod test {
|
||||||
photo: None,
|
photo: None,
|
||||||
},
|
},
|
||||||
kind: MessageKind::Common {
|
kind: MessageKind::Common {
|
||||||
from: Sender::User(User {
|
from: Some(Sender::User(User {
|
||||||
id: 218_485_655,
|
id: 218_485_655,
|
||||||
is_bot: false,
|
is_bot: false,
|
||||||
first_name: String::from("Waffle"),
|
first_name: String::from("Waffle"),
|
||||||
last_name: None,
|
last_name: None,
|
||||||
username: Some(String::from("WaffleLapkin")),
|
username: Some(String::from("WaffleLapkin")),
|
||||||
language_code: Some(LanguageCode::EN),
|
language_code: Some(LanguageCode::EN),
|
||||||
}),
|
})),
|
||||||
forward_kind: ForwardKind::Origin {
|
forward_kind: ForwardKind::Origin {
|
||||||
reply_to_message: None,
|
reply_to_message: None,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue