add dc_msg_set_html() api (#2153)

* draft dc_msg_set_html() api

* implement setting 'html to be send'

* test sending html-parts

* more flexible html-partbuilder

* write html-parts to database and also send them

* add 'sendhtml' command to repl tool
This commit is contained in:
bjoern
2021-01-27 12:56:22 +01:00
committed by GitHub
parent c8c2724c28
commit 1e6d8063c8
8 changed files with 146 additions and 30 deletions

View File

@@ -14,6 +14,7 @@ use crate::dc_tools::{
use crate::e2ee::EncryptHelper;
use crate::ephemeral::Timer as EphemeralTimer;
use crate::format_flowed::{format_flowed, format_flowed_quote};
use crate::html::new_html_mimepart;
use crate::location;
use crate::message::{self, Message, MsgId};
use crate::mimeparser::SystemMessage;
@@ -966,14 +967,16 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
// add HTML-part, this is needed only if a HTML-message from a non-delta-client is forwarded;
// for simplificity and to avoid conversion errors, we're generating the HTML-part from the original message.
if self.msg.has_html() {
if let Some(orig_msg_id) = self.msg.param.get_int(Param::Forwarded) {
let orig_msg_id = MsgId::new(orig_msg_id.try_into()?);
if let Some(html_part) = orig_msg_id.get_html_as_mimepart(context).await {
main_part = PartBuilder::new()
.message_type(MimeMultipartType::Alternative)
.child(main_part.build())
.child(html_part.build());
}
let html = if let Some(orig_msg_id) = self.msg.param.get_int(Param::Forwarded) {
MsgId::new(orig_msg_id.try_into()?).get_html(context).await
} else {
self.msg.param.get(Param::SendHtml).map(|s| s.to_string())
};
if let Some(html) = html {
main_part = PartBuilder::new()
.message_type(MimeMultipartType::Alternative)
.child(main_part.build())
.child(new_html_mimepart(html).await.build());
}
}