Fix https://github.com/chatmail/core/issues/8195 Supersedes https://github.com/chatmail/core/pull/8217 The most interesting change is in `delete_expired_imap_messages()` because there, messages are marked for deletion on single-device chatmail profiles. The logic in `delete_expired_imap_messages()` was wrong before, and pre-messages were not deleted at all. This is fixed by also querying `pre_rfc724_mid` in addition to `rfc724_mid` from the `msgs` table. In order not to make the SQL statement too complex, I split it into two. WRT tests: - `test_immediate_autodelete()` tests the auto-deletion; `test_imap_autodelete_fully_downloaded_msg()` tests that even for a message that is split into pre- and post-message, both messages are deleted. - A lot of tests test that if bcc_self is on, messages are not auto-deleted. E.g. `test_one_account_send_bcc_setting()` and `test_markseen_message_and_mdn()` relies on the fact that messages stay on the server when bcc_self is on. - Unfortunately, it is not possible to test that messages are only deleted for chatmail servers, because we don't have any tests that use a non-chatmail server.
deltachat-jsonrpc
This crate provides a JSON-RPC 2.0 interface to DeltaChat.
The JSON-RPC API is exposed in two fashions:
- A executable
deltachat-rpc-serverthat exposes the JSON-RPC API through stdio. - The JSON-RPC API can also be called through the C FFI. It exposes the functions
dc_jsonrpc_init,dc_jsonrpc_request,dc_jsonrpc_next_responseanddc_jsonrpc_unref. See the docs in the header file for details.
We also include a JavaScript and TypeScript client for the JSON-RPC API. The source for this is in the typescript folder.
Usage
Using the TypeScript/JavaScript client
The package includes a JavaScript/TypeScript client which is partially auto-generated through the JSON-RPC library used by this crate (yerpc). Find the source in the typescript folder.
To use it locally, first install the dependencies and compile the TypeScript code to JavaScript:
cd typescript
npm install
npm run build
The JavaScript client is published on NPM.
A script is included to build autogenerated documentation, which includes all RPC methods:
cd typescript
npm run docs
Then open the typescript/docs folder in a web browser.
Development
Running the example app
Testing
The crate includes both a basic Rust smoke test and more featureful integration tests that use the TypeScript client.
Rust tests
To run the Rust test, use this command:
cargo test
TypeScript tests
cd typescript
npm run test
This will build the deltachat-jsonrpc-server binary and then run a test suite.
The test suite includes some tests that need online connectivity and a way to create test email accounts. To run these tests, set the CHATMAIL_DOMAIN environment variable to your testing email server domain.
CHATMAIL_DOMAIN=ci-chatmail.testrun.org npm run test
Test Coverage
Running npm run test will report test coverage. For the coverage to be accurate the online tests need to be run.
If you are offline and want to see the coverage results anyway (even though they are inaccurate), you can bypass the errors of the online tests by setting the
COVERAGE_OFFLINE=1environment variable.
A summary of the coverage will be reported in the terminal after the test run. Open coverage/index.html in a web browser for a detailed report.