Merge branch 'rework-dispatching' of https://github.com/teloxide/teloxide into rework-dispatching

This commit is contained in:
Temirkhan Myrzamadi 2020-02-11 22:56:59 +06:00
commit 44471d3090
3 changed files with 6 additions and 6 deletions

View file

@ -35,7 +35,7 @@ pub enum MessageKind {
Common {
/// Sender, empty for messages sent to channels.
#[serde(flatten)]
from: Sender,
from: Option<Sender>,
#[serde(flatten)]
forward_kind: ForwardKind,
@ -352,7 +352,7 @@ mod getters {
/// NOTE: this is getter for both `from` and `author_signature`
pub fn from(&self) -> Option<&Sender> {
match &self.kind {
Common { from, .. } => Some(from),
Common { from, .. } => from.as_ref(),
_ => None,
}
}

View file

@ -116,14 +116,14 @@ mod tests {
photo: None,
},
kind: MessageKind::Common {
from: Sender::User(User {
from: Some(Sender::User(User {
id: 0,
is_bot: false,
first_name: "".to_string(),
last_name: None,
username: None,
language_code: None,
}),
})),
forward_kind: ForwardKind::Origin {
reply_to_message: None,
},

View file

@ -158,14 +158,14 @@ mod test {
photo: None,
},
kind: MessageKind::Common {
from: Sender::User(User {
from: Some(Sender::User(User {
id: 218_485_655,
is_bot: false,
first_name: String::from("Waffle"),
last_name: None,
username: Some(String::from("WaffleLapkin")),
language_code: Some(LanguageCode::EN),
}),
})),
forward_kind: ForwardKind::Origin {
reply_to_message: None,
},