mirror of
https://github.com/chatmail/core.git
synced 2026-10-11 23:50:16 +03:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8b9fd5005 | ||
|
|
694ef8ba76 | ||
|
|
de6f469710 | ||
|
|
81140d514f | ||
|
|
a8b6246052 | ||
|
|
4ea5cddc09 | ||
|
|
f8edd9136a | ||
|
|
697304e98a | ||
|
|
40c0954e42 | ||
|
|
3a79324728 | ||
|
|
6ab0cd513a | ||
|
|
0bee156449 | ||
|
|
9ce20d7763 | ||
|
|
d7376e32b2 | ||
|
|
6378533b6a | ||
|
|
1451478911 |
+15
-12
@@ -25,11 +25,16 @@ env:
|
||||
# Minimum Supported Rust Version
|
||||
MSRV: 1.89.0
|
||||
|
||||
PYTHON_VERSION: 3.15
|
||||
|
||||
jobs:
|
||||
lint_rust:
|
||||
name: Lint Rust
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
# Tests always unwind: match it so dependencies are only checked once.
|
||||
CARGO_PROFILE_DEV_PANIC: unwind
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
@@ -48,8 +53,6 @@ jobs:
|
||||
run: cargo fmt --all -- --check
|
||||
- name: Run clippy
|
||||
run: scripts/clippy.sh
|
||||
- name: Check with all features
|
||||
run: cargo check --workspace --all-targets --all-features
|
||||
- name: Check with only default features
|
||||
run: cargo check --all-targets
|
||||
|
||||
@@ -139,12 +142,12 @@ jobs:
|
||||
- name: Tests
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
run: cargo nextest run --workspace --locked
|
||||
run: cargo nextest run --workspace --exclude deltachat-jsonrpc-bindings --locked
|
||||
|
||||
- name: Doc-Tests
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
run: cargo test --workspace --locked --doc
|
||||
run: cargo test --workspace --exclude deltachat-jsonrpc-bindings --locked --doc
|
||||
|
||||
- name: Test cargo vendor
|
||||
run: cargo vendor
|
||||
@@ -267,11 +270,11 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Currently used Rust version.
|
||||
# Currently used Python version.
|
||||
- os: ubuntu-latest
|
||||
python: 3.14
|
||||
python: latest
|
||||
- os: macos-latest
|
||||
python: 3.14
|
||||
python: latest
|
||||
|
||||
# PyPy tests
|
||||
- os: ubuntu-latest
|
||||
@@ -302,7 +305,7 @@ jobs:
|
||||
- name: Install python
|
||||
uses: actions/setup-python@v7.0.0
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
python-version: ${{ matrix.python == 'latest' && env.PYTHON_VERSION || matrix.python }}
|
||||
|
||||
- name: Install tox
|
||||
run: pip install tox
|
||||
@@ -323,11 +326,11 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
python: 3.14
|
||||
python: latest
|
||||
- os: macos-latest
|
||||
python: 3.14
|
||||
python: latest
|
||||
- os: windows-latest
|
||||
python: 3.14
|
||||
python: latest
|
||||
|
||||
# PyPy tests
|
||||
- os: ubuntu-latest
|
||||
@@ -350,7 +353,7 @@ jobs:
|
||||
- name: Install python
|
||||
uses: actions/setup-python@v7.0.0
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
python-version: ${{ matrix.python == 'latest' && env.PYTHON_VERSION || matrix.python }}
|
||||
|
||||
- name: Install tox
|
||||
run: pip install tox
|
||||
|
||||
@@ -1,5 +1,84 @@
|
||||
# Changelog
|
||||
|
||||
## [2.63.0] - 2026-10-09
|
||||
|
||||
### API-Changes
|
||||
|
||||
- add `PinnedMessagesChanged` event.
|
||||
- [**breaking**]: remove unused `dc_chatlist_get_summary2()` ([#8812](https://github.com/chatmail/core/pull/8812))
|
||||
- new `dc_msg_get_summary_text()` ([#8813](https://github.com/chatmail/core/pull/8813)).
|
||||
|
||||
### Features / Changes
|
||||
|
||||
- connect to the most recently successfully used SMTP transport first.
|
||||
- re-add "second device added" message if deleted soon after transfer ([#8758](https://github.com/chatmail/core/pull/8758)).
|
||||
- do not request MDNs for unencrypted messages.
|
||||
- do not send unencrypted MDNs.
|
||||
- add context to HTTP(S) proxy connection errors.
|
||||
- deltachat-repl: remove "reset" command.
|
||||
|
||||
### Fixes
|
||||
|
||||
- Correctly percent-encode addresses in securejoin invite codes ([#8747](https://github.com/chatmail/core/pull/8747)).
|
||||
- regenerate deltachat.pc if env changed ([#8752](https://github.com/chatmail/core/pull/8752)).
|
||||
- delete handled securejoin messages on all relays.
|
||||
- add headers to unencrypted MDNs.
|
||||
- In SMTP loop, reset `transport_id` and `from` when disconnecting ([#8797](https://github.com/chatmail/core/pull/8797)).
|
||||
- deltachat-rpc-client: shutdown all threads after RPC server crash.
|
||||
- (linux-only) make sure large attachments return memory to kernel.
|
||||
- do not reencode animated WebPs into JPEG.
|
||||
|
||||
### CI
|
||||
|
||||
- update Rust to 1.99.0.
|
||||
- speedup lint job and the Rust test builds
|
||||
|
||||
### Refactor
|
||||
|
||||
- [**breaking**] stop saving legacy config values when configuring a transport.
|
||||
- core does not set deprecated config values `addr`, `mail_pw` etc. Use `list_transports()` API instead.
|
||||
- get rid of dead sticker-related code in check_or_recode_to_size().
|
||||
- factor add_headers_to_part() out of mimefactory::add_headers_to_protected_part().
|
||||
- replace MimeFactory::from_mdn() with a standalone mimefactory::mdn().
|
||||
- take securejoin addresses from transport list.
|
||||
- deltachat-repl: move all commands to cmdline.rs.
|
||||
- do not guess image format from file extension on I/O error.
|
||||
- reduce macro-generated lines by >70%, and drop tracing.
|
||||
- stop excluding `COPYUID` responses from the logs.
|
||||
|
||||
### Tests
|
||||
|
||||
- move pinned messages tests into pinned_messages_tests module.
|
||||
- Add basic tests for rendering unencrypted messages ([#8736](https://github.com/chatmail/core/pull/8736)).
|
||||
- do not ignore errors in add_pseudo_transport().
|
||||
- test sending and receiving long filename with emojis.
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- update rPGP from 0.20.0 to 0.21.0.
|
||||
- reduce noise created by key-contact migration.
|
||||
- enable `clippy::unnecessary_wraps`, fix `clippy::redundant_clone` and `clippy::string_lit_as_bytes` suggestions.
|
||||
- add chatmail.au.
|
||||
- add chatmail.cc ([#8756](https://github.com/chatmail/core/pull/8756)).
|
||||
- remove some `unwrap()` calls.
|
||||
- remove unused "sdp" dependency.
|
||||
- cargo: bump smallvec from 1.15.2 to 1.16.1.
|
||||
- cargo: bump syn from 3.0.4 to 3.0.6.
|
||||
- deps: bump zizmorcore/zizmor-action from 0.6.2 to 0.6.4.
|
||||
- cargo: bump mailparse from 0.16.1 to 0.17.0.
|
||||
- cargo: bump uuid from 1.25.0 to 1.26.1.
|
||||
- deps: bump cachix/install-nix-action from 31.11.0 to 31.11.1.
|
||||
- cargo: bump hyper from 1.10.1 to 1.11.1.
|
||||
- cargo: bump tokio-rustls from 0.26.4 to 0.26.5.
|
||||
- cargo: bump thiserror from 2.0.20 to 2.0.21.
|
||||
- deps: bump taiki-e/install-action from 2.86.7 to 2.87.20.
|
||||
- cargo: bump hyper-util from 0.1.20 to 0.1.21.
|
||||
- cargo: bump dirs from 6.0.0 to 7.0.0.
|
||||
- move deltachat-time to dev dependencies.
|
||||
- update astral-tokio-tar from 0.6.4 to 0.7.0.
|
||||
- update async-imap to 0.12.0.
|
||||
- update mail-builder to 1.0.
|
||||
|
||||
## [2.62.0] - 2026-09-22
|
||||
|
||||
### API-Changes
|
||||
@@ -8903,3 +8982,4 @@ https://github.com/chatmail/core/pulls?q=is%3Apr+is%3Aclosed
|
||||
[2.60.0]: https://github.com/chatmail/core/compare/v2.59.0..v2.60.0
|
||||
[2.61.0]: https://github.com/chatmail/core/compare/v2.60.0..v2.61.0
|
||||
[2.62.0]: https://github.com/chatmail/core/compare/v2.61.0..v2.62.0
|
||||
[2.63.0]: https://github.com/chatmail/core/compare/v2.62.0..v2.63.0
|
||||
|
||||
Generated
+36
-30
@@ -272,19 +272,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "async-imap"
|
||||
version = "0.11.3"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a6728e0f7931b36d725ac234fcb02539e9f7888dbeaaa8a18d9ea5792181570"
|
||||
checksum = "f97b87216c9f0ccc63c516263169085fa34bba25633f6d96c6a9b9ca1fd5f70a"
|
||||
dependencies = [
|
||||
"async-channel 2.5.0",
|
||||
"async-compression",
|
||||
"base64",
|
||||
"base64 0.23.1",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"imap-proto",
|
||||
"log",
|
||||
"nom 7.1.3",
|
||||
"nom 8.0.0",
|
||||
"pin-project",
|
||||
"pin-utils",
|
||||
"self_cell",
|
||||
@@ -323,7 +323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55219982f938e74491ba85dc4e49cefe8096b1e8f49348c67180a7d244988dca"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"futures",
|
||||
"log",
|
||||
"nom 8.0.0",
|
||||
@@ -436,6 +436,12 @@ version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.6.0"
|
||||
@@ -833,7 +839,7 @@ version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1f927b07c74ba84c7e5fe4db2baeb3e996ab2688992e39ac68ce3220a677c7e"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"encoding_rs",
|
||||
]
|
||||
|
||||
@@ -1328,7 +1334,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deltachat"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"astral-tokio-tar",
|
||||
@@ -1338,7 +1344,7 @@ dependencies = [
|
||||
"async-native-tls",
|
||||
"async-smtp",
|
||||
"async_zip",
|
||||
"base64",
|
||||
"base64 0.23.1",
|
||||
"blake3",
|
||||
"brotli",
|
||||
"bytes",
|
||||
@@ -1406,7 +1412,6 @@ dependencies = [
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"toml",
|
||||
"tracing",
|
||||
"url",
|
||||
"uuid",
|
||||
"walkdir",
|
||||
@@ -1435,11 +1440,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deltachat-jsonrpc"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-channel 2.5.0",
|
||||
"base64",
|
||||
"base64 0.23.1",
|
||||
"deltachat",
|
||||
"deltachat-contact-tools",
|
||||
"futures",
|
||||
@@ -1456,14 +1461,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deltachat-jsonrpc-bindings"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
dependencies = [
|
||||
"deltachat-jsonrpc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deltachat-repl"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deltachat",
|
||||
@@ -1479,12 +1484,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deltachat-rpc-server"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deltachat",
|
||||
"deltachat-jsonrpc",
|
||||
"futures-lite",
|
||||
"libc",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1508,7 +1514,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deltachat_ffi"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deltachat",
|
||||
@@ -2941,11 +2947,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "imap-proto"
|
||||
version = "0.16.5"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de555d9526462b6f9ece826a26fb7c67eca9a0245bd9ff84fa91972a5d5d8856"
|
||||
checksum = "5ccf963d57074747b455398a1763d174da80bcaba6f51e3671a82252b531a68b"
|
||||
dependencies = [
|
||||
"nom 7.1.3",
|
||||
"nom 8.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3445,9 +3451,9 @@ checksum = "9106e1d747ffd48e6be5bb2d97fa706ed25b144fbee4d5c02eae110cd8d6badd"
|
||||
|
||||
[[package]]
|
||||
name = "mail-builder"
|
||||
version = "0.5.0"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c942e8a4b83f9351236c1e531ea9fa0237913d63c7fc36818430e0128a1ddf3"
|
||||
checksum = "ccbc27cb02a58a311a404769a22f5abf63fe3173b290d80be7c534f9c7023151"
|
||||
|
||||
[[package]]
|
||||
name = "mailparse"
|
||||
@@ -4181,7 +4187,7 @@ version = "3.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@@ -4247,16 +4253,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pgp"
|
||||
version = "0.20.0"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cfa4743b28656065ff4c0ba09e46b357a65e8c00fc2341e89084b82f87cbdf1"
|
||||
checksum = "ae70f4d9325a391db30d115d6191a7bb67cec856aa0bba131290f0c4e09a532a"
|
||||
dependencies = [
|
||||
"aead",
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
"aes-kw",
|
||||
"argon2",
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bitfields",
|
||||
"block-padding",
|
||||
"blowfish",
|
||||
@@ -4535,7 +4541,7 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d6db66007eac4a0ec8331d0d20c734bd64f6445d64bbaf0d0a27fea7a054e36"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"derive_more 1.0.0",
|
||||
"futures-lite",
|
||||
@@ -5091,7 +5097,7 @@ version = "0.12.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
@@ -5685,7 +5691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e78db9c9912c90ea7487f49bc149b329b535806bfa12b740fbade73f573a3d9f"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"blake3",
|
||||
"byte_string",
|
||||
"bytes",
|
||||
@@ -5985,7 +5991,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb921f10397d5669e1af6455e9e2d367bf1f9cebcd6b1dd1dc50e19f6a9ac2ac"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bounded-integer",
|
||||
"byteorder",
|
||||
"crc",
|
||||
@@ -6400,7 +6406,7 @@ version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fcaf159b4e7a376b05b5bfd77bfd38f3324f5fce751b4213bfc7eaa47affb4e"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
|
||||
+5
-6
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
edition = "2024"
|
||||
license = "MPL-2.0"
|
||||
rust-version = "1.89"
|
||||
@@ -43,7 +43,7 @@ ratelimit = { path = "./deltachat-ratelimit" }
|
||||
anyhow = { workspace = true }
|
||||
async-broadcast = "0.7.2"
|
||||
async-channel = { workspace = true }
|
||||
async-imap = { version = "0.11.3", default-features = false, features = ["runtime-tokio", "compress"] }
|
||||
async-imap = { version = "0.12.0", default-features = false, features = ["runtime-tokio", "compress"] }
|
||||
async-native-tls = { version = "0.6", default-features = false, features = ["runtime-tokio"] }
|
||||
async-smtp = { version = "0.10.2", default-features = false, features = ["runtime-tokio"] }
|
||||
async_zip = { version = "0.0.18", default-features = false, features = ["deflate", "tokio-fs"] }
|
||||
@@ -69,7 +69,7 @@ iroh-gossip = { version = "0.35", default-features = false, features = ["net"] }
|
||||
iroh = { version = "0.35", default-features = false }
|
||||
kamadak-exif = "0.6.1"
|
||||
libc = { workspace = true }
|
||||
mail-builder = { version = "0.5.0", default-features = false }
|
||||
mail-builder = { version = "1.0.0", default-features = false }
|
||||
mailparse = { workspace = true }
|
||||
mime = "0.3.17"
|
||||
num_cpus = "1.17"
|
||||
@@ -77,7 +77,7 @@ num-derive = "0.4"
|
||||
num-traits = { workspace = true }
|
||||
parking_lot = "0.12.4"
|
||||
percent-encoding = "2.3"
|
||||
pgp = { version = "0.20.0", features = ["draft-pqc"], default-features = false }
|
||||
pgp = { version = "0.21.0", features = ["pqc"], default-features = false }
|
||||
pin-project = "1"
|
||||
qrcodegen = "1.7.0"
|
||||
quick-xml = { version = "0.41", features = ["escape-html"] }
|
||||
@@ -104,7 +104,6 @@ astral-tokio-tar = { version = "0.7.0", default-features = false }
|
||||
tokio-util = { workspace = true }
|
||||
tokio = { workspace = true, features = ["fs", "rt-multi-thread", "macros"] }
|
||||
toml = "0.9"
|
||||
tracing = "0.1.41"
|
||||
url = "2"
|
||||
uuid = { version = "1", features = ["serde", "v4"] }
|
||||
walkdir = "2.5.0"
|
||||
@@ -179,7 +178,7 @@ harness = false
|
||||
[workspace.dependencies]
|
||||
anyhow = "1"
|
||||
async-channel = "2.5.0"
|
||||
base64 = "0.22"
|
||||
base64 = { version = "0.23", default-features = false, features = ["std"] }
|
||||
chrono = { version = "0.4.44", default-features = false }
|
||||
deltachat-contact-tools = { path = "deltachat-contact-tools" }
|
||||
deltachat-jsonrpc = { path = "deltachat-jsonrpc", default-features = false }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat_ffi"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
description = "Deltachat FFI"
|
||||
edition = "2024"
|
||||
license = "MPL-2.0"
|
||||
|
||||
+29
-22
@@ -3543,28 +3543,6 @@ uint32_t dc_chatlist_get_msg_id (const dc_chatlist_t* chatlist, siz
|
||||
dc_lot_t* dc_chatlist_get_summary (const dc_chatlist_t* chatlist, size_t index, dc_chat_t* chat);
|
||||
|
||||
|
||||
/**
|
||||
* Create a chatlist summary item when the chatlist object is already unref()'d.
|
||||
*
|
||||
* This function is similar to dc_chatlist_get_summary(), however,
|
||||
* it takes the chat ID and the message ID as returned by dc_chatlist_get_chat_id() and dc_chatlist_get_msg_id()
|
||||
* as arguments. The chatlist object itself is not needed directly.
|
||||
*
|
||||
* This maybe useful if you convert the complete object into a different representation
|
||||
* as done e.g. in the node-bindings.
|
||||
* If you have access to the chatlist object in some way, using this function is not recommended,
|
||||
* use dc_chatlist_get_summary() in this case instead.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object.
|
||||
* @param chat_id The chat ID to get a summary for.
|
||||
* @param msg_id The message ID to get a summary for.
|
||||
* @return The summary as an dc_lot_t object, see dc_chatlist_get_summary() for details.
|
||||
* Must be freed using dc_lot_unref(). NULL is never returned.
|
||||
*/
|
||||
dc_lot_t* dc_chatlist_get_summary2 (dc_context_t* context, uint32_t chat_id, uint32_t msg_id);
|
||||
|
||||
|
||||
/**
|
||||
* Get info summary for a chat, in JSON format.
|
||||
*
|
||||
@@ -4313,6 +4291,7 @@ dc_lot_t* dc_msg_get_summary (const dc_msg_t* msg, const dc_cha
|
||||
* notifications.
|
||||
*
|
||||
* @memberof dc_msg_t
|
||||
* @deprecated 2026-10-08, use dc_msg_get_summary_text(msg, 1, 1, approx_chars) instead
|
||||
* @param msg The message object.
|
||||
* @param approx_characters A rough length of the expected string.
|
||||
* @return A summary for the given messages.
|
||||
@@ -4322,6 +4301,34 @@ dc_lot_t* dc_msg_get_summary (const dc_msg_t* msg, const dc_cha
|
||||
char* dc_msg_get_summarytext (const dc_msg_t* msg, int approx_characters);
|
||||
|
||||
|
||||
/**
|
||||
* Get a message summary.
|
||||
* Used for notifications, pinned messages and for copying texts to clipboard.
|
||||
*
|
||||
* @memberof dc_msg_t
|
||||
* @param msg The message object.
|
||||
* @param add_forwarded 1=add a hint if a message was forwarded.
|
||||
* 0=do not add the hint;
|
||||
* this is allowed only if the message is shown without a username, e.g. for pinned messages.
|
||||
* @param add_type_emoji 1=add the type of the message as an emoji prefix.
|
||||
* 0=do not add type emoji;
|
||||
* this is allowed only if the message type is visible otherwise,
|
||||
* close to where the emoji would be displayed otherwise
|
||||
* (eg. images in pinned messages preceding summary)
|
||||
* @param approx_chars >0=convert linebreaks to spaces and truncate the line at about the given number of characters;
|
||||
* for single-line UI elements such as pinned messages or notifications;
|
||||
* additionally, UIs will most times clip the text to the available space.
|
||||
* 0=leave linebreaks as is and return the full text, useful e.g. for copying to clipboard.
|
||||
* @return A summary for the given message.
|
||||
* The returned string must be released using dc_str_unref().
|
||||
* Returns an empty string on errors, never returns NULL.
|
||||
*/
|
||||
char* dc_msg_get_summary_text (const dc_msg_t* msg, int add_forwarded, int add_type_emoji, int approx_chars);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the name that should be shown over the message (in a group chat) instead of the contact
|
||||
* display name, or NULL.
|
||||
|
||||
+31
-37
@@ -12,7 +12,6 @@
|
||||
extern crate human_panic;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::Write;
|
||||
use std::future::Future;
|
||||
use std::mem::ManuallyDrop;
|
||||
@@ -47,7 +46,6 @@ mod dc_array;
|
||||
mod lot;
|
||||
|
||||
mod string;
|
||||
use deltachat::chatlist::Chatlist;
|
||||
|
||||
use self::string::*;
|
||||
|
||||
@@ -2844,34 +2842,6 @@ pub unsafe extern "C" fn dc_chatlist_get_summary(
|
||||
Box::into_raw(Box::new(summary.into()))
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn dc_chatlist_get_summary2(
|
||||
context: *mut dc_context_t,
|
||||
chat_id: u32,
|
||||
msg_id: u32,
|
||||
) -> *mut dc_lot_t {
|
||||
if context.is_null() {
|
||||
eprintln!("ignoring careless call to dc_chatlist_get_summary2()");
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let ctx = unsafe { &*context };
|
||||
let msg_id = if msg_id == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(MsgId::new(msg_id))
|
||||
};
|
||||
let summary = block_on(Chatlist::get_summary2(
|
||||
ctx,
|
||||
ChatId::new(chat_id),
|
||||
msg_id,
|
||||
None,
|
||||
))
|
||||
.context("get_summary2 failed")
|
||||
.log_err(ctx)
|
||||
.unwrap_or_default();
|
||||
Box::into_raw(Box::new(summary.into()))
|
||||
}
|
||||
|
||||
// dc_chat_t
|
||||
|
||||
/// FFI struct for [dc_chat_t]
|
||||
@@ -3502,6 +3472,7 @@ pub unsafe extern "C" fn dc_msg_get_summary(
|
||||
Box::into_raw(Box::new(summary.into()))
|
||||
}
|
||||
|
||||
// deprecated, use dc_msg_get_summary_text instead
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn dc_msg_get_summarytext(
|
||||
msg: *mut dc_msg_t,
|
||||
@@ -3513,14 +3484,37 @@ pub unsafe extern "C" fn dc_msg_get_summarytext(
|
||||
}
|
||||
let ffi_msg = unsafe { &mut *msg };
|
||||
|
||||
let summary = block_on(ffi_msg.message.get_summary(&ffi_msg.context, None))
|
||||
.context("dc_msg_get_summarytext failed")
|
||||
.log_err(&ffi_msg.context)
|
||||
.unwrap_or_default();
|
||||
match usize::try_from(approx_characters) {
|
||||
Ok(chars) => summary.truncated_text(chars).strdup(),
|
||||
Err(_) => summary.text.strdup(),
|
||||
let add_forwarded = true;
|
||||
let add_type_emoji = true;
|
||||
block_on(ffi_msg.message.get_summary_text_ext(
|
||||
&ffi_msg.context,
|
||||
add_forwarded,
|
||||
add_type_emoji,
|
||||
usize::try_from(approx_characters).unwrap_or_default(),
|
||||
))
|
||||
.strdup()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn dc_msg_get_summary_text(
|
||||
msg: *mut dc_msg_t,
|
||||
add_forwarded: libc::c_int,
|
||||
add_type_emoji: libc::c_int,
|
||||
approx_chars: libc::c_int,
|
||||
) -> *mut libc::c_char {
|
||||
if msg.is_null() {
|
||||
eprintln!("ignoring careless call to dc_msg_get_summary_text()");
|
||||
return "".strdup();
|
||||
}
|
||||
let ffi_msg = unsafe { &mut *msg };
|
||||
|
||||
block_on(ffi_msg.message.get_summary_text_ext(
|
||||
&ffi_msg.context,
|
||||
add_forwarded != 0,
|
||||
add_type_emoji != 0,
|
||||
usize::try_from(approx_chars).unwrap_or(0),
|
||||
))
|
||||
.strdup()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat-jsonrpc-bindings"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
description = "Autogenerate DeltaChat JSON-RPC API bindings at build time"
|
||||
edition = "2024"
|
||||
license = "MPL-2.0"
|
||||
|
||||
@@ -54,5 +54,5 @@
|
||||
},
|
||||
"type": "module",
|
||||
"types": "dist/deltachat.d.ts",
|
||||
"version": "2.63.0-dev"
|
||||
"version": "2.64.0-dev"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat-jsonrpc"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
description = "DeltaChat JSON-RPC API"
|
||||
edition = "2024"
|
||||
license = "MPL-2.0"
|
||||
|
||||
@@ -31,8 +31,6 @@ pub enum ChatListItemFetchResult {
|
||||
summary_text1: String,
|
||||
summary_text2: String,
|
||||
summary_status: u32,
|
||||
/// showing preview if last chat message is image
|
||||
summary_preview_image: Option<String>,
|
||||
|
||||
/// True if the chat is encrypted.
|
||||
/// This means that all messages in the chat are encrypted,
|
||||
@@ -103,8 +101,6 @@ pub(crate) async fn get_chat_list_item_by_id(
|
||||
let summary_text1 = summary.prefix.map_or_else(String::new, |s| s.to_string());
|
||||
let summary_text2 = summary.text.to_owned();
|
||||
|
||||
let summary_preview_image = summary.thumbnail_path;
|
||||
|
||||
let visibility = chat.get_visibility();
|
||||
|
||||
let avatar_path = chat
|
||||
@@ -157,7 +153,6 @@ pub(crate) async fn get_chat_list_item_by_id(
|
||||
summary_text1,
|
||||
summary_text2,
|
||||
summary_status: summary.state.to_u32().expect("impossible"), // idea and a function to transform the constant to strings? or return string enum
|
||||
summary_preview_image,
|
||||
is_encrypted: chat.is_encrypted(ctx).await?,
|
||||
is_group: chat.get_type() == Chattype::Group,
|
||||
fresh_message_counter,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat-repl"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
license = "MPL-2.0"
|
||||
edition = "2024"
|
||||
repository = "https://github.com/chatmail/core"
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "deltachat-rpc-client"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
license = "MPL-2.0"
|
||||
description = "Python client for Delta Chat core JSON-RPC interface"
|
||||
classifiers = [
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def anonymous_mib(pid):
|
||||
with open(f"/proc/{pid}/smaps_rollup") as f:
|
||||
for line in f:
|
||||
if line.startswith("Anonymous:"):
|
||||
return int(line.split()[1]) // 1024
|
||||
raise LookupError("Anonymous")
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform != "linux", reason="reads /proc")
|
||||
def test_attachment_memory_is_returned(acf, rpc, tmp_path):
|
||||
# See also comments for `tune_malloc` in `deltachat-rpc-server/src/main.rs`
|
||||
ac1, ac2 = acf.get_online_accounts(2)
|
||||
chat1 = acf.get_accepted_chat(ac1, ac2)
|
||||
chat2 = ac2.create_chat(ac1)
|
||||
blob = tmp_path / "blob.bin"
|
||||
blob.write_bytes(os.urandom(20 << 20))
|
||||
before = anonymous_mib(rpc.process.pid)
|
||||
|
||||
for sender_chat, receiver in ((chat1, ac2), (chat2, ac1)):
|
||||
sender_chat.send_file(str(blob))
|
||||
event = receiver.wait_for_incoming_msg_event()
|
||||
assert receiver.get_message_by_id(event.msg_id).get_snapshot().file_bytes == 20 << 20
|
||||
for ac in (ac1, ac2):
|
||||
rpc.wait_for_all_work_done(ac.id)
|
||||
|
||||
grown = anonymous_mib(rpc.process.pid) - before
|
||||
assert grown < 64, f"the server kept {grown} MiB after two 20 MiB attachments"
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deltachat-rpc-server"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
description = "DeltaChat JSON-RPC server"
|
||||
edition = "2024"
|
||||
license = "MPL-2.0"
|
||||
@@ -14,6 +14,7 @@ deltachat = { workspace = true }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
futures-lite = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
log = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
},
|
||||
"type": "module",
|
||||
"types": "index.d.ts",
|
||||
"version": "2.63.0-dev"
|
||||
"version": "2.64.0-dev"
|
||||
}
|
||||
|
||||
@@ -22,8 +22,32 @@ use tokio::task::JoinHandle;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use yerpc::{RpcClient, RpcSession};
|
||||
|
||||
/// Pins Linux glibc's mmap threshold so that freed message buffers go back to the kernel.
|
||||
///
|
||||
/// See M_MMAP_THRESHOLD in <https://man7.org/linux/man-pages/man3/mallopt.3.html>:
|
||||
/// glibc by default starts with a M_MMAP_THRESHOLD threshold of 128 KiB
|
||||
/// but raises it to the size of every freed block that exceeds it,
|
||||
/// up to 32 MiB on 64-bit systems,
|
||||
/// and trims the heap only from its top end once twice that much is free.
|
||||
/// Fixating the threshold disables the adjustment: allocations at or above it
|
||||
/// that the free list cannot satisfy are mmapped and unmapped on free,
|
||||
/// at the price of the kernel zeroing each such buffer after unmap.
|
||||
/// Large message processing (allocations above 128KiB) very slightly slows
|
||||
/// down to the kernel zeroing the buffers, but it's hardly measurable,
|
||||
/// while overall process memory allocation behaviour significantly improves.
|
||||
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
||||
fn tune_malloc() {
|
||||
unsafe {
|
||||
libc::mallopt(libc::M_MMAP_THRESHOLD, 128 * 1024);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
|
||||
fn tune_malloc() {}
|
||||
|
||||
#[tokio::main(flavor = "multi_thread")]
|
||||
async fn main() {
|
||||
tune_malloc();
|
||||
// Logs from `log` crate and traces from `tracing` crate
|
||||
// are configurable with `RUST_LOG` environment variable
|
||||
// and go to stderr to avoid interfering with JSON-RPC using stdout.
|
||||
|
||||
@@ -63,6 +63,7 @@ ignore = [
|
||||
# Please keep this list alphabetically sorted.
|
||||
skip = [
|
||||
{ name = "async-channel", version = "1.9.0" },
|
||||
{ name = "base64", version = "0.22.1" },
|
||||
{ name = "bitflags", version = "1.3.2" },
|
||||
{ name = "constant_time_eq", version = "0.3.1" },
|
||||
{ name = "cpufeatures", version = "0.2.17" },
|
||||
|
||||
@@ -456,6 +456,21 @@ CREATE TABLE smtp_status_updates (
|
||||
descr TEXT NOT NULL -- text to send along with the updates
|
||||
);
|
||||
|
||||
-- Table to record the successful usage transports for sending.
|
||||
-- Sorting the table by rowid in descending order
|
||||
-- returns most recently successfully used transport first.
|
||||
CREATE TABLE smtp_success (
|
||||
-- Sequentially increasing ID of the success.
|
||||
-- Transport with the highest ID is to be used first.
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
|
||||
-- ID of the transport that was used to send a message.
|
||||
transport_id INTEGER UNIQUE NOT NULL,
|
||||
|
||||
-- Delete `smtp_success` rows when the transport is deleted.
|
||||
FOREIGN KEY(transport_id) REFERENCES transports(id) ON DELETE CASCADE
|
||||
) STRICT;
|
||||
|
||||
-- Table of "sync items" to be grouped into sync messages
|
||||
-- and sent to own devices.
|
||||
CREATE TABLE multi_device_sync (
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "deltachat"
|
||||
version = "2.63.0-dev"
|
||||
version = "2.64.0-dev"
|
||||
license = "MPL-2.0"
|
||||
description = "Python bindings for the Delta Chat Core library using CFFI against the Rust-implemented libdeltachat"
|
||||
readme = "README.rst"
|
||||
|
||||
@@ -188,7 +188,7 @@ class Message:
|
||||
|
||||
def get_summarytext(self, width: int) -> str:
|
||||
"""Get a message summary as a single line of text. Typically used for notifications."""
|
||||
return from_dc_charpointer(lib.dc_msg_get_summarytext(self._dc_msg, width))
|
||||
return from_dc_charpointer(lib.dc_msg_get_summary_text(self._dc_msg, 1, 1, width))
|
||||
|
||||
@props.with_doc
|
||||
def time_sent(self):
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2026-09-22
|
||||
2026-10-09
|
||||
+1
-1
@@ -6,4 +6,4 @@
|
||||
#
|
||||
# To automatically fix warnings, run
|
||||
# scripts/clippy.sh --fix --allow-dirty
|
||||
cargo clippy --locked --workspace --all-targets --all-features "$@" -- -D warnings
|
||||
cargo clippy --locked --workspace --exclude deltachat-jsonrpc-bindings --all-targets --all-features "$@" -- -D warnings
|
||||
|
||||
+3
-22
@@ -76,12 +76,8 @@ impl Accounts {
|
||||
Accounts::open(events, dir, writable).await
|
||||
}
|
||||
|
||||
/// Get the ID used to log events.
|
||||
///
|
||||
/// Account manager logs events with ID 0
|
||||
/// which is not used by any accounts.
|
||||
fn get_id(&self) -> u32 {
|
||||
0
|
||||
fn log_info(&self, file: &str, line: u32, msg: String) {
|
||||
self.emit_event(EventType::Info(format!("{file}:{line}: {msg}")));
|
||||
}
|
||||
|
||||
/// Ensures the accounts directory and config file exist.
|
||||
@@ -395,11 +391,6 @@ impl Accounts {
|
||||
"Starting background fetch for {n_accounts} accounts."
|
||||
)),
|
||||
});
|
||||
::tracing::event!(
|
||||
::tracing::Level::INFO,
|
||||
account_id = 0,
|
||||
"Starting background fetch for {n_accounts} accounts."
|
||||
);
|
||||
let mut set = JoinSet::new();
|
||||
for account in accounts {
|
||||
set.spawn(async move {
|
||||
@@ -415,11 +406,6 @@ impl Accounts {
|
||||
"Finished background fetch for {n_accounts} accounts."
|
||||
)),
|
||||
});
|
||||
::tracing::event!(
|
||||
::tracing::Level::INFO,
|
||||
account_id = 0,
|
||||
"Finished background fetch for {n_accounts} accounts."
|
||||
);
|
||||
}
|
||||
|
||||
/// Auxiliary function for [Accounts::background_fetch].
|
||||
@@ -462,11 +448,6 @@ impl Accounts {
|
||||
id: 0,
|
||||
typ: EventType::Warning("Background fetch timed out.".to_string()),
|
||||
});
|
||||
::tracing::event!(
|
||||
::tracing::Level::WARN,
|
||||
account_id = 0,
|
||||
"Background fetch timed out."
|
||||
);
|
||||
}
|
||||
events.emit(Event {
|
||||
id: 0,
|
||||
@@ -549,7 +530,7 @@ impl Accounts {
|
||||
}
|
||||
}
|
||||
|
||||
/// Emits a single event.
|
||||
/// Emits a single event with ID 0, which is not used by any accounts.
|
||||
pub fn emit_event(&self, event: EventType) {
|
||||
self.events.emit(Event { id: 0, typ: event })
|
||||
}
|
||||
|
||||
+18
-1
@@ -350,7 +350,24 @@ impl<'a> BlobObject<'a> {
|
||||
*vt = Viewtype::Image;
|
||||
return Ok(name);
|
||||
}
|
||||
let mut img = imgreader.decode().context("image decode failure")?;
|
||||
|
||||
let mut img = match fmt {
|
||||
image::ImageFormat::WebP => {
|
||||
// `with_guessed_format()` restores file position,
|
||||
// so `buf_reader` is at the beginning of the file.
|
||||
let buf_reader = imgreader.into_inner();
|
||||
let webp_decoder = image::codecs::webp::WebPDecoder::new(buf_reader)
|
||||
.context("Failed to create WebP decoder")?;
|
||||
|
||||
// If WebP has animation, do not try to recode it.
|
||||
// Recoding into JPEG will result in losing the animation.
|
||||
if !is_avatar && webp_decoder.has_animation() {
|
||||
return Ok(name);
|
||||
}
|
||||
DynamicImage::from_decoder(webp_decoder)?
|
||||
}
|
||||
_ => imgreader.decode().context("Failed to decode image")?,
|
||||
};
|
||||
let orientation = exif
|
||||
.as_ref()
|
||||
.map(|exif| exif_orientation(exif, context))
|
||||
|
||||
+67
-1
@@ -4,7 +4,9 @@ use super::*;
|
||||
use crate::message::{Message, Viewtype};
|
||||
use crate::param::Param;
|
||||
use crate::sql;
|
||||
use crate::test_utils::{self, AVATAR_64x64_BYTES, AVATAR_64x64_DEDUPLICATED, TestContext};
|
||||
use crate::test_utils::{
|
||||
self, AVATAR_64x64_BYTES, AVATAR_64x64_DEDUPLICATED, TestContext, TestContextManager,
|
||||
};
|
||||
use crate::tools::SystemTime;
|
||||
|
||||
fn check_image_size(path: impl AsRef<Path>, width: u32, height: u32) -> image::DynamicImage {
|
||||
@@ -738,6 +740,70 @@ async fn test_send_gif_as_sticker() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Tests that animated WebP is sent without reencoding.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_send_animated_webp_as_image() -> Result<()> {
|
||||
let bytes = include_bytes!("../../test-data/image/animated.webp");
|
||||
assert!(
|
||||
bytes.len() > constants::WORSE_IMAGE_SIZE as usize,
|
||||
"Animated WebP should be large enough to trigger reencoding"
|
||||
);
|
||||
let (width, height) = (900u32, 900u32);
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = &tcm.alice().await;
|
||||
let bob = &tcm.bob().await;
|
||||
alice
|
||||
.set_config(
|
||||
Config::MediaQuality,
|
||||
Some(&(MediaQuality::Worse as i32).to_string()),
|
||||
)
|
||||
.await?;
|
||||
let file = alice.get_blobdir().join("file").with_extension("webp");
|
||||
fs::write(&file, &bytes)
|
||||
.await
|
||||
.context("Failed to write file")?;
|
||||
let mut msg = Message::new(Viewtype::Image);
|
||||
msg.set_file_and_deduplicate(alice, &file, Some("file.webp"), None)?;
|
||||
|
||||
let chat = alice.create_chat(bob).await;
|
||||
let sent = alice.send_msg(chat.id, &mut msg).await;
|
||||
let bob_msg = bob.recv_msg(&sent).await;
|
||||
assert_eq!(bob_msg.get_viewtype(), Viewtype::Image);
|
||||
assert_eq!(bob_msg.get_width() as u32, width);
|
||||
assert_eq!(bob_msg.get_height() as u32, height);
|
||||
assert_eq!(
|
||||
bob_msg.get_filebytes(bob).await?.unwrap(),
|
||||
bytes.len() as u64
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Tests that if user sets animated WebP as an avatar, it may be recoded.
|
||||
///
|
||||
/// We don't want to recode animated WebPs into JPEG and lose animation,
|
||||
/// but for avatars we don't want animation and transparency anyway.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_recode_animated_webp_avatar() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let t = &tcm.alice().await;
|
||||
|
||||
let avatar_src = t.dir.path().join("avatar.webp");
|
||||
let avatar_bytes = include_bytes!("../../test-data/image/animated.webp");
|
||||
fs::write(&avatar_src, avatar_bytes).await.unwrap();
|
||||
|
||||
t.set_config(Config::Selfavatar, Some(avatar_src.to_str().unwrap()))
|
||||
.await?;
|
||||
let avatar_blob = t.get_config(Config::Selfavatar).await?.unwrap();
|
||||
assert!(avatar_blob.ends_with(".jpg"));
|
||||
|
||||
let scaled_avatar_size = fs::metadata(&avatar_blob).await.unwrap().len();
|
||||
assert!(
|
||||
scaled_avatar_size < avatar_bytes.len() as u64,
|
||||
"Animated WebP avatar must be recoded"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_create_and_deduplicate() -> Result<()> {
|
||||
let t = TestContext::new().await;
|
||||
|
||||
+1
-3
@@ -3,7 +3,6 @@
|
||||
use std::cmp;
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::fmt;
|
||||
use std::io::Cursor;
|
||||
use std::marker::Sync;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
@@ -1918,8 +1917,7 @@ impl Chat {
|
||||
let new_mime_headers: Option<String> = new_mime_headers.map(|s| {
|
||||
let html_part = MimePart::new("text/html", s);
|
||||
let mut buffer = Vec::new();
|
||||
let cursor = Cursor::new(&mut buffer);
|
||||
html_part.write_part(cursor).ok();
|
||||
html_part.write_part(&mut buffer);
|
||||
String::from_utf8_lossy(&buffer).to_string()
|
||||
});
|
||||
let new_mime_headers = new_mime_headers.or_else(|| match was_truncated {
|
||||
|
||||
+12
-22
@@ -1457,7 +1457,6 @@ impl Session {
|
||||
fn drain_unsolicited_responses(&self, context: &Context) -> bool {
|
||||
use UnsolicitedResponse::*;
|
||||
use async_imap::imap_proto::Response;
|
||||
use async_imap::imap_proto::ResponseCode;
|
||||
|
||||
let folder = self.selected_folder.as_deref().unwrap_or_default();
|
||||
let mut should_refetch = false;
|
||||
@@ -1472,28 +1471,19 @@ impl Session {
|
||||
}
|
||||
|
||||
Expunge(_) | Recent(_) => {}
|
||||
Other(ref response_data) => {
|
||||
match response_data.parsed() {
|
||||
Response::Fetch { .. } => {
|
||||
info!(
|
||||
context,
|
||||
"Need to refetch {folder:?}, got unsolicited FETCH {response:?}"
|
||||
);
|
||||
should_refetch = true;
|
||||
}
|
||||
|
||||
// We are not interested in the following responses and they are are
|
||||
// sent quite frequently, so, we ignore them without logging them.
|
||||
Response::Done {
|
||||
code: Some(ResponseCode::CopyUid(_, _, _)),
|
||||
..
|
||||
} => {}
|
||||
|
||||
_ => {
|
||||
info!(context, "{folder:?}: got unsolicited response {response:?}")
|
||||
}
|
||||
Other(ref response_data) => match response_data.parsed() {
|
||||
Response::Fetch { .. } => {
|
||||
info!(
|
||||
context,
|
||||
"Need to refetch {folder:?}, got unsolicited FETCH {response:?}"
|
||||
);
|
||||
should_refetch = true;
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
info!(context, "{folder:?}: got unsolicited response {response:?}")
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
info!(context, "{folder:?}: got unsolicited response {response:?}")
|
||||
}
|
||||
|
||||
+23
-30
@@ -3,6 +3,7 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use crate::context::Context;
|
||||
use crate::events::EventType;
|
||||
|
||||
mod stream;
|
||||
|
||||
@@ -12,15 +13,9 @@ macro_rules! info {
|
||||
($ctx:expr, $msg:expr) => {
|
||||
info!($ctx, $msg,)
|
||||
};
|
||||
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
|
||||
let formatted = format!($msg, $($args),*);
|
||||
let full = format!("{file}:{line}: {msg}",
|
||||
file = file!(),
|
||||
line = line!(),
|
||||
msg = &formatted);
|
||||
::tracing::event!(::tracing::Level::INFO, account_id = $ctx.get_id(), "{}", &formatted);
|
||||
$ctx.emit_event($crate::EventType::Info(full));
|
||||
}};
|
||||
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {
|
||||
$ctx.log_info(file!(), line!(), format!($msg, $($args),*))
|
||||
};
|
||||
}
|
||||
|
||||
// Workaround for <https://github.com/rust-lang/rust/issues/133708>.
|
||||
@@ -30,15 +25,9 @@ mod warn_macro_mod {
|
||||
($ctx:expr, $msg:expr) => {
|
||||
warn_macro!($ctx, $msg,)
|
||||
};
|
||||
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
|
||||
let formatted = format!($msg, $($args),*);
|
||||
let full = format!("{file}:{line}: {msg}",
|
||||
file = file!(),
|
||||
line = line!(),
|
||||
msg = &formatted);
|
||||
::tracing::event!(::tracing::Level::WARN, account_id = $ctx.get_id(), "{}", &formatted);
|
||||
$ctx.emit_event($crate::EventType::Warning(full));
|
||||
}};
|
||||
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {
|
||||
$ctx.log_warn(file!(), line!(), format!($msg, $($args),*))
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use warn_macro;
|
||||
@@ -50,15 +39,25 @@ macro_rules! error {
|
||||
($ctx:expr, $msg:expr) => {
|
||||
error!($ctx, $msg,)
|
||||
};
|
||||
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {{
|
||||
let formatted = format!($msg, $($args),*);
|
||||
::tracing::event!(::tracing::Level::ERROR, account_id = $ctx.get_id(), "{}", &formatted);
|
||||
$ctx.set_last_error(&formatted);
|
||||
$ctx.emit_event($crate::EventType::Error(formatted));
|
||||
}};
|
||||
($ctx:expr, $msg:expr, $($args:expr),* $(,)?) => {
|
||||
$ctx.log_error(format!($msg, $($args),*))
|
||||
};
|
||||
}
|
||||
|
||||
impl Context {
|
||||
pub(crate) fn log_info(&self, file: &str, line: u32, msg: String) {
|
||||
self.emit_event(EventType::Info(format!("{file}:{line}: {msg}")));
|
||||
}
|
||||
|
||||
pub(crate) fn log_warn(&self, file: &str, line: u32, msg: String) {
|
||||
self.emit_event(EventType::Warning(format!("{file}:{line}: {msg}")));
|
||||
}
|
||||
|
||||
pub(crate) fn log_error(&self, msg: String) {
|
||||
self.set_last_error(&msg);
|
||||
self.emit_event(EventType::Error(msg));
|
||||
}
|
||||
|
||||
/// Set last error string.
|
||||
/// Implemented as blocking as used from macros in different, not always async blocks.
|
||||
pub fn set_last_error(&self, error: &str) {
|
||||
@@ -116,12 +115,6 @@ impl<T, E: std::fmt::Display> LogExt<T, E> for Result<T, E> {
|
||||
);
|
||||
// We can't use the warn!() macro here as the file!() and line!() macros
|
||||
// don't work with #[track_caller]
|
||||
tracing::event!(
|
||||
::tracing::Level::WARN,
|
||||
account_id = context.get_id(),
|
||||
"{}",
|
||||
&full
|
||||
);
|
||||
context.emit_event(crate::EventType::Warning(full));
|
||||
};
|
||||
self
|
||||
|
||||
@@ -93,11 +93,6 @@ impl<S: SessionStream> AsyncRead for LoggingStream<S> {
|
||||
"Read error on stream {peer_addr:?} after reading {} and writing {} bytes: {err}.",
|
||||
this.metrics.total_read, this.metrics.total_written
|
||||
);
|
||||
tracing::event!(
|
||||
::tracing::Level::WARN,
|
||||
account_id = *this.account_id,
|
||||
log_message
|
||||
);
|
||||
this.events.emit(Event {
|
||||
id: *this.account_id,
|
||||
typ: EventType::Warning(log_message),
|
||||
|
||||
+8
-15
@@ -1,7 +1,6 @@
|
||||
//! # MIME message production.
|
||||
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
use std::io::Cursor;
|
||||
|
||||
use anyhow::{Context as _, Result, bail, format_err};
|
||||
use base64::Engine as _;
|
||||
@@ -245,25 +244,20 @@ pub(crate) fn render_queued_mail(
|
||||
|
||||
let is_encrypted = encryption.is_encrypted();
|
||||
|
||||
fn add_header(
|
||||
name: &[u8],
|
||||
value: &impl mail_builder::headers::Header,
|
||||
headers: &mut Vec<u8>,
|
||||
) -> Result<()> {
|
||||
fn add_header(name: &[u8], value: &impl mail_builder::headers::Header, headers: &mut Vec<u8>) {
|
||||
headers.extend(name);
|
||||
value.write_header(headers, name.len())?;
|
||||
Ok(())
|
||||
value.write_header(headers, name.len());
|
||||
}
|
||||
|
||||
let from_header = new_address_with_name(&display_name, from_addr.clone());
|
||||
add_header(b"From: ", &from_header, &mut inner_headers)?;
|
||||
add_header(b"From: ", &from_header, &mut inner_headers);
|
||||
|
||||
if is_encrypted {
|
||||
let unencrypted_from = Address::new_address(None::<&'static str>, from_addr.clone());
|
||||
add_header(b"From: ", &unencrypted_from, &mut outer_headers)?;
|
||||
add_header(b"HP-Outer: From: ", &unencrypted_from, &mut inner_headers)?;
|
||||
add_header(b"From: ", &unencrypted_from, &mut outer_headers);
|
||||
add_header(b"HP-Outer: From: ", &unencrypted_from, &mut inner_headers);
|
||||
} else {
|
||||
add_header(b"From: ", &from_header, &mut outer_headers)?;
|
||||
add_header(b"From: ", &from_header, &mut outer_headers);
|
||||
}
|
||||
|
||||
if is_encrypted {
|
||||
@@ -334,7 +328,7 @@ pub(crate) fn render_queued_mail(
|
||||
} else {
|
||||
&mut outer_headers
|
||||
},
|
||||
)?;
|
||||
);
|
||||
}
|
||||
|
||||
if is_encrypted {
|
||||
@@ -2433,8 +2427,7 @@ pub(crate) async fn keyupdate_message(
|
||||
/// Renders MIME part into a vector of bytes.
|
||||
pub(crate) fn part_to_bytes(message: MimePart<'static>) -> Vec<u8> {
|
||||
let mut raw_message = Vec::new();
|
||||
let cursor = Cursor::new(&mut raw_message);
|
||||
message.write_part(cursor).ok();
|
||||
message.write_part(&mut raw_message);
|
||||
raw_message
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use pgp::armor;
|
||||
use pgp::packet::{Packet, PacketParser};
|
||||
use pretty_assertions::assert_eq;
|
||||
use regex::regex;
|
||||
use std::io::BufReader;
|
||||
use std::io::{BufReader, Cursor};
|
||||
use std::str;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -30,8 +30,7 @@ fn render_email_address(display_name: &str, addr: &str) -> String {
|
||||
let mut output = Vec::<u8>::new();
|
||||
new_address_with_name(display_name, addr.to_string())
|
||||
.unwrap_address()
|
||||
.write_header(&mut output, 0)
|
||||
.unwrap();
|
||||
.write_header(&mut output, 0);
|
||||
|
||||
String::from_utf8(output).unwrap()
|
||||
}
|
||||
@@ -50,9 +49,7 @@ fn test_render_email_address() {
|
||||
|
||||
let s = render_email_address(display_name, addr);
|
||||
|
||||
println!("{s}");
|
||||
|
||||
assert_eq!(s, "=?utf-8?B?w6Qgc3BhY2U=?= <x@y.org>");
|
||||
assert_eq!(s, "=?utf-8?B?w6Qgc3BhY2U=?= <x@y.org>\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -70,14 +67,14 @@ fn test_render_email_address_noescape() {
|
||||
let s = render_email_address(display_name, addr);
|
||||
|
||||
// Addresses should not be unnecessarily be encoded, see <https://github.com/deltachat/deltachat-core-rust/issues/1575>:
|
||||
assert_eq!(s, r#""a space" <x@y.org>"#);
|
||||
assert_eq!(s, "\"a space\" <x@y.org>\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_render_email_address_duplicated_as_name() {
|
||||
let addr = "x@y.org";
|
||||
let s = render_email_address(addr, addr);
|
||||
assert_eq!(s, "<x@y.org>");
|
||||
assert_eq!(s, "<x@y.org>\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -102,8 +99,7 @@ fn render_header_text(text: &str) -> String {
|
||||
// Some non-zero length of the header name.
|
||||
let bytes_written = 20;
|
||||
mail_builder::headers::text::Text::new(text.to_string())
|
||||
.write_header(&mut output, bytes_written)
|
||||
.unwrap();
|
||||
.write_header(&mut output, bytes_written);
|
||||
|
||||
String::from_utf8(output).unwrap()
|
||||
}
|
||||
@@ -955,7 +951,7 @@ async fn test_no_empty_to_header() -> Result<()> {
|
||||
assert!(
|
||||
// It would be equally fine if the payload contained `To: alice@example.org` or similar,
|
||||
// as long as it's a valid header
|
||||
payload.contains("To: \"hidden-recipients\": ;"),
|
||||
payload.contains("To: \"hidden-recipients\":;"),
|
||||
"Payload doesn't contain correct To: header: {payload}"
|
||||
);
|
||||
|
||||
@@ -1064,8 +1060,8 @@ MIME-Version: 1.0
|
||||
To: "hidden-recipients": ;
|
||||
Subject: [...]
|
||||
Chat-Version: 1.0
|
||||
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted";
|
||||
boundary="BOUNDARY"
|
||||
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted";
|
||||
boundary="BOUNDARY"
|
||||
|
||||
|
||||
--BOUNDARY
|
||||
@@ -1106,17 +1102,18 @@ async fn test_render_unencrypted_msg_basic() -> Result<()> {
|
||||
let expected = r#"From: <alice@example.org>
|
||||
Message-ID: <MESSAGE_ID@localhost>
|
||||
MIME-Version: 1.0
|
||||
Autocrypt: addr=alice@example.org; prefer-encrypt=mutual; keydata=mDMEXlh13RYJKwYBBAHaRw8BAQdAzfVIAleCXMJrq8VeLlEVof6ITCviMktKjmcBKAu4m5
|
||||
DCtAQfFggAZgUCXlh13RYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDAhsDAh4JBAsJCAcFFQgJCgsDFgIB
|
||||
AycJAgIZASwUgAAAAAASABFyZWxheXNAY2hhdG1haWwuYXRhbGljZUBleGFtcGxlLm9yZwAAb1QA/0
|
||||
HbvPN3/Vn02Gk1dcQMEcyGyETld9dSsRo8uwHAyW35AQCrFJjAQFLTud7XK61uYt9BC/QHipCfIGbq
|
||||
X1FjMbTUC80TPGFsaWNlQGV4YW1wbGUub3JnPsKRBBMWCAA5BQJeWHXdFiEELm+iyyO1MtcoY0tYZL
|
||||
CPYantlEMCGwMCHgkECwkIBwUVCAkKCwMWAgEDJwkCAhkBAAoJEGSwj2Gp7ZRD1m4A/iOifEzIOiP8
|
||||
wW0O8I/sg69gQtG8Czn4MsVV6Ea1EyIqAP4uByHaUJdy8MSQPfv/Usr09KsidNgy2Jh37yg82fKUBr
|
||||
g4BF5Ydd0SCisGAQQBl1UBBQEBB0AG7cjWy2SFAU8KnltlubVW67rFiyfp01JrRe6Xqy22HQMBCAeI
|
||||
eAQYFggAIBYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDBQJeWHXdAhsMAAoJEGSwj2Gp7ZRDLo8BAObE8G
|
||||
nsGVwKzNqCvHeWgJsqhjS3C6gvSlV3tEm9XmF6AQDXucIyVfoBwoyMh2h6cSn/ATn5QJb35pgo+ivp
|
||||
3jsMAg==
|
||||
Autocrypt: addr=alice@example.org; prefer-encrypt=mutual;
|
||||
keydata=mDMEXlh13RYJKwYBBAHaRw8BAQdAzfVIAleCXMJrq8VeLlEVof6ITCviMktKjmcBKAu4m5
|
||||
DCtAQfFggAZgUCXlh13RYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDAhsDAh4JBAsJCAcFFQgJCgsDFgIB
|
||||
AycJAgIZASwUgAAAAAASABFyZWxheXNAY2hhdG1haWwuYXRhbGljZUBleGFtcGxlLm9yZwAAb1QA/0
|
||||
HbvPN3/Vn02Gk1dcQMEcyGyETld9dSsRo8uwHAyW35AQCrFJjAQFLTud7XK61uYt9BC/QHipCfIGbq
|
||||
X1FjMbTUC80TPGFsaWNlQGV4YW1wbGUub3JnPsKRBBMWCAA5BQJeWHXdFiEELm+iyyO1MtcoY0tYZL
|
||||
CPYantlEMCGwMCHgkECwkIBwUVCAkKCwMWAgEDJwkCAhkBAAoJEGSwj2Gp7ZRD1m4A/iOifEzIOiP8
|
||||
wW0O8I/sg69gQtG8Czn4MsVV6Ea1EyIqAP4uByHaUJdy8MSQPfv/Usr09KsidNgy2Jh37yg82fKUBr
|
||||
g4BF5Ydd0SCisGAQQBl1UBBQEBB0AG7cjWy2SFAU8KnltlubVW67rFiyfp01JrRe6Xqy22HQMBCAeI
|
||||
eAQYFggAIBYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDBQJeWHXdAhsMAAoJEGSwj2Gp7ZRDLo8BAObE8G
|
||||
nsGVwKzNqCvHeWgJsqhjS3C6gvSlV3tEm9XmF6AQDXucIyVfoBwoyMh2h6cSn/ATn5QJb35pgo+ivp
|
||||
3jsMAg==
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
Date: DATE
|
||||
To: <bob@example.net>
|
||||
@@ -1126,7 +1123,7 @@ Chat-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
Hello!"#
|
||||
.replace("\n", "\r\n");
|
||||
.replace("\n", "\r\n");
|
||||
assert_eq!(
|
||||
unencrypted, expected,
|
||||
"---------------- Actual: ----------------
|
||||
@@ -1156,19 +1153,20 @@ async fn test_render_unencrypted_msg_with_attachment() -> Result<()> {
|
||||
let expected = r#"From: <alice@example.org>
|
||||
Message-ID: <MESSAGE_ID@localhost>
|
||||
MIME-Version: 1.0
|
||||
Autocrypt: addr=alice@example.org; prefer-encrypt=mutual; keydata=mDMEXlh13RYJKwYBBAHaRw8BAQdAzfVIAleCXMJrq8VeLlEVof6ITCviMktKjmcBKAu4m5
|
||||
DCtAQfFggAZgUCXlh13RYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDAhsDAh4JBAsJCAcFFQgJCgsDFgIB
|
||||
AycJAgIZASwUgAAAAAASABFyZWxheXNAY2hhdG1haWwuYXRhbGljZUBleGFtcGxlLm9yZwAAb1QA/0
|
||||
HbvPN3/Vn02Gk1dcQMEcyGyETld9dSsRo8uwHAyW35AQCrFJjAQFLTud7XK61uYt9BC/QHipCfIGbq
|
||||
X1FjMbTUC80TPGFsaWNlQGV4YW1wbGUub3JnPsKRBBMWCAA5BQJeWHXdFiEELm+iyyO1MtcoY0tYZL
|
||||
CPYantlEMCGwMCHgkECwkIBwUVCAkKCwMWAgEDJwkCAhkBAAoJEGSwj2Gp7ZRD1m4A/iOifEzIOiP8
|
||||
wW0O8I/sg69gQtG8Czn4MsVV6Ea1EyIqAP4uByHaUJdy8MSQPfv/Usr09KsidNgy2Jh37yg82fKUBr
|
||||
g4BF5Ydd0SCisGAQQBl1UBBQEBB0AG7cjWy2SFAU8KnltlubVW67rFiyfp01JrRe6Xqy22HQMBCAeI
|
||||
eAQYFggAIBYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDBQJeWHXdAhsMAAoJEGSwj2Gp7ZRDLo8BAObE8G
|
||||
nsGVwKzNqCvHeWgJsqhjS3C6gvSlV3tEm9XmF6AQDXucIyVfoBwoyMh2h6cSn/ATn5QJb35pgo+ivp
|
||||
3jsMAg==
|
||||
Content-Type: multipart/mixed;
|
||||
boundary="BOUNDARY"
|
||||
Autocrypt: addr=alice@example.org; prefer-encrypt=mutual;
|
||||
keydata=mDMEXlh13RYJKwYBBAHaRw8BAQdAzfVIAleCXMJrq8VeLlEVof6ITCviMktKjmcBKAu4m5
|
||||
DCtAQfFggAZgUCXlh13RYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDAhsDAh4JBAsJCAcFFQgJCgsDFgIB
|
||||
AycJAgIZASwUgAAAAAASABFyZWxheXNAY2hhdG1haWwuYXRhbGljZUBleGFtcGxlLm9yZwAAb1QA/0
|
||||
HbvPN3/Vn02Gk1dcQMEcyGyETld9dSsRo8uwHAyW35AQCrFJjAQFLTud7XK61uYt9BC/QHipCfIGbq
|
||||
X1FjMbTUC80TPGFsaWNlQGV4YW1wbGUub3JnPsKRBBMWCAA5BQJeWHXdFiEELm+iyyO1MtcoY0tYZL
|
||||
CPYantlEMCGwMCHgkECwkIBwUVCAkKCwMWAgEDJwkCAhkBAAoJEGSwj2Gp7ZRD1m4A/iOifEzIOiP8
|
||||
wW0O8I/sg69gQtG8Czn4MsVV6Ea1EyIqAP4uByHaUJdy8MSQPfv/Usr09KsidNgy2Jh37yg82fKUBr
|
||||
g4BF5Ydd0SCisGAQQBl1UBBQEBB0AG7cjWy2SFAU8KnltlubVW67rFiyfp01JrRe6Xqy22HQMBCAeI
|
||||
eAQYFggAIBYhBC5vossjtTLXKGNLWGSwj2Gp7ZRDBQJeWHXdAhsMAAoJEGSwj2Gp7ZRDLo8BAObE8G
|
||||
nsGVwKzNqCvHeWgJsqhjS3C6gvSlV3tEm9XmF6AQDXucIyVfoBwoyMh2h6cSn/ATn5QJb35pgo+ivp
|
||||
3jsMAg==
|
||||
Content-Type: multipart/mixed;
|
||||
boundary="BOUNDARY"
|
||||
Date: DATE
|
||||
To: <bob@example.net>
|
||||
Subject: Message from alice@example.org
|
||||
|
||||
@@ -1032,7 +1032,6 @@ Content-Disposition: reaction\n\
|
||||
assert_eq!(summary.timestamp, bob_msg1.get_timestamp()); // time refers to message, not to reaction
|
||||
assert_eq!(summary.state, MessageState::InFresh); // state refers to message, not to reaction
|
||||
assert!(summary.prefix.is_none());
|
||||
assert!(summary.thumbnail_path.is_none());
|
||||
assert_summary(&alice, "BOB reacted 👍 to \"Party?\"").await;
|
||||
|
||||
// Alice reacts to own message as well
|
||||
|
||||
@@ -2957,6 +2957,7 @@ async fn test_weird_and_duplicated_filenames() -> Result<()> {
|
||||
"a.tar.gz",
|
||||
"a.a..a.a.a.a.tar.gz",
|
||||
"a. tar.tar.gz",
|
||||
"very long filename with emoji \u{1F600} very long file name with emoji \u{1FAE0} very long file name with emoji.tar.gz",
|
||||
] {
|
||||
let attachment = alice.blobdir.join(filename_sent);
|
||||
let content = "File content of tar.gz archive".to_string();
|
||||
|
||||
+49
-7
@@ -54,6 +54,39 @@ pub(crate) struct Smtp {
|
||||
pub(crate) last_send_error: Option<String>,
|
||||
}
|
||||
|
||||
/// Returns transports with their IDs in the order in which they should be tried.
|
||||
async fn sorted_transports(context: &Context) -> Result<Vec<(u32, ConfiguredLoginParam)>> {
|
||||
context
|
||||
.sql
|
||||
.query_map_vec(
|
||||
"SELECT transports.id, configured_param FROM transports
|
||||
LEFT JOIN smtp_success ON smtp_success.transport_id=transports.id
|
||||
ORDER BY IFNULL(smtp_success.id, 0) DESC, transports.id ASC",
|
||||
(),
|
||||
|row| {
|
||||
let id: u32 = row.get(0)?;
|
||||
let json: String = row.get(1)?;
|
||||
let param = ConfiguredLoginParam::from_json(&json)?;
|
||||
Ok((id, param))
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Records successful use of SMTP transport so it is tried first next time we connect to SMTP.
|
||||
async fn record_success(context: &Context, transport_id: u32) -> Result<()> {
|
||||
// INSERT OR REPLACE essentially replaces rowid of the row
|
||||
// if the row exists already, so it becomes the highest rowid in the table.
|
||||
context
|
||||
.sql
|
||||
.execute(
|
||||
"INSERT OR REPLACE INTO smtp_success (transport_id) VALUES (?)",
|
||||
(transport_id,),
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl Smtp {
|
||||
/// Create a new Smtp instances.
|
||||
pub fn new() -> Self {
|
||||
@@ -101,13 +134,7 @@ impl Smtp {
|
||||
|
||||
self.connectivity.set_connecting(context);
|
||||
let proxy_config = ProxyConfig::load(context).await?;
|
||||
let transports = ConfiguredLoginParam::load_all(context).await?;
|
||||
|
||||
// Try to connect to the newest transport first. If sending is unreliable,
|
||||
// user can configure a new transport and it will be the one used.
|
||||
// Conversely, if user just added a new transport and sending got less reliable,
|
||||
// user can restore old state by removing the just added transport.
|
||||
for (transport_id, lp) in transports.into_iter().rev() {
|
||||
for (transport_id, lp) in sorted_transports(context).await? {
|
||||
info!(context, "Trying to connect to transport {transport_id}.");
|
||||
match self
|
||||
.connect(
|
||||
@@ -327,6 +354,18 @@ pub(crate) async fn smtp_send(
|
||||
Ok(()) => SendResult::Success,
|
||||
};
|
||||
|
||||
if matches!(status, SendResult::Success) {
|
||||
debug_assert!(smtp.transport_id.is_some());
|
||||
if let Some(transport_id) = smtp.transport_id
|
||||
&& let Err(err) = record_success(context, transport_id).await
|
||||
{
|
||||
warn!(
|
||||
context,
|
||||
"Failed to record successful use of transport {transport_id} in smtp_success table: {err:#}."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let SendResult::Failure(err) = &status
|
||||
&& let Some(msg_id) = msg_id
|
||||
{
|
||||
@@ -858,3 +897,6 @@ pub(crate) async fn add_self_recipients(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod smtp_tests;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::test_utils::TestContextManager;
|
||||
use crate::transport;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_smtp_candidates() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let t = &tcm.unconfigured().await;
|
||||
|
||||
transport::add_pseudo_transport(t, "foo@example.net").await?;
|
||||
transport::add_pseudo_transport(t, "bar@example.net").await?;
|
||||
transport::add_pseudo_transport(t, "baz@example.net").await?;
|
||||
|
||||
let transports = super::sorted_transports(t).await?;
|
||||
let [
|
||||
(transport_id1, ref transport1),
|
||||
(transport_id2, ref transport2),
|
||||
(transport_id3, ref transport3),
|
||||
] = transports[..]
|
||||
else {
|
||||
panic!("Unexpected number of transports");
|
||||
};
|
||||
|
||||
// By default first added transport is used first.
|
||||
assert_eq!(transport1.addr, "foo@example.net");
|
||||
assert_eq!(transport2.addr, "bar@example.net");
|
||||
assert_eq!(transport3.addr, "baz@example.net");
|
||||
|
||||
super::record_success(t, transport_id3).await?;
|
||||
let transports2 = super::sorted_transports(t).await?;
|
||||
assert_eq!(transports2[0].0, transport_id3);
|
||||
assert_eq!(transports2[1].0, transport_id1);
|
||||
assert_eq!(transports2[2].0, transport_id2);
|
||||
|
||||
super::record_success(t, transport_id2).await?;
|
||||
let transports3 = super::sorted_transports(t).await?;
|
||||
assert_eq!(transports3[0].0, transport_id2);
|
||||
assert_eq!(transports3[1].0, transport_id3);
|
||||
assert_eq!(transports3[2].0, transport_id1);
|
||||
|
||||
super::record_success(t, transport_id3).await?;
|
||||
let transports4 = super::sorted_transports(t).await?;
|
||||
assert_eq!(transports4[0].0, transport_id3);
|
||||
assert_eq!(transports4[1].0, transport_id2);
|
||||
assert_eq!(transports4[2].0, transport_id1);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -2672,6 +2672,21 @@ CREATE TABLE smtp2 (
|
||||
.await?;
|
||||
}
|
||||
|
||||
inc_and_check(&mut migration_version, 168)?;
|
||||
if dbversion < migration_version {
|
||||
sql.execute_migration(
|
||||
"
|
||||
CREATE TABLE smtp_success (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
transport_id INTEGER UNIQUE NOT NULL,
|
||||
FOREIGN KEY(transport_id) REFERENCES transports(id) ON DELETE CASCADE
|
||||
) STRICT;
|
||||
",
|
||||
migration_version,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let new_version = sql
|
||||
.get_raw_config_int(VERSION_CFG)
|
||||
.await?
|
||||
|
||||
+98
-35
@@ -10,6 +10,7 @@ use num_traits::FromPrimitive;
|
||||
use crate::calls::{CallState, call_state};
|
||||
use crate::chat::Chat;
|
||||
use crate::constants::Chattype;
|
||||
use crate::constants::DC_DESIRED_TEXT_LEN;
|
||||
use crate::contact::{Contact, ContactId};
|
||||
use crate::context::Context;
|
||||
use crate::message::{Message, MessageState, Viewtype};
|
||||
@@ -56,9 +57,6 @@ pub struct Summary {
|
||||
|
||||
/// Message state.
|
||||
pub state: MessageState,
|
||||
|
||||
/// Message preview image path
|
||||
pub thumbnail_path: Option<String>,
|
||||
}
|
||||
|
||||
impl Summary {
|
||||
@@ -83,7 +81,6 @@ impl Summary {
|
||||
text: msg_reacted(context, reaction_contact_id, &reaction, &summary).await,
|
||||
timestamp: msg.get_timestamp(), // message timestamp (not reaction) to make timestamps more consistent with chats ordering
|
||||
state: msg.state, // message state (not reaction) - indicating if it was me sending the last message
|
||||
thumbnail_path: None,
|
||||
});
|
||||
}
|
||||
Self::new(context, msg, chat, contact).await
|
||||
@@ -121,30 +118,11 @@ impl Summary {
|
||||
None
|
||||
};
|
||||
|
||||
let mut text = msg.get_summary_text(context).await;
|
||||
|
||||
if text.is_empty() && msg.quoted_text().is_some() {
|
||||
text = stock_str::reply_noun(context)
|
||||
}
|
||||
|
||||
let thumbnail_path = if msg.viewtype == Viewtype::Image
|
||||
|| msg.viewtype == Viewtype::Gif
|
||||
|| msg.viewtype == Viewtype::Sticker
|
||||
{
|
||||
msg.get_file(context)
|
||||
.and_then(|path| path.to_str().map(|p| p.to_owned()))
|
||||
} else if msg.viewtype == Viewtype::Webxdc {
|
||||
Some("webxdc-icon://last-msg-id".to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(Summary {
|
||||
prefix,
|
||||
text,
|
||||
text: msg.get_summary_text(context).await,
|
||||
timestamp: msg.get_timestamp(),
|
||||
state: msg.state,
|
||||
thumbnail_path,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -155,19 +133,32 @@ impl Summary {
|
||||
}
|
||||
|
||||
impl Message {
|
||||
/// Returns a summary text.
|
||||
/// Returns a summary text with emoji and "Forwarded:" prefixes.
|
||||
/// This is the standard summary to be used in chatlists, notifications etc.
|
||||
pub(crate) async fn get_summary_text(&self, context: &Context) -> String {
|
||||
let summary = self.get_summary_text_without_prefix(context).await;
|
||||
|
||||
if self.is_forwarded() {
|
||||
format!("{}: {}", stock_str::forwarded(context), summary)
|
||||
} else {
|
||||
summary
|
||||
}
|
||||
let add_forwarded = true;
|
||||
let add_type_emoji = true;
|
||||
self.get_summary_text_ext(context, add_forwarded, add_type_emoji, DC_DESIRED_TEXT_LEN)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Returns a summary text without "Forwarded:" prefix.
|
||||
/// Returns a summary text with emoji prefixes but without "Forwarded:" prefix.
|
||||
/// Used for shorter reaction summaries as "USER reacts 👋 to SUMMARY"
|
||||
async fn get_summary_text_without_prefix(&self, context: &Context) -> String {
|
||||
let add_forwarded = false;
|
||||
let add_type_emoji = true;
|
||||
self.get_summary_text_ext(context, add_forwarded, add_type_emoji, DC_DESIRED_TEXT_LEN)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Returns a summary text with optional "Forwarded:" and emoji prefixes and optionally converting to one line.
|
||||
pub async fn get_summary_text_ext(
|
||||
&self,
|
||||
context: &Context,
|
||||
add_forwarded: bool,
|
||||
add_type_emoji: bool,
|
||||
approx_chars: usize,
|
||||
) -> String {
|
||||
let (emoji, type_name, type_file, append_text);
|
||||
let viewtype = match self
|
||||
.param
|
||||
@@ -281,7 +272,11 @@ impl Message {
|
||||
}
|
||||
};
|
||||
|
||||
let text = self.text.clone();
|
||||
let text = if approx_chars > 0 {
|
||||
truncate(self.text.trim(), approx_chars).to_string()
|
||||
} else {
|
||||
self.text.trim().to_string()
|
||||
};
|
||||
|
||||
let summary = if let Some(type_file) = type_file {
|
||||
if append_text && !text.is_empty() {
|
||||
@@ -303,13 +298,30 @@ impl Message {
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
let emoji = emoji.filter(|_| add_type_emoji);
|
||||
let summary = if let Some(emoji) = emoji {
|
||||
format!("{emoji} {summary}")
|
||||
} else {
|
||||
summary
|
||||
};
|
||||
|
||||
summary.split_whitespace().collect::<Vec<&str>>().join(" ")
|
||||
let summary = if summary.is_empty() && self.quoted_text().is_some() {
|
||||
stock_str::reply_noun(context)
|
||||
} else {
|
||||
summary
|
||||
};
|
||||
|
||||
let summary = if add_forwarded && self.is_forwarded() {
|
||||
format!("{}: {}", stock_str::forwarded(context), summary)
|
||||
} else {
|
||||
summary
|
||||
};
|
||||
|
||||
if approx_chars > 0 {
|
||||
summary.split_whitespace().collect::<Vec<&str>>().join(" ")
|
||||
} else {
|
||||
summary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,6 +343,13 @@ mod tests {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_get_summary_text() {
|
||||
let forwarded = true;
|
||||
let emoji = true;
|
||||
let one_line = 2000;
|
||||
let no_forwarded = false;
|
||||
let no_emoji = false;
|
||||
let multi_line = 0;
|
||||
|
||||
let d = TestContext::new_alice().await;
|
||||
let ctx = &d.ctx;
|
||||
let chat_id = ChatId::create_for_contact(ctx, ContactId::SELF)
|
||||
@@ -347,12 +366,22 @@ mod tests {
|
||||
|
||||
let msg = Message::new_text(some_text.to_string());
|
||||
assert_summary_texts(&msg, ctx, "bla bla").await; // for simple text, the type is not added to the summary
|
||||
assert_eq!(
|
||||
msg.get_summary_text_ext(ctx, forwarded, emoji, multi_line)
|
||||
.await,
|
||||
"bla \t\n\tbla" // lineends are preserved, but text is still trimmed
|
||||
);
|
||||
|
||||
let file = write_file_to_blobdir(&d).await;
|
||||
let mut msg = Message::new(Viewtype::Image);
|
||||
msg.set_file_and_deduplicate(&d, &file, Some("foo.jpg"), None)
|
||||
.unwrap();
|
||||
assert_summary_texts(&msg, ctx, "📷 Image").await; // file names are not added for images
|
||||
assert_eq!(
|
||||
msg.get_summary_text_ext(ctx, no_forwarded, no_emoji, one_line)
|
||||
.await,
|
||||
"Image"
|
||||
);
|
||||
|
||||
let file = write_file_to_blobdir(&d).await;
|
||||
let mut msg = Message::new(Viewtype::Image);
|
||||
@@ -360,6 +389,16 @@ mod tests {
|
||||
msg.set_file_and_deduplicate(&d, &file, Some("foo.jpg"), None)
|
||||
.unwrap();
|
||||
assert_summary_texts(&msg, ctx, "📷 bla bla").await; // type is visible by emoji if text is set
|
||||
assert_eq!(
|
||||
msg.get_summary_text_ext(ctx, no_forwarded, no_emoji, one_line)
|
||||
.await,
|
||||
"bla bla"
|
||||
);
|
||||
assert_eq!(
|
||||
msg.get_summary_text_ext(ctx, forwarded, emoji, multi_line)
|
||||
.await,
|
||||
"📷 bla \t\n\tbla"
|
||||
);
|
||||
|
||||
let file = write_file_to_blobdir(&d).await;
|
||||
let mut msg = Message::new(Viewtype::Video);
|
||||
@@ -490,6 +529,30 @@ mod tests {
|
||||
msg.get_summary_text_without_prefix(ctx).await,
|
||||
"📎 foo.bar \u{2013} bla bla"
|
||||
); // skipping prefix used for reactions summaries
|
||||
assert_eq!(
|
||||
msg.get_summary_text_ext(ctx, no_forwarded, no_emoji, one_line)
|
||||
.await,
|
||||
"foo.bar \u{2013} bla bla"
|
||||
);
|
||||
assert_eq!(
|
||||
msg.get_summary_text_ext(ctx, forwarded, no_emoji, one_line)
|
||||
.await,
|
||||
"Forwarded: foo.bar \u{2013} bla bla"
|
||||
);
|
||||
d.assert_warn("Not a valid DeltaChat vCard").await;
|
||||
|
||||
// If nothing else is present, but the message is a reply, we say so. needed for summary of draft
|
||||
let mut msg = Message::new_text("".to_string());
|
||||
msg.set_quote_text(Some(("blubb".to_string(), true)));
|
||||
assert_summary_texts(&msg, ctx, "Reply").await;
|
||||
assert_eq!(
|
||||
msg.get_summary_text_ext(ctx, no_forwarded, no_emoji, multi_line)
|
||||
.await,
|
||||
"Reply"
|
||||
);
|
||||
|
||||
// If there is nothing, the summary is empty
|
||||
let msg = Message::new_text("".to_string());
|
||||
assert_summary_texts(&msg, ctx, "").await;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -105,7 +105,10 @@ async fn check_aeap_transition(chat_for_transition: ChatForTransition) {
|
||||
check_that_transition_worked(bob, &groups, alice_contact, ALICE_NEW_ADDR).await;
|
||||
|
||||
tcm.section("Test switching back");
|
||||
tcm.change_addr(alice, "alice@example.org").await;
|
||||
alice
|
||||
.set_primary_self_addr("alice@example.org")
|
||||
.await
|
||||
.unwrap();
|
||||
let sent = alice
|
||||
.send_text(chat_to_send, "Hello from my old addr!")
|
||||
.await;
|
||||
|
||||
+2
-2
@@ -740,14 +740,14 @@ pub(crate) fn maybe_update_sending_transport(
|
||||
pub async fn add_pseudo_transport(context: &Context, addr: &str) -> Result<()> {
|
||||
context.sql
|
||||
.execute(
|
||||
"INSERT OR IGNORE INTO transports (addr, entered_param, configured_param) VALUES (?, ?, ?)",
|
||||
"INSERT INTO transports (addr, entered_param, configured_param) VALUES (?, ?, ?)",
|
||||
(
|
||||
addr,
|
||||
serde_json::to_string(&EnteredLoginParam{addr: addr.to_string(), ..Default::default()})?,
|
||||
format!(r#"{{"addr":"{addr}","imap":[],"imap_user":"","imap_password":"","smtp":[],"smtp_user":"","smtp_password":"","certificate_checks":"Automatic","oauth2":false}}"#)
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
.await.with_context(|| format!("Failed to insert pseudo transport for {addr:?}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1664,7 +1664,6 @@ async fn test_webxdc_chatlist_summary() -> Result<()> {
|
||||
assert_eq!(chatlist.len(), 1);
|
||||
let summary = chatlist.get_summary(&t, 0, None).await?;
|
||||
assert_eq!(summary.text, "📱 nice app!".to_string());
|
||||
assert_eq!(summary.thumbnail_path.unwrap(), "webxdc-icon://last-msg-id");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 676 KiB |
Reference in New Issue
Block a user