mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 10:56:29 +03:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user