mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
refactor: prepare_msg_raw(): don't return MsgId
The function takes `&mut Message` and updates its `id` and `chat_id` before return.
This commit is contained in:
13
src/chat.rs
13
src/chat.rs
@@ -1957,7 +1957,7 @@ impl Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Adds missing values to the msg object,
|
/// Adds missing values to the msg object,
|
||||||
/// writes the record to the database and returns its msg_id.
|
/// writes the record to the database.
|
||||||
///
|
///
|
||||||
/// If `update_msg_id` is set, that record is reused;
|
/// If `update_msg_id` is set, that record is reused;
|
||||||
/// if `update_msg_id` is None, a new record is created.
|
/// if `update_msg_id` is None, a new record is created.
|
||||||
@@ -1966,7 +1966,7 @@ impl Chat {
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
msg: &mut Message,
|
msg: &mut Message,
|
||||||
update_msg_id: Option<MsgId>,
|
update_msg_id: Option<MsgId>,
|
||||||
) -> Result<MsgId> {
|
) -> Result<()> {
|
||||||
let mut to_id = 0;
|
let mut to_id = 0;
|
||||||
let mut location_id = 0;
|
let mut location_id = 0;
|
||||||
|
|
||||||
@@ -2244,7 +2244,7 @@ impl Chat {
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
context.scheduler.interrupt_ephemeral_task().await;
|
context.scheduler.interrupt_ephemeral_task().await;
|
||||||
Ok(msg.id)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a `SyncAction` synchronising chat contacts to other devices.
|
/// Sends a `SyncAction` synchronising chat contacts to other devices.
|
||||||
@@ -2972,8 +2972,7 @@ async fn prepare_send_msg(
|
|||||||
if !msg.hidden {
|
if !msg.hidden {
|
||||||
chat_id.unarchive_if_not_muted(context, msg.state).await?;
|
chat_id.unarchive_if_not_muted(context, msg.state).await?;
|
||||||
}
|
}
|
||||||
msg.id = chat.prepare_msg_raw(context, msg, update_msg_id).await?;
|
chat.prepare_msg_raw(context, msg, update_msg_id).await?;
|
||||||
msg.chat_id = chat_id;
|
|
||||||
|
|
||||||
let row_ids = create_send_msg_jobs(context, msg)
|
let row_ids = create_send_msg_jobs(context, msg)
|
||||||
.await
|
.await
|
||||||
@@ -4464,13 +4463,13 @@ pub async fn forward_msgs(context: &Context, msg_ids: &[MsgId], chat_id: ChatId)
|
|||||||
msg.state = MessageState::OutPending;
|
msg.state = MessageState::OutPending;
|
||||||
msg.rfc724_mid = create_outgoing_rfc724_mid();
|
msg.rfc724_mid = create_outgoing_rfc724_mid();
|
||||||
msg.timestamp_sort = curr_timestamp;
|
msg.timestamp_sort = curr_timestamp;
|
||||||
let new_msg_id = chat.prepare_msg_raw(context, &mut msg, None).await?;
|
chat.prepare_msg_raw(context, &mut msg, None).await?;
|
||||||
|
|
||||||
curr_timestamp += 1;
|
curr_timestamp += 1;
|
||||||
if !create_send_msg_jobs(context, &mut msg).await?.is_empty() {
|
if !create_send_msg_jobs(context, &mut msg).await?.is_empty() {
|
||||||
context.scheduler.interrupt_smtp().await;
|
context.scheduler.interrupt_smtp().await;
|
||||||
}
|
}
|
||||||
created_msgs.push(new_msg_id);
|
created_msgs.push(msg.id);
|
||||||
}
|
}
|
||||||
for msg_id in created_msgs {
|
for msg_id in created_msgs {
|
||||||
context.emit_msgs_changed(chat_id, msg_id);
|
context.emit_msgs_changed(chat_id, msg_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user