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:
bjoern
2022-06-10 16:41:20 +02:00
committed by GitHub
parent 1fb6d1b59d
commit 78f9383332
4 changed files with 18 additions and 17 deletions

View File

@@ -1951,7 +1951,7 @@ pub async fn send_msg(context: &Context, chat_id: ChatId, msg: &mut Message) ->
}
}
msg.param.remove(Param::PrepForwards);
msg.update_param(context).await;
msg.update_param(context).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 {
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");
@@ -2128,7 +2128,7 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result<Option<
let recipients = recipients.join(" ");
msg.subject = rendered_msg.subject.clone();
msg.update_subject(context).await;
msg.update_subject(context).await?;
let row_id = context
.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());
}
msg.update_param(context).await;
msg.update_param(context).await?;
msg.param = save_param;
} else {
msg.state = MessageState::OutPending;
@@ -3165,7 +3165,7 @@ pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
for mut msg in msgs {
if msg.get_showpadlock() && !chat.is_protected() {
msg.param.remove(Param::GuaranteeE2ee);
msg.update_param(context).await;
msg.update_param(context).await?;
}
match msg.get_state() {
MessageState::OutFailed | MessageState::OutDelivered | MessageState::OutMdnRcvd => {

View File

@@ -23,7 +23,6 @@ use crate::download::DownloadState;
use crate::ephemeral::{start_ephemeral_timers_msgids, Timer as EphemeralTimer};
use crate::events::EventType;
use crate::imap::markseen_on_imap_table;
use crate::log::LogExt;
use crate::mimeparser::{parse_message_id, FailureReport, SystemMessage};
use crate::param::{Param, Params};
use crate::pgp::split_armored_data;
@@ -404,7 +403,7 @@ impl Message {
}
if !self.id.is_unset() {
self.update_param(context).await;
self.update_param(context).await?;
}
}
}
@@ -762,7 +761,7 @@ impl Message {
width: i32,
height: i32,
duration: i32,
) {
) -> Result<()> {
if width > 0 && height > 0 {
self.param.set_int(Param::Width, width);
self.param.set_int(Param::Height, height);
@@ -770,7 +769,8 @@ impl Message {
if duration > 0 {
self.param.set_int(Param::Duration, duration);
}
self.update_param(context).await;
self.update_param(context).await?;
Ok(())
}
/// Sets message quote.
@@ -850,26 +850,26 @@ impl Message {
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
.sql
.execute(
"UPDATE msgs SET param=? WHERE id=?;",
paramsv![self.param.to_string(), self.id],
)
.await
.ok_or_log(context);
.await?;
Ok(())
}
pub(crate) async fn update_subject(&self, context: &Context) {
pub(crate) async fn update_subject(&self, context: &Context) -> Result<()> {
context
.sql
.execute(
"UPDATE msgs SET subject=? WHERE id=?;",
paramsv![self.subject, self.id],
)
.await
.ok_or_log(context);
.await?;
Ok(())
}
/// Gets the error status of the message.

View File

@@ -306,7 +306,7 @@ impl Context {
}
if param_changed {
instance.update_param(self).await;
instance.update_param(self).await?;
self.emit_msgs_changed(instance.chat_id, instance.id);
}