diff --git a/CHANGELOG.md b/CHANGELOG.md index 3be0e8877..d438da421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,31 @@ ## Unreleased ### API-Changes +- breaking jsonrpc: changed function naming + - `autocryptInitiateKeyTransfer` -> `initiateAutocryptKeyTransfer` + - `autocryptContinueKeyTransfer` -> `continueAutocryptKeyTransfer` + - `chatlistGetFullChatById` -> `getFullChatById` + - `messageGetMessage` -> `getMessage` + - `messageGetMessages` -> `getMessages` + - `messageGetNotificationInfo` -> `getMessageNotificationInfo` + - `contactsGetContact` -> `getContact` + - `contactsCreateContact` -> `createContact` + - `contactsCreateChatByContactId` -> `createChatByContactId` + - `contactsBlock` -> `blockContact` + - `contactsUnblock` -> `unblockContact` + - `contactsGetBlocked` -> `getBlockedContacts` + - `contactsGetContactIds` -> `getContactIds` + - `contactsGetContacts` -> `getContacts` + - `contactsGetContactsByIds` -> `getContactsByIds` + - `chatGetMedia` -> `getChatMedia` + - `chatGetNeighboringMedia` -> `getNeighboringChatMedia` + - `webxdcSendStatusUpdate` -> `sendWebxdcStatusUpdate` + - `webxdcGetStatusUpdates` -> `getWebxdcStatusUpdates` + - `messageGetWebxdcInfo` -> `getWebxdcInfo` +- jsonrpc: changed method signature + - `miscSendTextMessage(accountId, text, chatId)` -> `miscSendTextMessage(accountId, chatId, text)` + + ### Changes - allow sender timestamp to be in the future, but not too much diff --git a/deltachat-jsonrpc/src/api/mod.rs b/deltachat-jsonrpc/src/api/mod.rs index 31f09e43f..f86d34b58 100644 --- a/deltachat-jsonrpc/src/api/mod.rs +++ b/deltachat-jsonrpc/src/api/mod.rs @@ -400,12 +400,12 @@ impl CommandApi { // autocrypt // --------------------------------------------- - async fn autocrypt_initiate_key_transfer(&self, account_id: u32) -> Result { + async fn initiate_autocrypt_key_transfer(&self, account_id: u32) -> Result { let ctx = self.get_context(account_id).await?; deltachat::imex::initiate_key_transfer(&ctx).await } - async fn autocrypt_continue_key_transfer( + async fn continue_autocrypt_key_transfer( &self, account_id: u32, message_id: u32, @@ -472,11 +472,7 @@ impl CommandApi { // chat // --------------------------------------------- - async fn chatlist_get_full_chat_by_id( - &self, - account_id: u32, - chat_id: u32, - ) -> Result { + async fn get_full_chat_by_id(&self, account_id: u32, chat_id: u32) -> Result { let ctx = self.get_context(account_id).await?; FullChat::try_from_dc_chat_id(&ctx, chat_id).await } @@ -911,7 +907,7 @@ impl CommandApi { .collect::>()) } - async fn message_get_message(&self, account_id: u32, message_id: u32) -> Result { + async fn get_message(&self, account_id: u32, message_id: u32) -> Result { let ctx = self.get_context(account_id).await?; MessageObject::from_message_id(&ctx, message_id).await } @@ -921,7 +917,7 @@ impl CommandApi { MsgId::new(message_id).get_html(&ctx).await } - async fn message_get_messages( + async fn get_messages( &self, account_id: u32, message_ids: Vec, @@ -938,7 +934,7 @@ impl CommandApi { } /// Fetch info desktop needs for creating a notification for a message - async fn message_get_notification_info( + async fn get_message_notification_info( &self, account_id: u32, message_id: u32, @@ -1029,11 +1025,7 @@ impl CommandApi { // --------------------------------------------- /// Get a single contact options by ID. - async fn contacts_get_contact( - &self, - account_id: u32, - contact_id: u32, - ) -> Result { + async fn get_contact(&self, account_id: u32, contact_id: u32) -> Result { let ctx = self.get_context(account_id).await?; let contact_id = ContactId::new(contact_id); @@ -1047,7 +1039,7 @@ impl CommandApi { /// Add a single contact as a result of an explicit user action. /// /// Returns contact id of the created or existing contact - async fn contacts_create_contact( + async fn create_contact( &self, account_id: u32, email: String, @@ -1064,11 +1056,7 @@ impl CommandApi { } /// Returns contact id of the created or existing DM chat with that contact - async fn contacts_create_chat_by_contact_id( - &self, - account_id: u32, - contact_id: u32, - ) -> Result { + async fn create_chat_by_contact_id(&self, account_id: u32, contact_id: u32) -> Result { let ctx = self.get_context(account_id).await?; let contact = Contact::get_by_id(&ctx, ContactId::new(contact_id)).await?; ChatId::create_for_contact(&ctx, contact.id) @@ -1076,17 +1064,17 @@ impl CommandApi { .map(|id| id.to_u32()) } - async fn contacts_block(&self, account_id: u32, contact_id: u32) -> Result<()> { + async fn block_contact(&self, account_id: u32, contact_id: u32) -> Result<()> { let ctx = self.get_context(account_id).await?; Contact::block(&ctx, ContactId::new(contact_id)).await } - async fn contacts_unblock(&self, account_id: u32, contact_id: u32) -> Result<()> { + async fn unblock_contact(&self, account_id: u32, contact_id: u32) -> Result<()> { let ctx = self.get_context(account_id).await?; Contact::unblock(&ctx, ContactId::new(contact_id)).await } - async fn contacts_get_blocked(&self, account_id: u32) -> Result> { + async fn get_blocked_contacts(&self, account_id: u32) -> Result> { let ctx = self.get_context(account_id).await?; let blocked_ids = Contact::get_all_blocked(&ctx).await?; let mut contacts: Vec = Vec::with_capacity(blocked_ids.len()); @@ -1102,7 +1090,7 @@ impl CommandApi { Ok(contacts) } - async fn contacts_get_contact_ids( + async fn get_contact_ids( &self, account_id: u32, list_flags: u32, @@ -1115,7 +1103,7 @@ impl CommandApi { /// Get a list of contacts. /// (formerly called getContacts2 in desktop) - async fn contacts_get_contacts( + async fn get_contacts( &self, account_id: u32, list_flags: u32, @@ -1136,7 +1124,7 @@ impl CommandApi { Ok(contacts) } - async fn contacts_get_contacts_by_ids( + async fn get_contacts_by_ids( &self, account_id: u32, ids: Vec, @@ -1219,7 +1207,7 @@ impl CommandApi { /// /// Setting `chat_id` to `None` (`null` in typescript) means get messages with media /// from any chat of the currently used account. - async fn chat_get_media( + async fn get_chat_media( &self, account_id: u32, chat_id: Option, @@ -1247,7 +1235,7 @@ impl CommandApi { /// /// one combined call for getting chat::get_next_media for both directions /// the manual chat::get_next_media in only one direction is not exposed by the jsonrpc yet - async fn chat_get_neighboring_media( + async fn get_neighboring_chat_media( &self, account_id: u32, msg_id: u32, @@ -1399,7 +1387,7 @@ impl CommandApi { // webxdc // --------------------------------------------- - async fn webxdc_send_status_update( + async fn send_webxdc_status_update( &self, account_id: u32, instance_msg_id: u32, @@ -1411,7 +1399,7 @@ impl CommandApi { .await } - async fn webxdc_get_status_updates( + async fn get_webxdc_status_updates( &self, account_id: u32, instance_msg_id: u32, @@ -1426,7 +1414,7 @@ impl CommandApi { } /// Get info from a webxdc message - async fn message_get_webxdc_info( + async fn get_webxdc_info( &self, account_id: u32, instance_msg_id: u32, @@ -1579,8 +1567,8 @@ impl CommandApi { async fn misc_send_text_message( &self, account_id: u32, - text: String, chat_id: u32, + text: String, ) -> Result { let ctx = self.get_context(account_id).await?; diff --git a/deltachat-jsonrpc/typescript/example/example.ts b/deltachat-jsonrpc/typescript/example/example.ts index 14dfc9881..b7e37f9cc 100644 --- a/deltachat-jsonrpc/typescript/example/example.ts +++ b/deltachat-jsonrpc/typescript/example/example.ts @@ -68,7 +68,7 @@ async function run() { null ); for (const [chatId, _messageId] of chats) { - const chat = await client.rpc.chatlistGetFullChatById( + const chat = await client.rpc.getFullChatById( selectedAccount, chatId ); @@ -78,7 +78,7 @@ async function run() { chatId, 0 ); - const messages = await client.rpc.messageGetMessages( + const messages = await client.rpc.getMessages( selectedAccount, messageIds ); diff --git a/deltachat-jsonrpc/typescript/generated/client.ts b/deltachat-jsonrpc/typescript/generated/client.ts index c243b05d3..7556c11bc 100644 --- a/deltachat-jsonrpc/typescript/generated/client.ts +++ b/deltachat-jsonrpc/typescript/generated/client.ts @@ -232,13 +232,13 @@ export class RawClient { } - public autocryptInitiateKeyTransfer(accountId: T.U32): Promise { - return (this._transport.request('autocrypt_initiate_key_transfer', [accountId] as RPC.Params)) as Promise; + public initiateAutocryptKeyTransfer(accountId: T.U32): Promise { + return (this._transport.request('initiate_autocrypt_key_transfer', [accountId] as RPC.Params)) as Promise; } - public autocryptContinueKeyTransfer(accountId: T.U32, messageId: T.U32, setupCode: string): Promise { - return (this._transport.request('autocrypt_continue_key_transfer', [accountId, messageId, setupCode] as RPC.Params)) as Promise; + public continueAutocryptKeyTransfer(accountId: T.U32, messageId: T.U32, setupCode: string): Promise { + return (this._transport.request('continue_autocrypt_key_transfer', [accountId, messageId, setupCode] as RPC.Params)) as Promise; } @@ -252,8 +252,8 @@ export class RawClient { } - public chatlistGetFullChatById(accountId: T.U32, chatId: T.U32): Promise { - return (this._transport.request('chatlist_get_full_chat_by_id', [accountId, chatId] as RPC.Params)) as Promise; + public getFullChatById(accountId: T.U32, chatId: T.U32): Promise { + return (this._transport.request('get_full_chat_by_id', [accountId, chatId] as RPC.Params)) as Promise; } /** @@ -593,8 +593,8 @@ export class RawClient { } - public messageGetMessage(accountId: T.U32, messageId: T.U32): Promise { - return (this._transport.request('message_get_message', [accountId, messageId] as RPC.Params)) as Promise; + public getMessage(accountId: T.U32, messageId: T.U32): Promise { + return (this._transport.request('get_message', [accountId, messageId] as RPC.Params)) as Promise; } @@ -603,15 +603,15 @@ export class RawClient { } - public messageGetMessages(accountId: T.U32, messageIds: (T.U32)[]): Promise> { - return (this._transport.request('message_get_messages', [accountId, messageIds] as RPC.Params)) as Promise>; + public getMessages(accountId: T.U32, messageIds: (T.U32)[]): Promise> { + return (this._transport.request('get_messages', [accountId, messageIds] as RPC.Params)) as Promise>; } /** * Fetch info desktop needs for creating a notification for a message */ - public messageGetNotificationInfo(accountId: T.U32, messageId: T.U32): Promise { - return (this._transport.request('message_get_notification_info', [accountId, messageId] as RPC.Params)) as Promise; + public getMessageNotificationInfo(accountId: T.U32, messageId: T.U32): Promise { + return (this._transport.request('get_message_notification_info', [accountId, messageId] as RPC.Params)) as Promise; } /** @@ -676,8 +676,8 @@ export class RawClient { /** * Get a single contact options by ID. */ - public contactsGetContact(accountId: T.U32, contactId: T.U32): Promise { - return (this._transport.request('contacts_get_contact', [accountId, contactId] as RPC.Params)) as Promise; + public getContact(accountId: T.U32, contactId: T.U32): Promise { + return (this._transport.request('get_contact', [accountId, contactId] as RPC.Params)) as Promise; } /** @@ -685,48 +685,48 @@ export class RawClient { * * Returns contact id of the created or existing contact */ - public contactsCreateContact(accountId: T.U32, email: string, name: (string|null)): Promise { - return (this._transport.request('contacts_create_contact', [accountId, email, name] as RPC.Params)) as Promise; + public createContact(accountId: T.U32, email: string, name: (string|null)): Promise { + return (this._transport.request('create_contact', [accountId, email, name] as RPC.Params)) as Promise; } /** * Returns contact id of the created or existing DM chat with that contact */ - public contactsCreateChatByContactId(accountId: T.U32, contactId: T.U32): Promise { - return (this._transport.request('contacts_create_chat_by_contact_id', [accountId, contactId] as RPC.Params)) as Promise; + public createChatByContactId(accountId: T.U32, contactId: T.U32): Promise { + return (this._transport.request('create_chat_by_contact_id', [accountId, contactId] as RPC.Params)) as Promise; } - public contactsBlock(accountId: T.U32, contactId: T.U32): Promise { - return (this._transport.request('contacts_block', [accountId, contactId] as RPC.Params)) as Promise; + public blockContact(accountId: T.U32, contactId: T.U32): Promise { + return (this._transport.request('block_contact', [accountId, contactId] as RPC.Params)) as Promise; } - public contactsUnblock(accountId: T.U32, contactId: T.U32): Promise { - return (this._transport.request('contacts_unblock', [accountId, contactId] as RPC.Params)) as Promise; + public unblockContact(accountId: T.U32, contactId: T.U32): Promise { + return (this._transport.request('unblock_contact', [accountId, contactId] as RPC.Params)) as Promise; } - public contactsGetBlocked(accountId: T.U32): Promise<(T.Contact)[]> { - return (this._transport.request('contacts_get_blocked', [accountId] as RPC.Params)) as Promise<(T.Contact)[]>; + public getBlockedContacts(accountId: T.U32): Promise<(T.Contact)[]> { + return (this._transport.request('get_blocked_contacts', [accountId] as RPC.Params)) as Promise<(T.Contact)[]>; } - public contactsGetContactIds(accountId: T.U32, listFlags: T.U32, query: (string|null)): Promise<(T.U32)[]> { - return (this._transport.request('contacts_get_contact_ids', [accountId, listFlags, query] as RPC.Params)) as Promise<(T.U32)[]>; + public getContactIds(accountId: T.U32, listFlags: T.U32, query: (string|null)): Promise<(T.U32)[]> { + return (this._transport.request('get_contact_ids', [accountId, listFlags, query] as RPC.Params)) as Promise<(T.U32)[]>; } /** * Get a list of contacts. * (formerly called getContacts2 in desktop) */ - public contactsGetContacts(accountId: T.U32, listFlags: T.U32, query: (string|null)): Promise<(T.Contact)[]> { - return (this._transport.request('contacts_get_contacts', [accountId, listFlags, query] as RPC.Params)) as Promise<(T.Contact)[]>; + public getContacts(accountId: T.U32, listFlags: T.U32, query: (string|null)): Promise<(T.Contact)[]> { + return (this._transport.request('get_contacts', [accountId, listFlags, query] as RPC.Params)) as Promise<(T.Contact)[]>; } - public contactsGetContactsByIds(accountId: T.U32, ids: (T.U32)[]): Promise> { - return (this._transport.request('contacts_get_contacts_by_ids', [accountId, ids] as RPC.Params)) as Promise>; + public getContactsByIds(accountId: T.U32, ids: (T.U32)[]): Promise> { + return (this._transport.request('get_contacts_by_ids', [accountId, ids] as RPC.Params)) as Promise>; } @@ -770,8 +770,8 @@ export class RawClient { * Setting `chat_id` to `None` (`null` in typescript) means get messages with media * from any chat of the currently used account. */ - public chatGetMedia(accountId: T.U32, chatId: (T.U32|null), messageType: T.Viewtype, orMessageType2: (T.Viewtype|null), orMessageType3: (T.Viewtype|null)): Promise<(T.U32)[]> { - return (this._transport.request('chat_get_media', [accountId, chatId, messageType, orMessageType2, orMessageType3] as RPC.Params)) as Promise<(T.U32)[]>; + public getChatMedia(accountId: T.U32, chatId: (T.U32|null), messageType: T.Viewtype, orMessageType2: (T.Viewtype|null), orMessageType3: (T.Viewtype|null)): Promise<(T.U32)[]> { + return (this._transport.request('get_chat_media', [accountId, chatId, messageType, orMessageType2, orMessageType3] as RPC.Params)) as Promise<(T.U32)[]>; } /** @@ -782,8 +782,8 @@ export class RawClient { * one combined call for getting chat::get_next_media for both directions * the manual chat::get_next_media in only one direction is not exposed by the jsonrpc yet */ - public chatGetNeighboringMedia(accountId: T.U32, msgId: T.U32, messageType: T.Viewtype, orMessageType2: (T.Viewtype|null), orMessageType3: (T.Viewtype|null)): Promise<[(T.U32|null),(T.U32|null)]> { - return (this._transport.request('chat_get_neighboring_media', [accountId, msgId, messageType, orMessageType2, orMessageType3] as RPC.Params)) as Promise<[(T.U32|null),(T.U32|null)]>; + public getNeighboringChatMedia(accountId: T.U32, msgId: T.U32, messageType: T.Viewtype, orMessageType2: (T.Viewtype|null), orMessageType3: (T.Viewtype|null)): Promise<[(T.U32|null),(T.U32|null)]> { + return (this._transport.request('get_neighboring_chat_media', [accountId, msgId, messageType, orMessageType2, orMessageType3] as RPC.Params)) as Promise<[(T.U32|null),(T.U32|null)]>; } @@ -845,20 +845,20 @@ export class RawClient { } - public webxdcSendStatusUpdate(accountId: T.U32, instanceMsgId: T.U32, updateStr: string, description: string): Promise { - return (this._transport.request('webxdc_send_status_update', [accountId, instanceMsgId, updateStr, description] as RPC.Params)) as Promise; + public sendWebxdcStatusUpdate(accountId: T.U32, instanceMsgId: T.U32, updateStr: string, description: string): Promise { + return (this._transport.request('send_webxdc_status_update', [accountId, instanceMsgId, updateStr, description] as RPC.Params)) as Promise; } - public webxdcGetStatusUpdates(accountId: T.U32, instanceMsgId: T.U32, lastKnownSerial: T.U32): Promise { - return (this._transport.request('webxdc_get_status_updates', [accountId, instanceMsgId, lastKnownSerial] as RPC.Params)) as Promise; + public getWebxdcStatusUpdates(accountId: T.U32, instanceMsgId: T.U32, lastKnownSerial: T.U32): Promise { + return (this._transport.request('get_webxdc_status_updates', [accountId, instanceMsgId, lastKnownSerial] as RPC.Params)) as Promise; } /** * Get info from a webxdc message */ - public messageGetWebxdcInfo(accountId: T.U32, instanceMsgId: T.U32): Promise { - return (this._transport.request('message_get_webxdc_info', [accountId, instanceMsgId] as RPC.Params)) as Promise; + public getWebxdcInfo(accountId: T.U32, instanceMsgId: T.U32): Promise { + return (this._transport.request('get_webxdc_info', [accountId, instanceMsgId] as RPC.Params)) as Promise; } /** @@ -923,8 +923,8 @@ export class RawClient { /** * Returns the messageid of the sent message */ - public miscSendTextMessage(accountId: T.U32, text: string, chatId: T.U32): Promise { - return (this._transport.request('misc_send_text_message', [accountId, text, chatId] as RPC.Params)) as Promise; + public miscSendTextMessage(accountId: T.U32, chatId: T.U32, text: string): Promise { + return (this._transport.request('misc_send_text_message', [accountId, chatId, text] as RPC.Params)) as Promise; } diff --git a/deltachat-jsonrpc/typescript/generated/types.ts b/deltachat-jsonrpc/typescript/generated/types.ts index d776ccd7e..9b2dcacc2 100644 --- a/deltachat-jsonrpc/typescript/generated/types.ts +++ b/deltachat-jsonrpc/typescript/generated/types.ts @@ -177,4 +177,4 @@ export type MessageNotificationInfo={"id":U32;"chatId":U32;"accountId":U32;"imag export type MessageSearchResult={"id":U32;"authorProfileImage":(string|null);"authorName":string;"authorColor":string;"chatName":(string|null);"message":string;"timestamp":I64;}; export type F64=number; export type Location={"locationId":U32;"isIndependent":boolean;"latitude":F64;"longitude":F64;"accuracy":F64;"timestamp":I64;"contactId":U32;"msgId":U32;"chatId":U32;"marker":(string|null);}; -export type __AllTyps=[string,boolean,Record,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],null,null,U32,null,U32,null,U32,Account,U32,U64,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,Record,null,U32,null,U32,null,U32,string,(string|null),null,U32,string,(string|null),null,U32,(U32)[],U32,U32,Usize,U32,boolean,I64,Usize,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record,U32,U32,FullChat,U32,U32,BasicChat,U32,U32,null,U32,U32,null,U32,U32,null,U32,U32,string,U32,(U32|null),[string,string],U32,string,U32,U32,U32,null,U32,U32,U32,null,U32,U32,U32,null,U32,U32,(U32)[],U32,string,boolean,U32,U32,U32,U32,U32,string,null,U32,U32,(string|null),null,U32,U32,ChatVisibility,null,U32,U32,U32,null,U32,U32,U32,U32,string,string,U32,U32,U32,null,U32,U32,(U32|null),U32,U32,MuteDuration,null,U32,U32,boolean,U32,(U32)[],null,U32,U32,U32,(U32)[],U32,U32,U32,(MessageListItem)[],U32,U32,Message,U32,U32,(string|null),U32,(U32)[],Record,U32,U32,MessageNotificationInfo,U32,(U32)[],null,U32,U32,string,U32,U32,null,U32,string,(U32|null),(U32)[],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,boolean,U32,U32,string,null,U32,U32,string,U32,string,(U32|null),U32,(U32|null),Viewtype,(Viewtype|null),(Viewtype|null),(U32)[],U32,U32,Viewtype,(Viewtype|null),(Viewtype|null),[(U32|null),(U32|null)],U32,string,(string|null),null,U32,string,(string|null),null,null,U32,U32,U32,string,U32,(U32|null),(U32|null),I64,I64,(Location)[],U32,U32,string,string,null,U32,U32,U32,string,U32,U32,WebxdcMessageInfo,U32,(U32)[],U32,null,U32,U32,string,U32,U32,U32,(string)[],U32,U32,U32,null,U32,U32,(Message|null),U32,U32,U32,U32,string,U32,Record,U32,string,U32,U32,U32,U32,(string|null),(string|null),([F64,F64]|null),(U32|null),[U32,Message],U32,U32,(string|null),(string|null),(U32|null),null]; +export type __AllTyps=[string,boolean,Record,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],null,null,U32,null,U32,null,U32,Account,U32,U64,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,Record,null,U32,null,U32,null,U32,string,(string|null),null,U32,string,(string|null),null,U32,(U32)[],U32,U32,Usize,U32,boolean,I64,Usize,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record,U32,U32,FullChat,U32,U32,BasicChat,U32,U32,null,U32,U32,null,U32,U32,null,U32,U32,string,U32,(U32|null),[string,string],U32,string,U32,U32,U32,null,U32,U32,U32,null,U32,U32,U32,null,U32,U32,(U32)[],U32,string,boolean,U32,U32,U32,U32,U32,string,null,U32,U32,(string|null),null,U32,U32,ChatVisibility,null,U32,U32,U32,null,U32,U32,U32,U32,string,string,U32,U32,U32,null,U32,U32,(U32|null),U32,U32,MuteDuration,null,U32,U32,boolean,U32,(U32)[],null,U32,U32,U32,(U32)[],U32,U32,U32,(MessageListItem)[],U32,U32,Message,U32,U32,(string|null),U32,(U32)[],Record,U32,U32,MessageNotificationInfo,U32,(U32)[],null,U32,U32,string,U32,U32,null,U32,string,(U32|null),(U32)[],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,boolean,U32,U32,string,null,U32,U32,string,U32,string,(U32|null),U32,(U32|null),Viewtype,(Viewtype|null),(Viewtype|null),(U32)[],U32,U32,Viewtype,(Viewtype|null),(Viewtype|null),[(U32|null),(U32|null)],U32,string,(string|null),null,U32,string,(string|null),null,null,U32,U32,U32,string,U32,(U32|null),(U32|null),I64,I64,(Location)[],U32,U32,string,string,null,U32,U32,U32,string,U32,U32,WebxdcMessageInfo,U32,(U32)[],U32,null,U32,U32,string,U32,U32,U32,(string)[],U32,U32,U32,null,U32,U32,(Message|null),U32,U32,U32,U32,string,U32,Record,U32,U32,string,U32,U32,U32,(string|null),(string|null),([F64,F64]|null),(U32|null),[U32,Message],U32,U32,(string|null),(string|null),(U32|null),null]; diff --git a/deltachat-jsonrpc/typescript/test/basic.ts b/deltachat-jsonrpc/typescript/test/basic.ts index ea300643f..b4593305e 100644 --- a/deltachat-jsonrpc/typescript/test/basic.ts +++ b/deltachat-jsonrpc/typescript/test/basic.ts @@ -84,21 +84,21 @@ describe("basic tests", () => { accountId = await dc.rpc.addAccount(); }); it("should block and unblock contact", async function () { - const contactId = await dc.rpc.contactsCreateContact( + const contactId = await dc.rpc.createContact( accountId, "example@delta.chat", null ); - expect((await dc.rpc.contactsGetContact(accountId, contactId)).isBlocked).to.be + expect((await dc.rpc.getContact(accountId, contactId)).isBlocked).to.be .false; - await dc.rpc.contactsBlock(accountId, contactId); - expect((await dc.rpc.contactsGetContact(accountId, contactId)).isBlocked).to.be + await dc.rpc.blockContact(accountId, contactId); + expect((await dc.rpc.getContact(accountId, contactId)).isBlocked).to.be .true; - expect(await dc.rpc.contactsGetBlocked(accountId)).to.have.length(1); - await dc.rpc.contactsUnblock(accountId, contactId); - expect((await dc.rpc.contactsGetContact(accountId, contactId)).isBlocked).to.be + expect(await dc.rpc.getBlockedContacts(accountId)).to.have.length(1); + await dc.rpc.unblockContact(accountId, contactId); + expect((await dc.rpc.getContact(accountId, contactId)).isBlocked).to.be .false; - expect(await dc.rpc.contactsGetBlocked(accountId)).to.have.length(0); + expect(await dc.rpc.getBlockedContacts(accountId)).to.have.length(0); }); }); diff --git a/deltachat-jsonrpc/typescript/test/online.ts b/deltachat-jsonrpc/typescript/test/online.ts index fd59668e8..c7f56b35e 100644 --- a/deltachat-jsonrpc/typescript/test/online.ts +++ b/deltachat-jsonrpc/typescript/test/online.ts @@ -80,21 +80,18 @@ describe("online tests", function () { } this.timeout(15000); - const contactId = await dc.rpc.contactsCreateContact( + const contactId = await dc.rpc.createContact( accountId1, account2.email, null ); - const chatId = await dc.rpc.contactsCreateChatByContactId( - accountId1, - contactId - ); + const chatId = await dc.rpc.createChatByContactId(accountId1, contactId); const eventPromise = Promise.race([ waitForEvent(dc, "MsgsChanged", accountId2), waitForEvent(dc, "IncomingMsg", accountId2), ]); - await dc.rpc.miscSendTextMessage(accountId1, "Hello", chatId); + await dc.rpc.miscSendTextMessage(accountId1, chatId, "Hello"); const { chatId: chatIdOnAccountB } = await eventPromise; await dc.rpc.acceptChat(accountId2, chatIdOnAccountB); const messageList = await dc.rpc.getMessageIds( @@ -104,7 +101,7 @@ describe("online tests", function () { ); expect(messageList).have.length(1); - const message = await dc.rpc.messageGetMessage(accountId2, messageList[0]); + const message = await dc.rpc.getMessage(accountId2, messageList[0]); expect(message.text).equal("Hello"); }); @@ -115,20 +112,17 @@ describe("online tests", function () { this.timeout(10000); // send message from A to B - const contactId = await dc.rpc.contactsCreateContact( + const contactId = await dc.rpc.createContact( accountId1, account2.email, null ); - const chatId = await dc.rpc.contactsCreateChatByContactId( - accountId1, - contactId - ); + const chatId = await dc.rpc.createChatByContactId(accountId1, contactId); const eventPromise = Promise.race([ waitForEvent(dc, "MsgsChanged", accountId2), waitForEvent(dc, "IncomingMsg", accountId2), ]); - dc.rpc.miscSendTextMessage(accountId1, "Hello2", chatId); + dc.rpc.miscSendTextMessage(accountId1, chatId, "Hello2"); // wait for message from A console.log("wait for message from A"); @@ -141,7 +135,7 @@ describe("online tests", function () { chatIdOnAccountB, 0 ); - const message = await dc.rpc.messageGetMessage( + const message = await dc.rpc.getMessage( accountId2, messageList.reverse()[0] ); @@ -151,14 +145,14 @@ describe("online tests", function () { waitForEvent(dc, "MsgsChanged", accountId1), waitForEvent(dc, "IncomingMsg", accountId1), ]); - dc.rpc.miscSendTextMessage(accountId2, "super secret message", chatId); + dc.rpc.miscSendTextMessage(accountId2, chatId, "super secret message"); // Check if answer arives at A and if it is encrypted await eventPromise2; const messageId = ( await dc.rpc.getMessageIds(accountId1, chatId, 0) ).reverse()[0]; - const message2 = await dc.rpc.messageGetMessage(accountId1, messageId); + const message2 = await dc.rpc.getMessage(accountId1, messageId); expect(message2.text).equal("super secret message"); expect(message2.showPadlock).equal(true); });