mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 13:56:30 +03:00
api(jsonrpc): Add set_draft_vcard(.., msg_id, contacts)
Add a function setting a vCard containing the given contacts to the message draft. This should simplify sending contacts as vCards for apps.
This commit is contained in:
@@ -16,7 +16,7 @@ use crate::config::Config;
|
||||
use crate::constants::{
|
||||
Blocked, Chattype, VideochatType, DC_CHAT_ID_TRASH, DC_DESIRED_TEXT_LEN, DC_MSG_ID_LAST_SPECIAL,
|
||||
};
|
||||
use crate::contact::{Contact, ContactId};
|
||||
use crate::contact::{self, Contact, ContactId};
|
||||
use crate::context::Context;
|
||||
use crate::debug_logging::set_debug_logging_xdc;
|
||||
use crate::download::DownloadState;
|
||||
@@ -1081,6 +1081,18 @@ impl Message {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Makes message a vCard-containing message using the specified contacts.
|
||||
pub async fn make_vcard(&mut self, context: &Context, contacts: &[ContactId]) -> Result<()> {
|
||||
ensure!(
|
||||
matches!(self.viewtype, Viewtype::File | Viewtype::Vcard),
|
||||
"Wrong viewtype for vCard: {}",
|
||||
self.viewtype,
|
||||
);
|
||||
let vcard = contact::make_vcard(context, contacts).await?;
|
||||
self.set_file_from_bytes(context, "vcard.vcf", vcard.as_bytes(), None)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Set different sender name for a message.
|
||||
/// This overrides the name set by the `set_config()`-option `displayname`.
|
||||
pub fn set_override_sender_name(&mut self, name: Option<String>) {
|
||||
|
||||
Reference in New Issue
Block a user