Skip to content

Commit

Permalink
do not allow special chat_id in send_msg
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Dec 9, 2024
1 parent 97ee78e commit 2f7969b
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2785,25 +2785,8 @@ pub async fn is_contact_in_chat(
/// However, this does not imply, the message really reached the recipient -
/// sending may be delayed eg. due to network problems. However, from your
/// view, you're done with the message. Sooner or later it will find its way.
// TODO: Do not allow ChatId to be 0, if prepare_msg had been called
// the caller can get it from msg.chat_id. Forwards would need to
// be fixed for this somehow too.
pub async fn send_msg(context: &Context, chat_id: ChatId, msg: &mut Message) -> Result<MsgId> {
if chat_id.is_unset() {
let forwards = msg.param.get(Param::PrepForwards);
if let Some(forwards) = forwards {
for forward in forwards.split(' ') {
if let Ok(msg_id) = forward.parse::<u32>().map(MsgId::new) {
if let Ok(mut msg) = Message::load_from_db(context, msg_id).await {
send_msg_inner(context, chat_id, &mut msg).await?;
};
}
}
msg.param.remove(Param::PrepForwards);
msg.update_param(context).await?;
}
return send_msg_inner(context, chat_id, msg).await;
}
ensure!(!chat_id.is_special(), "chat_id cannot be a special chat: {chat_id}");

if msg.state != MessageState::Undefined && msg.state != MessageState::OutPreparing {
msg.param.remove(Param::GuaranteeE2ee);
Expand Down

0 comments on commit 2f7969b

Please sign in to comment.