Skip to content

Commit

Permalink
actually on some rare occasions message_id of forwarded channel post
Browse files Browse the repository at this point in the history
might be missing. Make it optional
  • Loading branch information
kworr committed Aug 17, 2024
1 parent 408318a commit 11dfca1
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions raw/src/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub enum ForwardFrom {
/// Original channel.
channel: Channel,
/// Identifier of the original message in the channel
message_id: Integer,
message_id: Option<Integer>,
},
ChannelHiddenUser {
sender_name: String,
Expand Down Expand Up @@ -244,12 +244,12 @@ impl Message {
raw.forward_from_message_id,
&raw.forward_sender_name,
) {
(None, &None, &None, None, &None) => None,
(Some(date), Some(from), &None, None, &None) => Some(Forward {
(None, None, None, None, None) => None,
(Some(date), Some(from), None, None, None) => Some(Forward {
date,
from: ForwardFrom::User { user: from.clone() },
}),
(Some(date), &None, &Some(Chat::Channel(ref channel)), Some(message_id), &None) => {
(Some(date), None, Some(Chat::Channel(ref channel)), message_id, None) => {
Some(Forward {
date,
from: ForwardFrom::Channel {
Expand All @@ -258,7 +258,7 @@ impl Message {
},
})
}
(Some(date), &None, &None, None, Some(sender_name)) => Some(Forward {
(Some(date), None, None, None, Some(sender_name)) => Some(Forward {
date,
from: ForwardFrom::ChannelHiddenUser {
sender_name: sender_name.clone(),
Expand Down Expand Up @@ -404,16 +404,14 @@ impl ChannelPost {
date,
from: ForwardFrom::User { user: from.clone() },
}),
(Some(date), &None, Some(Chat::Channel(channel)), Some(message_id), &None) => {
Some(Forward {
date,
from: ForwardFrom::Channel {
channel: channel.clone(),
message_id,
},
})
}
(Some(date), &None, &None, None, Some(sender_name)) => Some(Forward {
(Some(date), None, Some(Chat::Channel(channel)), message_id, None) => Some(Forward {
date,
from: ForwardFrom::Channel {
channel: channel.clone(),
message_id,
},
}),
(Some(date), None, None, None, Some(sender_name)) => Some(Forward {
date,
from: ForwardFrom::ChannelHiddenUser {
sender_name: sender_name.clone(),
Expand Down

0 comments on commit 11dfca1

Please sign in to comment.