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:
iequidoo
2024-06-06 12:02:53 -03:00
committed by iequidoo
parent 0a0e7156e0
commit 889b947792
3 changed files with 61 additions and 1 deletions

View File

@@ -1476,6 +1476,20 @@ impl CommandApi {
deltachat::contact::make_vcard(&ctx, &contacts).await
}
/// Sets vCard containing the given contacts to the message draft.
async fn set_draft_vcard(
&self,
account_id: u32,
msg_id: u32,
contacts: Vec<u32>,
) -> Result<()> {
let ctx = self.get_context(account_id).await?;
let contacts: Vec<_> = contacts.iter().map(|&c| ContactId::new(c)).collect();
let mut msg = Message::load_from_db(&ctx, MsgId::new(msg_id)).await?;
msg.make_vcard(&ctx, &contacts).await?;
msg.get_chat_id().set_draft(&ctx, Some(&mut msg)).await
}
// ---------------------------------------------
// chat
// ---------------------------------------------