diff --git a/CHANGELOG.md b/CHANGELOG.md index 545bd3852..a85a1952b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,13 +11,15 @@ and `dc_event_emitter_unref()` should be used instead of `dc_accounts_event_emitter_unref`. - add `dc_contact_was_seen_recently()` #3560 -- jsonrpc: add functions: +- jsonrpc: add functions: #3586, #3587 - `deleteChat()` - `getChatEncryptionInfo()` - `getChatSecurejoinQrCodeSvg()` - `leaveGroup()` - `removeContactFromChat()` - `addContactToChat()` + - `deleteMessages()` + - `getMessageInfo()` - jsonrpc: add `is_broadcast` property to `ChatListItemFetchResult` #3584 - jsonrpc: add `was_seen_recently` property to `ChatListItemFetchResult`, `FullChat` and `Contact` #3584 - jsonrpc: add `webxdc_info` property to `Message` #3588 diff --git a/deltachat-jsonrpc/src/api/mod.rs b/deltachat-jsonrpc/src/api/mod.rs index 733e38af6..50717f592 100644 --- a/deltachat-jsonrpc/src/api/mod.rs +++ b/deltachat-jsonrpc/src/api/mod.rs @@ -5,7 +5,7 @@ use deltachat::{ config::Config, contact::{may_be_valid_addr, Contact, ContactId}, context::get_info, - message::{Message, MsgId, Viewtype}, + message::{delete_msgs, get_msg_info, Message, MsgId, Viewtype}, provider::get_provider_info, qr, qr_code_generator::get_securejoin_qr_svg, @@ -537,6 +537,24 @@ impl CommandApi { Ok(messages) } + /// Delete messages. The messages are deleted on the current device and + /// on the IMAP server. + async fn delete_messages(&self, account_id: u32, message_ids: Vec) -> Result<()> { + let ctx = self.get_context(account_id).await?; + let msgs: Vec = message_ids.into_iter().map(MsgId::new).collect(); + delete_msgs(&ctx, &msgs).await + } + + /// Get an informational text for a single message. The text is multiline and may + /// contain e.g. the raw text of the message. + /// + /// The max. text returned is typically longer (about 100000 characters) than the + /// max. text returned by dc_msg_get_text() (about 30000 characters). + async fn get_message_info(&self, account_id: u32, message_id: u32) -> Result { + let ctx = self.get_context(account_id).await?; + get_msg_info(&ctx, MsgId::new(message_id)).await + } + // --------------------------------------------- // contact // --------------------------------------------- diff --git a/deltachat-jsonrpc/typescript/generated/client.ts b/deltachat-jsonrpc/typescript/generated/client.ts index 44fa7fdbe..bb5b9a65e 100644 --- a/deltachat-jsonrpc/typescript/generated/client.ts +++ b/deltachat-jsonrpc/typescript/generated/client.ts @@ -223,7 +223,7 @@ export class RawClient { * Things that are _not done_ implicitly: * * - Messages are **not deleted from the server**. - * - The chat or the contact is **not blocked**, so new messages from the user/the group may appear + * - The chat or the contact is **not blocked**, so new messages from the user/the group may appear as a contact request * and the user may create the chat again. * - **Groups are not left** - this would * be unexpected as (1) deleting a normal chat also does not prevent new mails @@ -321,6 +321,25 @@ export class RawClient { return (this._transport.request('message_get_messages', [accountId, messageIds] as RPC.Params)) as Promise>; } + /** + * Delete messages. The messages are deleted on the current device and + * on the IMAP server. + */ + public deleteMessages(accountId: T.U32, messageIds: (T.U32)[]): Promise { + return (this._transport.request('delete_messages', [accountId, messageIds] as RPC.Params)) as Promise; + } + + /** + * Get an informational text for a single message. The text is multiline and may + * contain e.g. the raw text of the message. + * + * The max. text returned is typically longer (about 100000 characters) than the + * max. text returned by dc_msg_get_text() (about 30000 characters). + */ + public getMessageInfo(accountId: T.U32, messageId: T.U32): Promise { + return (this._transport.request('get_message_info', [accountId, messageId] as RPC.Params)) as Promise; + } + /** * Get a single contact options by ID. */ diff --git a/deltachat-jsonrpc/typescript/generated/types.ts b/deltachat-jsonrpc/typescript/generated/types.ts index 901feefb8..9f9b52f64 100644 --- a/deltachat-jsonrpc/typescript/generated/types.ts +++ b/deltachat-jsonrpc/typescript/generated/types.ts @@ -103,4 +103,4 @@ export type WebxdcMessageInfo={ * True if full internet access should be granted to the app. */ "internetAccess":boolean;}; -export type __AllTyps=[string,boolean,Record,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record,U32,string,(string|null),null,U32,Record,null,U32,string,null,U32,string,Qr,U32,string,(string|null),U32,(string)[],Record,U32,null,U32,null,U32,(U32)[],U32,U32,Usize,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record,U32,U32,FullChat,U32,U32,null,U32,U32,null,U32,U32,null,U32,U32,string,U32,(U32|null),[string,string],U32,U32,null,U32,U32,U32,null,U32,U32,U32,null,U32,string,string,U32,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record,U32,(U32|null),Viewtype,(Viewtype|null),(Viewtype|null),(U32)[],U32,U32,string,string,null,U32,U32,U32,string,U32,U32,WebxdcMessageInfo,U32,string,U32,U32]; +export type __AllTyps=[string,boolean,Record,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record,U32,string,(string|null),null,U32,Record,null,U32,string,null,U32,string,Qr,U32,string,(string|null),U32,(string)[],Record,U32,null,U32,null,U32,(U32)[],U32,U32,Usize,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record,U32,U32,FullChat,U32,U32,null,U32,U32,null,U32,U32,null,U32,U32,string,U32,(U32|null),[string,string],U32,U32,null,U32,U32,U32,null,U32,U32,U32,null,U32,string,string,U32,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record,U32,(U32)[],null,U32,U32,string,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record,U32,(U32|null),Viewtype,(Viewtype|null),(Viewtype|null),(U32)[],U32,U32,string,string,null,U32,U32,U32,string,U32,U32,WebxdcMessageInfo,U32,string,U32,U32];