mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
fix: Set Param::GuaranteeE2ee before preparing message blob (#8090)
Otherwise `Param::GuaranteeE2ee` is set only after rendering the message and some UIs, e.g. DC Android, display the message as unencrypted while preparing the blob and rendering and encrypting the message. NB: DC Desktop doesn't display the message until `send_msg()` returns. --------- Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
16
src/chat.rs
16
src/chat.rs
@@ -2628,7 +2628,7 @@ pub async fn send_msg(context: &Context, chat_id: ChatId, msg: &mut Message) ->
|
|||||||
if msg.state != MessageState::Undefined && msg.state != MessageState::OutPreparing {
|
if msg.state != MessageState::Undefined && msg.state != MessageState::OutPreparing {
|
||||||
msg.param.remove(Param::GuaranteeE2ee);
|
msg.param.remove(Param::GuaranteeE2ee);
|
||||||
msg.param.remove(Param::ForcePlaintext);
|
msg.param.remove(Param::ForcePlaintext);
|
||||||
msg.update_param(context).await?;
|
// create_send_msg_jobs() will update `param` in the db.
|
||||||
}
|
}
|
||||||
|
|
||||||
// protect all system messages against RTLO attacks
|
// protect all system messages against RTLO attacks
|
||||||
@@ -2733,7 +2733,19 @@ async fn prepare_send_msg(
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
// ... then change the MessageState in the message object
|
if matches!(
|
||||||
|
msg.state,
|
||||||
|
MessageState::Undefined | MessageState::OutPreparing
|
||||||
|
)
|
||||||
|
// Legacy SecureJoin "v*-request" messages are unencrypted.
|
||||||
|
&& msg.param.get_cmd() != SystemMessage::SecurejoinMessage
|
||||||
|
&& chat.is_encrypted(context).await?
|
||||||
|
{
|
||||||
|
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
||||||
|
if !msg.id.is_unset() {
|
||||||
|
msg.update_param(context).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
msg.state = MessageState::OutPending;
|
msg.state = MessageState::OutPending;
|
||||||
|
|
||||||
msg.timestamp_sort = create_smeared_timestamp(context);
|
msg.timestamp_sort = create_smeared_timestamp(context);
|
||||||
|
|||||||
@@ -1392,6 +1392,8 @@ pub enum MessageState {
|
|||||||
/// For files which need time to be prepared before they can be
|
/// For files which need time to be prepared before they can be
|
||||||
/// sent, the message enters this state before
|
/// sent, the message enters this state before
|
||||||
/// OutPending.
|
/// OutPending.
|
||||||
|
///
|
||||||
|
/// Deprecated 2024-12-07.
|
||||||
OutPreparing = 18,
|
OutPreparing = 18,
|
||||||
|
|
||||||
/// Message saved as draft.
|
/// Message saved as draft.
|
||||||
|
|||||||
Reference in New Issue
Block a user