mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
bubble up errors from update_param() and some related functions (#3415)
* bubble up errors from update_param() and some related functions * log bubbled-up error in ffi
This commit is contained in:
@@ -3574,7 +3574,8 @@ pub unsafe extern "C" fn dc_msg_latefiling_mediasize(
|
|||||||
ffi_msg
|
ffi_msg
|
||||||
.message
|
.message
|
||||||
.latefiling_mediasize(ctx, width, height, duration)
|
.latefiling_mediasize(ctx, width, height, duration)
|
||||||
});
|
})
|
||||||
|
.ok_or_log_msg(ctx, "Cannot set media size");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
10
src/chat.rs
10
src/chat.rs
@@ -1951,7 +1951,7 @@ pub async fn send_msg(context: &Context, chat_id: ChatId, msg: &mut Message) ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.param.remove(Param::PrepForwards);
|
msg.param.remove(Param::PrepForwards);
|
||||||
msg.update_param(context).await;
|
msg.update_param(context).await?;
|
||||||
}
|
}
|
||||||
return send_msg_inner(context, chat_id, msg).await;
|
return send_msg_inner(context, chat_id, msg).await;
|
||||||
}
|
}
|
||||||
@@ -2120,7 +2120,7 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result<Option<
|
|||||||
|
|
||||||
if rendered_msg.is_encrypted && !needs_encryption {
|
if rendered_msg.is_encrypted && !needs_encryption {
|
||||||
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
||||||
msg.update_param(context).await;
|
msg.update_param(context).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure!(!recipients.is_empty(), "no recipients for smtp job set");
|
ensure!(!recipients.is_empty(), "no recipients for smtp job set");
|
||||||
@@ -2128,7 +2128,7 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result<Option<
|
|||||||
let recipients = recipients.join(" ");
|
let recipients = recipients.join(" ");
|
||||||
|
|
||||||
msg.subject = rendered_msg.subject.clone();
|
msg.subject = rendered_msg.subject.clone();
|
||||||
msg.update_subject(context).await;
|
msg.update_subject(context).await?;
|
||||||
|
|
||||||
let row_id = context
|
let row_id = context
|
||||||
.sql
|
.sql
|
||||||
@@ -3117,7 +3117,7 @@ pub async fn forward_msgs(context: &Context, msg_ids: &[MsgId], chat_id: ChatId)
|
|||||||
.set(Param::PrepForwards, new_msg_id.to_u32().to_string());
|
.set(Param::PrepForwards, new_msg_id.to_u32().to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.update_param(context).await;
|
msg.update_param(context).await?;
|
||||||
msg.param = save_param;
|
msg.param = save_param;
|
||||||
} else {
|
} else {
|
||||||
msg.state = MessageState::OutPending;
|
msg.state = MessageState::OutPending;
|
||||||
@@ -3165,7 +3165,7 @@ pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
|
|||||||
for mut msg in msgs {
|
for mut msg in msgs {
|
||||||
if msg.get_showpadlock() && !chat.is_protected() {
|
if msg.get_showpadlock() && !chat.is_protected() {
|
||||||
msg.param.remove(Param::GuaranteeE2ee);
|
msg.param.remove(Param::GuaranteeE2ee);
|
||||||
msg.update_param(context).await;
|
msg.update_param(context).await?;
|
||||||
}
|
}
|
||||||
match msg.get_state() {
|
match msg.get_state() {
|
||||||
MessageState::OutFailed | MessageState::OutDelivered | MessageState::OutMdnRcvd => {
|
MessageState::OutFailed | MessageState::OutDelivered | MessageState::OutMdnRcvd => {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use crate::download::DownloadState;
|
|||||||
use crate::ephemeral::{start_ephemeral_timers_msgids, Timer as EphemeralTimer};
|
use crate::ephemeral::{start_ephemeral_timers_msgids, Timer as EphemeralTimer};
|
||||||
use crate::events::EventType;
|
use crate::events::EventType;
|
||||||
use crate::imap::markseen_on_imap_table;
|
use crate::imap::markseen_on_imap_table;
|
||||||
use crate::log::LogExt;
|
|
||||||
use crate::mimeparser::{parse_message_id, FailureReport, SystemMessage};
|
use crate::mimeparser::{parse_message_id, FailureReport, SystemMessage};
|
||||||
use crate::param::{Param, Params};
|
use crate::param::{Param, Params};
|
||||||
use crate::pgp::split_armored_data;
|
use crate::pgp::split_armored_data;
|
||||||
@@ -404,7 +403,7 @@ impl Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !self.id.is_unset() {
|
if !self.id.is_unset() {
|
||||||
self.update_param(context).await;
|
self.update_param(context).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -762,7 +761,7 @@ impl Message {
|
|||||||
width: i32,
|
width: i32,
|
||||||
height: i32,
|
height: i32,
|
||||||
duration: i32,
|
duration: i32,
|
||||||
) {
|
) -> Result<()> {
|
||||||
if width > 0 && height > 0 {
|
if width > 0 && height > 0 {
|
||||||
self.param.set_int(Param::Width, width);
|
self.param.set_int(Param::Width, width);
|
||||||
self.param.set_int(Param::Height, height);
|
self.param.set_int(Param::Height, height);
|
||||||
@@ -770,7 +769,8 @@ impl Message {
|
|||||||
if duration > 0 {
|
if duration > 0 {
|
||||||
self.param.set_int(Param::Duration, duration);
|
self.param.set_int(Param::Duration, duration);
|
||||||
}
|
}
|
||||||
self.update_param(context).await;
|
self.update_param(context).await?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets message quote.
|
/// Sets message quote.
|
||||||
@@ -850,26 +850,26 @@ impl Message {
|
|||||||
self.param.set_int(Param::ForcePlaintext, 1);
|
self.param.set_int(Param::ForcePlaintext, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_param(&self, context: &Context) {
|
pub async fn update_param(&self, context: &Context) -> Result<()> {
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"UPDATE msgs SET param=? WHERE id=?;",
|
"UPDATE msgs SET param=? WHERE id=?;",
|
||||||
paramsv![self.param.to_string(), self.id],
|
paramsv![self.param.to_string(), self.id],
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.ok_or_log(context);
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn update_subject(&self, context: &Context) {
|
pub(crate) async fn update_subject(&self, context: &Context) -> Result<()> {
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"UPDATE msgs SET subject=? WHERE id=?;",
|
"UPDATE msgs SET subject=? WHERE id=?;",
|
||||||
paramsv![self.subject, self.id],
|
paramsv![self.subject, self.id],
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.ok_or_log(context);
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the error status of the message.
|
/// Gets the error status of the message.
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if param_changed {
|
if param_changed {
|
||||||
instance.update_param(self).await;
|
instance.update_param(self).await?;
|
||||||
self.emit_msgs_changed(instance.chat_id, instance.id);
|
self.emit_msgs_changed(instance.chat_id, instance.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user