mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
feat: do not require resent messages to be from the same chat
Chat was only loaded to avoid removing GuaranteeE2ee for protected chats, but resending a message in protected chat is guaranteed to be encrypted anyway.
This commit is contained in:
24
src/chat.rs
24
src/chat.rs
@@ -4542,18 +4542,9 @@ pub(crate) async fn save_copy_in_self_talk(
|
|||||||
///
|
///
|
||||||
/// This is primarily intended to make existing webxdcs available to new chat members.
|
/// This is primarily intended to make existing webxdcs available to new chat members.
|
||||||
pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
|
pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
|
||||||
let mut chat_id = None;
|
|
||||||
let mut msgs: Vec<Message> = Vec::new();
|
let mut msgs: Vec<Message> = Vec::new();
|
||||||
for msg_id in msg_ids {
|
for msg_id in msg_ids {
|
||||||
let msg = Message::load_from_db(context, *msg_id).await?;
|
let msg = Message::load_from_db(context, *msg_id).await?;
|
||||||
if let Some(chat_id) = chat_id {
|
|
||||||
ensure!(
|
|
||||||
chat_id == msg.chat_id,
|
|
||||||
"messages to resend needs to be in the same chat"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
chat_id = Some(msg.chat_id);
|
|
||||||
}
|
|
||||||
ensure!(
|
ensure!(
|
||||||
msg.from_id == ContactId::SELF,
|
msg.from_id == ContactId::SELF,
|
||||||
"can resend only own messages"
|
"can resend only own messages"
|
||||||
@@ -4562,22 +4553,7 @@ pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
|
|||||||
msgs.push(msg)
|
msgs.push(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(chat_id) = chat_id else {
|
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
|
|
||||||
let chat = Chat::load_from_db(context, chat_id).await?;
|
|
||||||
for mut msg in msgs {
|
for mut msg in msgs {
|
||||||
if msg.get_showpadlock() && !chat.is_protected() {
|
|
||||||
msg.param.remove(Param::GuaranteeE2ee);
|
|
||||||
|
|
||||||
// Do not call `msg.update_param` here.
|
|
||||||
// We do not want the message to appear unencrypted
|
|
||||||
// if it is loaded precisely at this time.
|
|
||||||
//
|
|
||||||
// Actual encryption status is persisted
|
|
||||||
// by `create_send_msg_jobs` below.
|
|
||||||
}
|
|
||||||
match msg.get_state() {
|
match msg.get_state() {
|
||||||
// `get_state()` may return an outdated `OutPending`, so update anyway.
|
// `get_state()` may return an outdated `OutPending`, so update anyway.
|
||||||
MessageState::OutPending
|
MessageState::OutPending
|
||||||
|
|||||||
Reference in New Issue
Block a user