Skip to content

Commit

Permalink
Avoid panic in join_chat
Browse files Browse the repository at this point in the history
Closes �#286.
  • Loading branch information
Lonami committed Nov 6, 2024
1 parent 2975e03 commit 6140149
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/grammers-client/src/client/chats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,13 +835,19 @@ impl Client {
&self,
chat: C,
) -> Result<Option<Chat>, InvocationError> {
let chat = chat.into();
let chat: PackedChat = chat.into();
let channel = chat.try_to_input_channel().ok_or_else(|| {
InvocationError::Rpc(RpcError {
code: 400,
name: "CHANNEL_INVALID".to_owned(),
value: None,
caused_by: None,
})
})?;
Ok(updates_to_chat(
Some(chat.id),
self.invoke(&tl::functions::channels::JoinChannel {
channel: chat.try_to_input_channel().unwrap(),
})
.await?,
self.invoke(&tl::functions::channels::JoinChannel { channel })
.await?,
))
}

Expand Down

0 comments on commit 6140149

Please sign in to comment.