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

@@ -3679,6 +3679,33 @@ int dc_msg_has_html (dc_msg_t* msg);
void dc_msg_set_text (dc_msg_t* msg, const char* text);
/**
* Set the HTML part of a message object.
* As for all other dc_msg_t setters,
* this is only useful if the message is sent using dc_send_msg() later.
*
* Please note, that Delta Chat clients show the plain text set with
* dc_msg_set_text() at the first place;
* the HTML part is not shown instead of this text.
* However, for messages with HTML parts,
* on the receiver's device, dc_msg_has_html() will return 1
* and a button "Show full message" is typically shown.
*
* So adding a HTML part might be useful eg. for bots,
* that want to add rich content to a message, eg. a website;
* this HTML part is similar to an attachment then.
*
* **dc_msg_set_html() is currently not meant for sending a message,
* a "normal user" has typed in!**
* Use dc_msg_set_text() for that purpose.
*
* @memberof dc_msg_t
* @param msg The message object.
* @param html HTML to send.
*/
void dc_msg_set_html (dc_msg_t* msg, const char* html);
/**
* Set the file associated with a message object.
* This does not alter any information in the database

View File

@@ -2923,6 +2923,16 @@ pub unsafe extern "C" fn dc_msg_set_text(msg: *mut dc_msg_t, text: *const libc::
ffi_msg.message.set_text(to_opt_string_lossy(text))
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_set_html(msg: *mut dc_msg_t, html: *const libc::c_char) {
if msg.is_null() {
eprintln!("ignoring careless call to dc_msg_set_html()");
return;
}
let ffi_msg = &mut *msg;
ffi_msg.message.set_html(to_opt_string_lossy(html))
}
#[no_mangle]
pub unsafe extern "C" fn dc_msg_set_file(
msg: *mut dc_msg_t,