Save subject for messages 2: Outgoing messages (#2283)

* Save subject for sent-out messages

* Test that subject is saved (outgoing)

* Correctly set subject when forwarding messages, add test for this
This commit is contained in:
Hocuri
2021-03-14 15:07:49 +01:00
committed by GitHub
parent db3f87dd77
commit 7bc919fad5
5 changed files with 95 additions and 54 deletions

View File

@@ -22,6 +22,7 @@ use crate::dc_tools::{
use crate::ephemeral::Timer as EphemeralTimer;
use crate::events::EventType;
use crate::job::{self, Action};
use crate::log::LogExt;
use crate::lot::{Lot, LotState, Meaning};
use crate::mimeparser::{FailureReport, SystemMessage};
use crate::param::{Param, Params};
@@ -307,7 +308,6 @@ pub struct Message {
pub(crate) ephemeral_timer: EphemeralTimer,
pub(crate) ephemeral_timestamp: i64,
pub(crate) text: Option<String>,
/// The value of the Subject header. Not set for messages that we sent ourselves.
pub(crate) subject: String,
pub(crate) rfc724_mid: String,
pub(crate) in_reply_to: Option<String>,
@@ -912,7 +912,7 @@ impl Message {
Ok(None)
}
pub async fn update_param(&mut self, context: &Context) -> bool {
pub async fn update_param(&self, context: &Context) {
context
.sql
.execute(
@@ -920,7 +920,18 @@ impl Message {
paramsv![self.param.to_string(), self.id],
)
.await
.is_ok()
.ok_or_log(context);
}
pub(crate) async fn update_subject(&self, context: &Context) {
context
.sql
.execute(
"UPDATE msgs SET subject=? WHERE id=?;",
paramsv![self.subject, self.id],
)
.await
.ok_or_log(context);
}
/// Gets the error status of the message.