forward html-messages properly (#2151)

* add failing tests for forwarding html-mails

* let MsgId.get_html() return an option

* write html-part to local database on forwarding

* add html-part to forwarded non-dc messages

* read HTML-parts from encrypted messages

* avoid clone()

* Received:-header is no longer needed since #2152

* Update src/html.rs

Co-authored-by: Floris Bruynooghe <flub@devork.be>

* Update src/html.rs

Co-authored-by: Floris Bruynooghe <flub@devork.be>

* Update src/mimeparser.rs

Co-authored-by: Floris Bruynooghe <flub@devork.be>

* prefer 'orig' over 'org' as abbreviation for 'original'

* improve comment on tests

* prefer 'try_into()' over 'as u32' to avoid panics on bad data

* simplify ffi

Co-authored-by: Floris Bruynooghe <flub@devork.be>
This commit is contained in:
bjoern
2021-01-23 23:21:18 +01:00
committed by GitHub
parent 2a8c418d54
commit e9c582c4e4
8 changed files with 183 additions and 19 deletions

View File

@@ -1060,6 +1060,12 @@ impl Chat {
EphemeralTimer::Enabled { duration } => time() + i64::from(duration),
};
let new_mime_headers = if msg.param.exists(Param::Forwarded) && msg.mime_modified {
msg.get_id().get_html_as_rawmime(context).await
} else {
None
};
// add message to the database
if context
@@ -1078,10 +1084,12 @@ impl Chat {
hidden,
mime_in_reply_to,
mime_references,
mime_modified,
mime_headers,
location_id,
ephemeral_timer,
ephemeral_timestamp)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);",
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);",
paramsv![
new_rfc724_mid,
self.id,
@@ -1095,6 +1103,8 @@ impl Chat {
msg.hidden,
msg.in_reply_to.as_deref().unwrap_or_default(),
new_references,
new_mime_headers.is_some(),
new_mime_headers,
location_id as i32,
ephemeral_timer,
ephemeral_timestamp
@@ -2738,7 +2748,8 @@ pub async fn forward_msgs(
// we tested a sort of broadcast
// by not marking own forwarded messages as such,
// however, this turned out to be to confusing and unclear.
msg.param.set_int(Param::Forwarded, 1);
msg.param
.set_int(Param::Forwarded, src_msg_id.to_u32() as i32);
msg.param.remove(Param::GuaranteeE2ee);
msg.param.remove(Param::ForcePlaintext);