Fix parsing for posts in private channels

This commit is contained in:
Maximilian Siling 2020-02-11 19:28:46 +03:00
parent 868f39c2e8
commit 423495d1c7
3 changed files with 6 additions and 6 deletions

View file

@ -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,
} }
} }

View file

@ -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,
}, },

View file

@ -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,
}, },