diff --git a/.github/workflows/node-package.yml b/.github/workflows/node-package.yml index 41c4ff25d..5e5b79108 100644 --- a/.github/workflows/node-package.yml +++ b/.github/workflows/node-package.yml @@ -67,7 +67,9 @@ jobs: # Build Linux prebuilds inside a container with old glibc for backwards compatibility. # Debian 10 contained glibc 2.28 at the time of the writing (2023-06-04): https://packages.debian.org/buster/libc6 - container: debian:10 + # Ubuntu 18.04 is at the End of Standard Support since June 2023, but it contains glibc 2.27, + # so we are using it to support Ubuntu 18.04 setups that are still not upgraded. + container: ubuntu:18.04 steps: # Working directory is owned by 1001:1001 by default. # Change it to our user. diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e54a6826..d4c1e029d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [1.121.0] - 2023-09-06 + +### API-Changes + +- Add `dc_context_change_passphrase()`. +- Add `Message.set_file_from_bytes()` API. +- Add experimental API to get similar chats. + +### Build system + +- Build node packages on Ubuntu 18.04 instead of Debian 10. + This reduces the requirement for glibc version from 2.28 to 2.27. + +### Fixes + +- Allow membership changes by a MUA if we're not in the group ([#4624](https://github.com/deltachat/deltachat-core-rust/pull/4624)). +- Save mime headers for messages not signed with a known key ([#4557](https://github.com/deltachat/deltachat-core-rust/pull/4557)). +- Return from `dc_get_chatlist(DC_GCL_FOR_FORWARDING)` only chats where we can send ([#4616](https://github.com/deltachat/deltachat-core-rust/pull/4616)). +- Do not allow dots at the end of email addresses. +- deltachat-rpc-client: Remove `aiodns` optional dependency from required dependencies. + `aiodns` depends on `pycares` which [fails to install in Termux](https://github.com/saghul/aiodns/issues/98). + ## [1.120.0] - 2023-08-28 ### API-Changes @@ -2764,3 +2786,4 @@ https://github.com/deltachat/deltachat-core-rust/pulls?q=is%3Apr+is%3Aclosed [1.119.0]: https://github.com/deltachat/deltachat-core-rust/compare/v1.118.0...v1.119.0 [1.119.1]: https://github.com/deltachat/deltachat-core-rust/compare/v1.119.0...v1.119.1 [1.120.0]: https://github.com/deltachat/deltachat-core-rust/compare/v1.119.1...v1.120.0 +[1.121.0]: https://github.com/deltachat/deltachat-core-rust/compare/v1.120.0...v1.121.0 diff --git a/Cargo.lock b/Cargo.lock index 07fd501c4..e2008e24f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,9 +17,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -120,9 +120,9 @@ checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" dependencies = [ "backtrace", ] @@ -215,7 +215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b538b767cbf9c162a6c5795d4b932bd2c20ba10b5a91a94d2b2b6886c1dce6a8" dependencies = [ "async-channel", - "base64 0.21.2", + "base64 0.21.3", "bytes", "chrono", "futures", @@ -276,7 +276,7 @@ checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -301,13 +301,13 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.19" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a1de45611fdb535bfde7b7de4fd54f4fd2b17b1737c0a59b69bf9b92074b8c" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", - "base64 0.21.2", + "base64 0.21.3", "bitflags 1.3.2", "bytes", "futures-util", @@ -353,9 +353,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -398,9 +398,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -643,9 +643,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", @@ -653,7 +653,7 @@ dependencies = [ "num-traits", "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.48.1", ] [[package]] @@ -987,7 +987,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1085,7 +1085,7 @@ dependencies = [ [[package]] name = "deltachat" -version = "1.120.0" +version = "1.121.0" dependencies = [ "ansi_term", "anyhow", @@ -1095,7 +1095,7 @@ dependencies = [ "async-smtp", "async_zip", "backtrace", - "base64 0.21.2", + "base64 0.21.3", "brotli", "chrono", "criterion", @@ -1162,12 +1162,12 @@ dependencies = [ [[package]] name = "deltachat-jsonrpc" -version = "1.120.0" +version = "1.121.0" dependencies = [ "anyhow", "async-channel", "axum", - "base64 0.21.2", + "base64 0.21.3", "deltachat", "env_logger", "futures", @@ -1186,7 +1186,7 @@ dependencies = [ [[package]] name = "deltachat-repl" -version = "1.120.0" +version = "1.121.0" dependencies = [ "ansi_term", "anyhow", @@ -1201,7 +1201,7 @@ dependencies = [ [[package]] name = "deltachat-rpc-server" -version = "1.120.0" +version = "1.121.0" dependencies = [ "anyhow", "deltachat", @@ -1221,12 +1221,12 @@ name = "deltachat_derive" version = "2.0.0" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "deltachat_ffi" -version = "1.120.0" +version = "1.121.0" dependencies = [ "anyhow", "deltachat", @@ -1427,7 +1427,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1707,14 +1707,14 @@ checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" [[package]] name = "enum-as-inner" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" +checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" dependencies = [ "heck", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] @@ -1727,7 +1727,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2030,7 +2030,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2110,9 +2110,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "group" @@ -2380,17 +2380,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.4.0" @@ -2403,9 +2392,9 @@ dependencies = [ [[package]] name = "image" -version = "0.24.6" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" +checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" dependencies = [ "bytemuck", "byteorder", @@ -2473,7 +2462,7 @@ dependencies = [ "socket2 0.5.3", "widestring", "windows-sys 0.48.0", - "winreg 0.50.0", + "winreg", ] [[package]] @@ -2490,7 +2479,7 @@ checksum = "e4fb9858c8cd3dd924a5da5bc511363845a9bcfdfac066bb2ef8454eb6111546" dependencies = [ "abao", "anyhow", - "base64 0.21.2", + "base64 0.21.3", "blake3", "bytes", "default-net", @@ -2666,9 +2655,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru-cache" @@ -2705,12 +2694,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - [[package]] name = "matchit" version = "0.7.1" @@ -2734,9 +2717,9 @@ checksum = "df39d232f5c40b0891c10216992c2f250c054105cb1e56f0fc9032db6203ecc1" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memoffset" @@ -2949,7 +2932,7 @@ checksum = "9e6a0fd4f737c707bd9086cc16c925f294943eb62eb71499e9fd4cf71f8b9f4e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -3006,9 +2989,9 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" dependencies = [ "memchr", ] @@ -3063,7 +3046,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -3238,7 +3221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27e1f8e085bfa9b85763fe3ddaacbe90a09cd847b3833129153a6cb063bbe132" dependencies = [ "aes", - "base64 0.21.2", + "base64 0.21.3", "bitfield", "block-padding", "blowfish", @@ -3300,14 +3283,14 @@ checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -3614,9 +3597,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -3786,14 +3769,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.4", - "regex-syntax 0.7.4", + "regex-automata 0.3.8", + "regex-syntax 0.7.5", ] [[package]] @@ -3807,13 +3790,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.4" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", ] [[package]] @@ -3824,17 +3807,17 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bytes", "encoding_rs", "futures-core", @@ -3862,7 +3845,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg 0.10.1", + "winreg", ] [[package]] @@ -4055,7 +4038,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", ] [[package]] @@ -4129,9 +4112,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" dependencies = [ "dyn-clone", "schemars_derive", @@ -4141,9 +4124,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" dependencies = [ "proc-macro2", "quote", @@ -4235,9 +4218,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.180" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -4262,13 +4245,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.180" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4284,9 +4267,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -4567,15 +4550,15 @@ checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.25.1" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6069ca09d878a33f883cc06aaa9718ede171841d3832450354410b718b097232" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4597,9 +4580,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -4667,9 +4650,9 @@ checksum = "094c9f64d6de9a8506b1e49b63a29333b37ed9e821ee04be694d431b3264c3c5" [[package]] name = "tempfile" -version = "3.7.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand 2.0.0", @@ -4714,22 +4697,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4808,11 +4791,10 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", @@ -4821,7 +4803,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.4.9", + "socket2 0.5.3", "tokio-macros", "windows-sys 0.48.0", ] @@ -4844,7 +4826,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4900,9 +4882,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec509ac96e9a0c43427c74f003127d953a265737636129424288d27cb5c4b12c" +checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2" dependencies = [ "futures-util", "log", @@ -5007,7 +4989,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -5061,9 +5043,9 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" +checksum = "0dc775440033cb114085f6f2437682b194fa7546466024b1037e82a48a052a69" dependencies = [ "async-trait", "cfg-if", @@ -5072,9 +5054,9 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna 0.2.3", + "idna", "ipnet", - "lazy_static", + "once_cell", "rand 0.8.5", "smallvec", "thiserror", @@ -5086,16 +5068,17 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" +checksum = "2dff7aed33ef3e8bf2c9966fccdfed93f93d46f432282ea875cd66faabc6ef2f" dependencies = [ "cfg-if", "futures-util", "ipconfig", - "lazy_static", "lru-cache", + "once_cell", "parking_lot", + "rand 0.8.5", "resolv-conf", "smallvec", "thiserror", @@ -5112,9 +5095,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tungstenite" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" +checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649" dependencies = [ "byteorder", "bytes", @@ -5146,9 +5129,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "typescript-type-def" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c4be05eb0171e18da471e545cfff85d80b8118e5aa2d50c2d152265d7435997" +checksum = "356e00027bd9ef773605a353070dc87684b25561a59087ea3ee3dd5fe8854e83" dependencies = [ "serde_json", "typescript-type-def-derive", @@ -5156,9 +5139,9 @@ dependencies = [ [[package]] name = "typescript-type-def-derive" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71aeb2295da6c2bfe665493332b4e4281d113fab3a0786e9651dcc85708095a4" +checksum = "c4e696c28431595138cc53892104528152cbcf26653ae0aa655e4eaede5b9f69" dependencies = [ "darling 0.13.4", "ident_case", @@ -5227,12 +5210,12 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", - "idna 0.4.0", + "idna", "percent-encoding", ] @@ -5340,7 +5323,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -5374,7 +5357,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5397,9 +5380,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" dependencies = [ "ring", "untrusted", @@ -5651,15 +5634,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] - [[package]] name = "winreg" version = "0.50.0" @@ -5777,5 +5751,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] diff --git a/Cargo.toml b/Cargo.toml index d41753ba6..f17ea2ed1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deltachat" -version = "1.120.0" +version = "1.121.0" edition = "2021" license = "MPL-2.0" rust-version = "1.67" @@ -54,7 +54,7 @@ futures = "0.3" futures-lite = "1.13.0" hex = "0.4.0" humansize = "2" -image = { version = "0.24.6", default-features=false, features = ["gif", "jpeg", "ico", "png", "pnm", "webp", "bmp"] } +image = { version = "0.24.7", default-features=false, features = ["gif", "jpeg", "ico", "png", "pnm", "webp", "bmp"] } iroh = { version = "0.4.1", default-features = false } kamadak-exif = "0.5" lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" } @@ -72,8 +72,8 @@ pretty_env_logger = { version = "0.5", optional = true } qrcodegen = "1.7.0" quick-xml = "0.30" rand = "0.8" -regex = "1.8" -reqwest = { version = "0.11.18", features = ["json"] } +regex = "1.9" +reqwest = { version = "0.11.20", features = ["json"] } rusqlite = { version = "0.29", features = ["sqlcipher"] } rust-hsluv = "0.1" sanitize-filename = "0.5" @@ -93,7 +93,7 @@ tokio-stream = { version = "0.1.14", features = ["fs"] } tokio-tar = { version = "0.3" } # TODO: integrate tokio into async-tar tokio-util = "0.7.8" toml = "0.7" -trust-dns-resolver = "0.22" +trust-dns-resolver = "0.23" url = "2" uuid = { version = "1", features = ["serde", "v4"] } diff --git a/deltachat-ffi/Cargo.toml b/deltachat-ffi/Cargo.toml index 546fec81d..5bafbc735 100644 --- a/deltachat-ffi/Cargo.toml +++ b/deltachat-ffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deltachat_ffi" -version = "1.120.0" +version = "1.121.0" description = "Deltachat FFI" edition = "2018" readme = "README.md" diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 38b4b97c4..78798e1e3 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -301,6 +301,19 @@ dc_context_t* dc_context_new_closed (const char* dbfile); int dc_context_open (dc_context_t *context, const char* passphrase); +/** + * Changes the passphrase on the open database. + * Existing database must already be encrypted and the passphrase cannot be NULL or empty. + * It is impossible to encrypt unencrypted database with this method and vice versa. + * + * @memberof dc_context_t + * @param context The context object. + * @param passphrase The new passphrase. + * @return 1 on success, 0 on error. + */ +int dc_context_change_passphrase (dc_context_t* context, const char* passphrase); + + /** * Returns 1 if database is open. * @@ -1328,6 +1341,20 @@ int dc_get_msg_cnt (dc_context_t* context, uint32_t ch int dc_get_fresh_msg_cnt (dc_context_t* context, uint32_t chat_id); +/** + * Returns a list of similar chats. + * + * @warning This is an experimental API which may change or be removed in the future. + * + * @memberof dc_context_t + * @param context The context object as returned from dc_context_new(). + * @param chat_id The ID of the chat for which to find similar chats. + * @return The list of similar chats. + * On errors, NULL is returned. + * Must be freed using dc_chatlist_unref() when no longer used. + */ +dc_chatlist_t* dc_get_similar_chatlist (dc_context_t* context, uint32_t chat_id); + /** * Estimate the number of messages that will be deleted diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 58d238fd8..4144f13b3 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -167,6 +167,24 @@ pub unsafe extern "C" fn dc_context_open( .unwrap_or(0) } +#[no_mangle] +pub unsafe extern "C" fn dc_context_change_passphrase( + context: *mut dc_context_t, + passphrase: *const libc::c_char, +) -> libc::c_int { + if context.is_null() { + eprintln!("ignoring careless call to dc_context_change_passphrase()"); + return 0; + } + + let ctx = &*context; + let passphrase = to_string_lossy(passphrase); + block_on(ctx.change_passphrase(passphrase)) + .context("dc_context_change_passphrase() failed") + .log_err(ctx) + .is_ok() as libc::c_int +} + #[no_mangle] pub unsafe extern "C" fn dc_context_is_open(context: *mut dc_context_t) -> libc::c_int { if context.is_null() { @@ -1234,6 +1252,30 @@ pub unsafe extern "C" fn dc_get_fresh_msg_cnt( }) } +#[no_mangle] +pub unsafe extern "C" fn dc_get_similar_chatlist( + context: *mut dc_context_t, + chat_id: u32, +) -> *mut dc_chatlist_t { + if context.is_null() { + eprintln!("ignoring careless call to dc_get_similar_chatlist()"); + return ptr::null_mut(); + } + let ctx = &*context; + + let chat_id = ChatId::new(chat_id); + match block_on(chat_id.get_similar_chatlist(ctx)) + .context("failed to get similar chatlist") + .log_err(ctx) + { + Ok(list) => { + let ffi_list = ChatlistWrapper { context, list }; + Box::into_raw(Box::new(ffi_list)) + } + Err(_) => ptr::null_mut(), + } +} + #[no_mangle] pub unsafe extern "C" fn dc_estimate_deletion_cnt( context: *mut dc_context_t, diff --git a/deltachat-jsonrpc/Cargo.toml b/deltachat-jsonrpc/Cargo.toml index f5812da18..f1b4d15a7 100644 --- a/deltachat-jsonrpc/Cargo.toml +++ b/deltachat-jsonrpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deltachat-jsonrpc" -version = "1.120.0" +version = "1.121.0" description = "DeltaChat JSON-RPC API" edition = "2021" default-run = "deltachat-jsonrpc-server" @@ -15,26 +15,26 @@ required-features = ["webserver"] anyhow = "1" deltachat = { path = ".." } num-traits = "0.2" -schemars = "0.8.11" +schemars = "0.8.13" serde = { version = "1.0", features = ["derive"] } -tempfile = "3.6.0" +tempfile = "3.8.0" log = "0.4" async-channel = { version = "1.8.0" } futures = { version = "0.3.28" } -serde_json = "1.0.99" +serde_json = "1.0.105" yerpc = { version = "0.5.2", features = ["anyhow_expose", "openrpc"] } -typescript-type-def = { version = "0.5.5", features = ["json_value"] } -tokio = { version = "1.29.1" } +typescript-type-def = { version = "0.5.8", features = ["json_value"] } +tokio = { version = "1.32.0" } sanitize-filename = "0.5" walkdir = "2.3.3" base64 = "0.21" # optional dependencies -axum = { version = "0.6.18", optional = true, features = ["ws"] } +axum = { version = "0.6.20", optional = true, features = ["ws"] } env_logger = { version = "0.10.0", optional = true } [dev-dependencies] -tokio = { version = "1.29.1", features = ["full", "rt-multi-thread"] } +tokio = { version = "1.32.0", features = ["full", "rt-multi-thread"] } [features] diff --git a/deltachat-jsonrpc/src/api/mod.rs b/deltachat-jsonrpc/src/api/mod.rs index 02027af0b..c2c57ea2b 100644 --- a/deltachat-jsonrpc/src/api/mod.rs +++ b/deltachat-jsonrpc/src/api/mod.rs @@ -39,6 +39,7 @@ pub mod types; use num_traits::FromPrimitive; use types::account::Account; use types::chat::FullChat; +use types::chat_list::ChatListEntry; use types::contact::ContactObject; use types::events::Event; use types::http::HttpResponse; @@ -569,6 +570,25 @@ impl CommandApi { Ok(l) } + /// Returns chats similar to the given one. + async fn get_similar_chatlist_entries( + &self, + account_id: u32, + chat_id: u32, + ) -> Result> { + let ctx = self.get_context(account_id).await?; + let chat_id = ChatId::new(chat_id); + let list = chat_id.get_similar_chatlist(&ctx).await?; + let mut l: Vec = Vec::with_capacity(list.len()); + for i in 0..list.len() { + l.push(ChatListEntry( + list.get_chat_id(i)?.to_u32(), + list.get_msg_id(i)?.unwrap_or_default().to_u32(), + )); + } + Ok(l) + } + async fn get_chatlist_items_by_entries( &self, account_id: u32, diff --git a/deltachat-jsonrpc/typescript/package.json b/deltachat-jsonrpc/typescript/package.json index 0c0e4b6bd..3f3fd3d16 100644 --- a/deltachat-jsonrpc/typescript/package.json +++ b/deltachat-jsonrpc/typescript/package.json @@ -55,5 +55,5 @@ }, "type": "module", "types": "dist/deltachat.d.ts", - "version": "1.120.0" + "version": "1.121.0" } diff --git a/deltachat-repl/Cargo.toml b/deltachat-repl/Cargo.toml index 32402d1d0..3d52b6b13 100644 --- a/deltachat-repl/Cargo.toml +++ b/deltachat-repl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deltachat-repl" -version = "1.120.0" +version = "1.121.0" license = "MPL-2.0" edition = "2021" @@ -9,7 +9,7 @@ ansi_term = "0.12.1" anyhow = "1" deltachat = { path = "..", features = ["internals"]} dirs = "5" -log = "0.4.19" +log = "0.4.20" pretty_env_logger = "0.5" rusqlite = "0.29" rustyline = "12" diff --git a/deltachat-repl/src/cmdline.rs b/deltachat-repl/src/cmdline.rs index 7bb4c40bc..080d8d07b 100644 --- a/deltachat-repl/src/cmdline.rs +++ b/deltachat-repl/src/cmdline.rs @@ -814,15 +814,30 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu } "chatinfo" => { ensure!(sel_chat.is_some(), "No chat selected."); + let sel_chat_id = sel_chat.as_ref().unwrap().get_id(); - let contacts = - chat::get_chat_contacts(&context, sel_chat.as_ref().unwrap().get_id()).await?; + let contacts = chat::get_chat_contacts(&context, sel_chat_id).await?; println!("Memberlist:"); log_contactlist(&context, &contacts).await?; + println!("{} contacts", contacts.len()); + + let similar_chats = sel_chat_id.get_similar_chat_ids(&context).await?; + if !similar_chats.is_empty() { + println!("Similar chats: "); + for (similar_chat_id, metric) in similar_chats { + let similar_chat = Chat::load_from_db(&context, similar_chat_id).await?; + println!( + "{} (#{}) {:.1}", + similar_chat.name, + similar_chat_id, + 100.0 * metric + ); + } + } + println!( - "{} contacts\nLocation streaming: {}", - contacts.len(), + "Location streaming: {}", location::is_sending_locations_to_chat( &context, Some(sel_chat.as_ref().unwrap().get_id()) diff --git a/deltachat-rpc-client/pyproject.toml b/deltachat-rpc-client/pyproject.toml index 8bde236a5..629ebb1ef 100644 --- a/deltachat-rpc-client/pyproject.toml +++ b/deltachat-rpc-client/pyproject.toml @@ -6,8 +6,7 @@ build-backend = "setuptools.build_meta" name = "deltachat-rpc-client" description = "Python client for Delta Chat core JSON-RPC interface" dependencies = [ - "aiohttp", - "aiodns" + "aiohttp" ] classifiers = [ "Development Status :: 5 - Production/Stable", diff --git a/deltachat-rpc-server/Cargo.toml b/deltachat-rpc-server/Cargo.toml index cf509dd2c..796e63b17 100644 --- a/deltachat-rpc-server/Cargo.toml +++ b/deltachat-rpc-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deltachat-rpc-server" -version = "1.120.0" +version = "1.121.0" description = "DeltaChat JSON-RPC server" edition = "2021" readme = "README.md" @@ -17,9 +17,9 @@ anyhow = "1" env_logger = { version = "0.10.0" } futures-lite = "1.13.0" log = "0.4" -serde_json = "1.0.99" +serde_json = "1.0.105" serde = { version = "1.0", features = ["derive"] } -tokio = { version = "1.29.1", features = ["io-std"] } +tokio = { version = "1.32.0", features = ["io-std"] } tokio-util = "0.7.8" yerpc = { version = "0.5.2", features = ["anyhow_expose", "openrpc"] } diff --git a/deny.toml b/deny.toml index 643aae78e..22d06bab4 100644 --- a/deny.toml +++ b/deny.toml @@ -3,11 +3,6 @@ unmaintained = "allow" ignore = [ "RUSTSEC-2020-0071", "RUSTSEC-2022-0093", - - # Exponential CPU time usage for TLS certificate processing in webpki. - # It is only used for backup transfer, so does not affect IMAP and SMTP connections. - # Waiting for `iroh` to update dependencies. - "RUSTSEC-2023-0052", ] [bans] @@ -32,7 +27,6 @@ skip = [ { name = "fastrand", version = "1.9.0" }, { name = "getrandom", version = "<0.2" }, { name = "hashbrown", version = "<0.14.0" }, - { name = "idna", version = "<0.3" }, { name = "indexmap", version = "<2.0.0" }, { name = "pem-rfc7468", version = "0.6.0" }, { name = "pkcs8", version = "0.9.0" }, @@ -62,7 +56,6 @@ skip = [ { name = "windows_x86_64_gnullvm", version = "<0.48" }, { name = "windows_x86_64_gnu", version = "<0.48" }, { name = "windows_x86_64_msvc", version = "<0.48" }, - { name = "winreg", version = "0.10.1" }, ] diff --git a/package.json b/package.json index 46f77993d..779fe9c0e 100644 --- a/package.json +++ b/package.json @@ -60,5 +60,5 @@ "test:mocha": "mocha -r esm node/test/test.js --growl --reporter=spec --bail --exit" }, "types": "node/dist/index.d.ts", - "version": "1.120.0" + "version": "1.121.0" } diff --git a/release-date.in b/release-date.in index 13b929383..1cef16d38 100644 --- a/release-date.in +++ b/release-date.in @@ -1 +1 @@ -2023-08-28 \ No newline at end of file +2023-09-06 \ No newline at end of file diff --git a/scripts/create-provider-data-rs.py b/scripts/create-provider-data-rs.py index 824e3354d..589cd0b90 100755 --- a/scripts/create-provider-data-rs.py +++ b/scripts/create-provider-data-rs.py @@ -44,7 +44,7 @@ def file2url(f): def process_opt(data): if not "opt" in data: - return "Default::default()" + return "ProviderOptions::new()" opt = "ProviderOptions {\n" opt_data = data.get("opt", "") for key in opt_data: @@ -54,7 +54,7 @@ def process_opt(data): if value in {"True", "False"}: value = value.lower() opt += " " + key + ": " + value + ",\n" - opt += " ..Default::default()\n" + opt += " ..ProviderOptions::new()\n" opt += " }" return opt @@ -62,7 +62,7 @@ def process_opt(data): def process_config_defaults(data): if not "config_defaults" in data: return "None" - defaults = "Some(vec![\n" + defaults = "Some(&[\n" config_defaults = data.get("config_defaults", "") for key in config_defaults: value = str(config_defaults[key]) @@ -96,11 +96,11 @@ def process_data(data, file): raise TypeError("domain used twice: " + domain) domains_set.add(domain) - domains += ' ("' + domain + '", &*' + file2varname(file) + "),\n" + domains += ' ("' + domain + '", &' + file2varname(file) + "),\n" comment += domain + ", " ids = "" - ids += ' ("' + file2id(file) + '", &*' + file2varname(file) + "),\n" + ids += ' ("' + file2id(file) + '", &' + file2varname(file) + "),\n" server = "" has_imap = False @@ -155,18 +155,18 @@ def process_data(data, file): provider += ( "static " + file2varname(file) - + ": Lazy = Lazy::new(|| Provider {\n" + + ": Provider = Provider {\n" ) provider += ' id: "' + file2id(file) + '",\n' provider += " status: Status::" + status.capitalize() + ",\n" provider += ' before_login_hint: "' + before_login_hint + '",\n' provider += ' after_login_hint: "' + after_login_hint + '",\n' provider += ' overview_page: "' + file2url(file) + '",\n' - provider += " server: vec![\n" + server + " ],\n" + provider += " server: &[\n" + server + " ],\n" provider += " opt: " + opt + ",\n" provider += " config_defaults: " + config_defaults + ",\n" provider += " oauth2_authorizer: " + oauth2 + ",\n" - provider += "});\n\n" + provider += "};\n\n" else: raise TypeError("SMTP and IMAP must be specified together or left out both") diff --git a/src/chat.rs b/src/chat.rs index 55600effc..488630d3e 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize}; use crate::aheader::EncryptPreference; use crate::blob::BlobObject; +use crate::chatlist::Chatlist; use crate::color::str_to_color; use crate::config::Config; use crate::constants::{ @@ -905,6 +906,133 @@ impl ChatId { Ok(count) } + /// Returns timestamp of the latest message in the chat. + pub(crate) async fn get_timestamp(self, context: &Context) -> Result> { + let timestamp = context + .sql + .query_get_value("SELECT MAX(timestamp) FROM msgs WHERE chat_id=?", (self,)) + .await?; + Ok(timestamp) + } + + /// Returns a list of active similar chat IDs sorted by similarity metric. + /// + /// Jaccard similarity coefficient is used to estimate similarity of chat member sets. + /// + /// Chat is considered active if something was posted there within the last 42 days. + pub async fn get_similar_chat_ids(self, context: &Context) -> Result> { + // Count number of common members in this and other chats. + let intersection: Vec<(ChatId, f64)> = context + .sql + .query_map( + "SELECT y.chat_id, SUM(x.contact_id = y.contact_id) + FROM chats_contacts as x + JOIN chats_contacts as y + WHERE x.contact_id > 9 + AND y.contact_id > 9 + AND x.chat_id=? + AND y.chat_id<>x.chat_id + GROUP BY y.chat_id", + (self,), + |row| { + let chat_id: ChatId = row.get(0)?; + let intersection: f64 = row.get(1)?; + Ok((chat_id, intersection)) + }, + |rows| { + rows.collect::, _>>() + .map_err(Into::into) + }, + ) + .await + .context("failed to calculate member set intersections")?; + + let chat_size: HashMap = context + .sql + .query_map( + "SELECT chat_id, count(*) AS n + FROM chats_contacts where contact_id > 9 + GROUP BY chat_id", + (), + |row| { + let chat_id: ChatId = row.get(0)?; + let size: f64 = row.get(1)?; + Ok((chat_id, size)) + }, + |rows| { + rows.collect::, _>>() + .map_err(Into::into) + }, + ) + .await + .context("failed to count chat member sizes")?; + + let our_chat_size = chat_size.get(&self).copied().unwrap_or_default(); + let mut chats_with_metrics = Vec::new(); + for (chat_id, intersection_size) in intersection { + if intersection_size > 0.0 { + let other_chat_size = chat_size.get(&chat_id).copied().unwrap_or_default(); + let union_size = our_chat_size + other_chat_size - intersection_size; + let metric = intersection_size / union_size; + chats_with_metrics.push((chat_id, metric)) + } + } + chats_with_metrics.sort_unstable_by(|(chat_id1, metric1), (chat_id2, metric2)| { + metric2 + .partial_cmp(metric1) + .unwrap_or(chat_id2.cmp(chat_id1)) + }); + + // Select up to five similar active chats. + let mut res = Vec::new(); + let now = time(); + for (chat_id, metric) in chats_with_metrics { + if let Some(chat_timestamp) = chat_id.get_timestamp(context).await? { + if now > chat_timestamp + 42 * 24 * 3600 { + // Chat was inactive for 42 days, skip. + continue; + } + } + + if metric < 0.1 { + // Chat is unrelated. + break; + } + + let chat = Chat::load_from_db(context, chat_id).await?; + if chat.typ != Chattype::Group { + continue; + } + + match chat.visibility { + ChatVisibility::Normal | ChatVisibility::Pinned => {} + ChatVisibility::Archived => continue, + } + + res.push((chat_id, metric)); + if res.len() >= 5 { + break; + } + } + + Ok(res) + } + + /// Returns similar chats as a [`Chatlist`]. + /// + /// [`Chatlist`]: crate::chatlist::Chatlist + pub async fn get_similar_chatlist(self, context: &Context) -> Result { + let chat_ids: Vec = self + .get_similar_chat_ids(context) + .await + .context("failed to get similar chat IDs")? + .into_iter() + .map(|(chat_id, _metric)| chat_id) + .collect(); + let chatlist = Chatlist::from_chat_ids(context, &chat_ids).await?; + Ok(chatlist) + } + pub(crate) async fn get_param(self, context: &Context) -> Result { let res: Option = context .sql @@ -1346,11 +1474,11 @@ impl Chat { pub async fn get_profile_image(&self, context: &Context) -> Result> { if let Some(image_rel) = self.param.get(Param::ProfileImage) { if !image_rel.is_empty() { - return Ok(Some(get_abs_path(context, image_rel))); + return Ok(Some(get_abs_path(context, Path::new(&image_rel)))); } } else if self.id.is_archived_link() { if let Ok(image_rel) = get_archive_icon(context).await { - return Ok(Some(get_abs_path(context, image_rel))); + return Ok(Some(get_abs_path(context, Path::new(&image_rel)))); } } else if self.typ == Chattype::Single { let contacts = get_chat_contacts(context, self.id).await?; @@ -1361,7 +1489,7 @@ impl Chat { } } else if self.typ == Chattype::Broadcast { if let Ok(image_rel) = get_broadcast_icon(context).await { - return Ok(Some(get_abs_path(context, image_rel))); + return Ok(Some(get_abs_path(context, Path::new(&image_rel)))); } } Ok(None) @@ -1632,6 +1760,11 @@ impl Chat { None }; + msg.chat_id = self.id; + msg.from_id = ContactId::SELF; + msg.rfc724_mid = new_rfc724_mid; + msg.timestamp_sort = timestamp; + // add message to the database if let Some(update_msg_id) = update_msg_id { context @@ -1645,11 +1778,11 @@ impl Chat { ephemeral_timestamp=? WHERE id=?;", params_slice![ - new_rfc724_mid, - self.id, - ContactId::SELF, + msg.rfc724_mid, + msg.chat_id, + msg.from_id, to_id, - timestamp, + msg.timestamp_sort, msg.viewtype, msg.state, msg.text, @@ -1694,11 +1827,11 @@ impl Chat { ephemeral_timestamp) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,1,?,?,?);", params_slice![ - new_rfc724_mid, - self.id, - ContactId::SELF, + msg.rfc724_mid, + msg.chat_id, + msg.from_id, to_id, - timestamp, + msg.timestamp_sort, msg.viewtype, msg.state, msg.text, @@ -2155,6 +2288,8 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> { } } + msg.try_calc_and_set_dimensions(context).await?; + info!( context, "Attaching \"{}\" for message type #{}.", @@ -2328,7 +2463,7 @@ async fn prepare_send_msg( ); message::update_msg_state(context, msg.id, MessageState::OutPending).await?; } - let row_id = create_send_msg_job(context, msg.id).await?; + let row_id = create_send_msg_job(context, msg).await?; Ok(row_id) } @@ -2338,13 +2473,10 @@ async fn prepare_send_msg( /// group with only self and no BCC-to-self configured. /// /// The caller has to interrupt SMTP loop or otherwise process a new row. -async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result> { - let mut msg = Message::load_from_db(context, msg_id).await?; - msg.try_calc_and_set_dimensions(context) - .await - .context("failed to calculate media dimensions")?; - - /* create message */ +pub(crate) async fn create_send_msg_job( + context: &Context, + msg: &mut Message, +) -> Result> { let needs_encryption = msg.param.get_bool(Param::GuaranteeE2ee).unwrap_or_default(); let attach_selfavatar = match shall_attach_selfavatar(context, msg.chat_id).await { @@ -2355,7 +2487,7 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result Result Ok(res), Err(err) => { - message::set_msg_failed(context, msg_id, &err.to_string()).await; + message::set_msg_failed(context, msg, &err.to_string()).await?; Err(err) } }?; @@ -2395,13 +2528,13 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result Result Result<()> { - if let Some(chat_timestamp) = context - .sql - .query_get_value( - "SELECT MAX(timestamp) FROM msgs WHERE chat_id=?", - (chat_id,), - ) - .await? - { + if let Some(chat_timestamp) = chat_id.get_timestamp(context).await? { if timestamp > chat_timestamp { marknoticed_chat(context, chat_id).await?; } @@ -3474,89 +3600,86 @@ pub async fn forward_msgs(context: &Context, msg_ids: &[MsgId], chat_id: ChatId) chat_id .unarchive_if_not_muted(context, MessageState::Undefined) .await?; - if let Ok(mut chat) = Chat::load_from_db(context, chat_id).await { - if let Some(reason) = chat.why_cant_send(context).await? { - bail!("cannot send to {}: {}", chat_id, reason); + let mut chat = Chat::load_from_db(context, chat_id).await?; + if let Some(reason) = chat.why_cant_send(context).await? { + bail!("cannot send to {}: {}", chat_id, reason); + } + curr_timestamp = create_smeared_timestamps(context, msg_ids.len()); + let ids = context + .sql + .query_map( + &format!( + "SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id", + sql::repeat_vars(msg_ids.len()) + ), + rusqlite::params_from_iter(msg_ids), + |row| row.get::<_, MsgId>(0), + |ids| ids.collect::, _>>().map_err(Into::into), + ) + .await?; + + for id in ids { + let src_msg_id: MsgId = id; + let mut msg = Message::load_from_db(context, src_msg_id).await?; + if msg.state == MessageState::OutDraft { + bail!("cannot forward drafts."); } - curr_timestamp = create_smeared_timestamps(context, msg_ids.len()); - let ids = context - .sql - .query_map( - &format!( - "SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id", - sql::repeat_vars(msg_ids.len()) - ), - rusqlite::params_from_iter(msg_ids), - |row| row.get::<_, MsgId>(0), - |ids| ids.collect::, _>>().map_err(Into::into), - ) - .await?; - for id in ids { - let src_msg_id: MsgId = id; - let mut msg = Message::load_from_db(context, src_msg_id).await?; - if msg.state == MessageState::OutDraft { - bail!("cannot forward drafts."); - } + let original_param = msg.param.clone(); - let original_param = msg.param.clone(); + // we tested a sort of broadcast + // by not marking own forwarded messages as such, + // however, this turned out to be to confusing and unclear. - // we tested a sort of broadcast - // by not marking own forwarded messages as such, - // however, this turned out to be to confusing and unclear. + if msg.get_viewtype() != Viewtype::Sticker { + msg.param + .set_int(Param::Forwarded, src_msg_id.to_u32() as i32); + } - if msg.get_viewtype() != Viewtype::Sticker { - msg.param - .set_int(Param::Forwarded, src_msg_id.to_u32() as i32); - } + msg.param.remove(Param::GuaranteeE2ee); + msg.param.remove(Param::ForcePlaintext); + msg.param.remove(Param::Cmd); + msg.param.remove(Param::OverrideSenderDisplayname); + msg.param.remove(Param::WebxdcSummary); + msg.param.remove(Param::WebxdcSummaryTimestamp); + msg.in_reply_to = None; - msg.param.remove(Param::GuaranteeE2ee); - msg.param.remove(Param::ForcePlaintext); - msg.param.remove(Param::Cmd); - msg.param.remove(Param::OverrideSenderDisplayname); - msg.param.remove(Param::WebxdcSummary); - msg.param.remove(Param::WebxdcSummaryTimestamp); - msg.in_reply_to = None; + // do not leak data as group names; a default subject is generated by mimefactory + msg.subject = "".to_string(); - // do not leak data as group names; a default subject is generated by mimefactory - msg.subject = "".to_string(); + let new_msg_id: MsgId; + if msg.state == MessageState::OutPreparing { + new_msg_id = chat + .prepare_msg_raw(context, &mut msg, None, curr_timestamp) + .await?; + curr_timestamp += 1; + msg.param = original_param; + msg.id = src_msg_id; - let new_msg_id: MsgId; - if msg.state == MessageState::OutPreparing { - new_msg_id = chat - .prepare_msg_raw(context, &mut msg, None, curr_timestamp) - .await?; - curr_timestamp += 1; - let save_param = msg.param.clone(); - msg.param = original_param; - msg.id = src_msg_id; - - if let Some(old_fwd) = msg.param.get(Param::PrepForwards) { - let new_fwd = format!("{} {}", old_fwd, new_msg_id.to_u32()); - msg.param.set(Param::PrepForwards, new_fwd); - } else { - msg.param - .set(Param::PrepForwards, new_msg_id.to_u32().to_string()); - } - - msg.update_param(context).await?; - msg.param = save_param; + if let Some(old_fwd) = msg.param.get(Param::PrepForwards) { + let new_fwd = format!("{} {}", old_fwd, new_msg_id.to_u32()); + msg.param.set(Param::PrepForwards, new_fwd); } else { - msg.state = MessageState::OutPending; - new_msg_id = chat - .prepare_msg_raw(context, &mut msg, None, curr_timestamp) - .await?; - curr_timestamp += 1; - if create_send_msg_job(context, new_msg_id).await?.is_some() { - context - .scheduler - .interrupt_smtp(InterruptInfo::new(false)) - .await; - } + msg.param + .set(Param::PrepForwards, new_msg_id.to_u32().to_string()); + } + + msg.update_param(context).await?; + } else { + msg.state = MessageState::OutPending; + new_msg_id = chat + .prepare_msg_raw(context, &mut msg, None, curr_timestamp) + .await?; + curr_timestamp += 1; + if create_send_msg_job(context, &mut msg).await?.is_some() { + context + .scheduler + .interrupt_smtp(InterruptInfo::new(false)) + .await; } - created_chats.push(chat_id); - created_msgs.push(new_msg_id); } + created_chats.push(chat_id); + created_msgs.push(new_msg_id); } for (chat_id, msg_id) in created_chats.iter().zip(created_msgs.iter()) { context.emit_msgs_changed(*chat_id, *msg_id); @@ -3588,29 +3711,31 @@ pub async fn resend_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> { msgs.push(msg) } - if let Some(chat_id) = chat_id { - let chat = Chat::load_from_db(context, chat_id).await?; - for mut msg in msgs { - if msg.get_showpadlock() && !chat.is_protected() { - msg.param.remove(Param::GuaranteeE2ee); - msg.update_param(context).await?; - } - match msg.get_state() { - MessageState::OutFailed | MessageState::OutDelivered | MessageState::OutMdnRcvd => { - message::update_msg_state(context, msg.id, MessageState::OutPending).await? - } - _ => bail!("unexpected message state"), - } - context.emit_event(EventType::MsgsChanged { - chat_id: msg.chat_id, - msg_id: msg.id, - }); - if create_send_msg_job(context, msg.id).await?.is_some() { - context - .scheduler - .interrupt_smtp(InterruptInfo::new(false)) - .await; + let Some(chat_id) = chat_id else { + return Ok(()); + }; + + let chat = Chat::load_from_db(context, chat_id).await?; + for mut msg in msgs { + if msg.get_showpadlock() && !chat.is_protected() { + msg.param.remove(Param::GuaranteeE2ee); + msg.update_param(context).await?; + } + match msg.get_state() { + MessageState::OutFailed | MessageState::OutDelivered | MessageState::OutMdnRcvd => { + message::update_msg_state(context, msg.id, MessageState::OutPending).await? } + _ => bail!("unexpected message state"), + } + context.emit_event(EventType::MsgsChanged { + chat_id: msg.chat_id, + msg_id: msg.id, + }); + if create_send_msg_job(context, &mut msg).await?.is_some() { + context + .scheduler + .interrupt_smtp(InterruptInfo::new(false)) + .await; } } Ok(()) @@ -3680,7 +3805,6 @@ pub async fn add_device_msg_with_importance( chat_id = ChatId::get_for_contact(context, ContactId::DEVICE).await?; let rfc724_mid = create_outgoing_rfc724_mid(None, "@device"); - msg.try_calc_and_set_dimensions(context).await.ok(); prepare_msg_blob(context, msg).await?; let timestamp_sent = create_smeared_timestamp(context); diff --git a/src/chatlist.rs b/src/chatlist.rs index beafa1206..d809b42d6 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -296,6 +296,27 @@ impl Chatlist { Ok(Chatlist { ids }) } + /// Converts list of chat IDs to a chatlist. + pub(crate) async fn from_chat_ids(context: &Context, chat_ids: &[ChatId]) -> Result { + let mut ids = Vec::new(); + for &chat_id in chat_ids { + let msg_id: Option = context + .sql + .query_get_value( + "SELECT id + FROM msgs + WHERE chat_id=?1 + AND (hidden=0 OR state=?2) + ORDER BY timestamp DESC, id DESC LIMIT 1", + (chat_id, MessageState::OutDraft), + ) + .await + .with_context(|| format!("failed to get msg ID for chat {}", chat_id))?; + ids.push((chat_id, msg_id)); + } + Ok(Chatlist { ids }) + } + /// Find out the number of chats. pub fn len(&self) -> usize { self.ids.len() diff --git a/src/config.rs b/src/config.rs index 68b8de70c..0a36f4946 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,7 @@ //! # Key-value configuration management. use std::env; +use std::path::Path; use std::str::FromStr; use anyhow::{ensure, Context as _, Result}; @@ -343,7 +344,11 @@ impl Context { let value = match key { Config::Selfavatar => { let rel_path = self.sql.get_raw_config(key.as_ref()).await?; - rel_path.map(|p| get_abs_path(self, p).to_string_lossy().into_owned()) + rel_path.map(|p| { + get_abs_path(self, Path::new(&p)) + .to_string_lossy() + .into_owned() + }) } Config::SysVersion => Some((*DC_VERSION_STR).clone()), Config::SysMsgsizeMaxRecommended => Some(format!("{RECOMMENDED_FILE_SIZE}")), diff --git a/src/configure.rs b/src/configure.rs index bb63c83d9..378268800 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -130,7 +130,7 @@ async fn on_configure_completed( old_addr: Option, ) -> Result<()> { if let Some(provider) = param.provider { - if let Some(config_defaults) = &provider.config_defaults { + if let Some(config_defaults) = provider.config_defaults { for def in config_defaults { if !context.config_exists(def.key).await? { info!(context, "apply config_defaults {}={}", def.key, def.value); diff --git a/src/contact.rs b/src/contact.rs index 2998ae1ad..e771e15de 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -5,7 +5,7 @@ use std::collections::BinaryHeap; use std::convert::{TryFrom, TryInto}; use std::fmt; use std::ops::Deref; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::time::{SystemTime, UNIX_EPOCH}; use anyhow::{bail, ensure, Context as _, Result}; @@ -1186,7 +1186,7 @@ impl Contact { } } else if let Some(image_rel) = self.param.get(Param::ProfileImage) { if !image_rel.is_empty() { - return Ok(Some(get_abs_path(context, image_rel))); + return Ok(Some(get_abs_path(context, Path::new(image_rel)))); } } Ok(None) @@ -1716,7 +1716,7 @@ mod tests { assert_eq!(may_be_valid_addr("dd.tt"), false); assert_eq!(may_be_valid_addr("tt.dd@uu"), true); assert_eq!(may_be_valid_addr("u@d"), true); - assert_eq!(may_be_valid_addr("u@d."), true); + assert_eq!(may_be_valid_addr("u@d."), false); assert_eq!(may_be_valid_addr("u@d.t"), true); assert_eq!(may_be_valid_addr("u@d.tt"), true); assert_eq!(may_be_valid_addr("u@.tt"), true); @@ -1725,6 +1725,7 @@ mod tests { assert_eq!(may_be_valid_addr("sk <@d.tt>"), false); assert_eq!(may_be_valid_addr("as@sd.de>"), false); assert_eq!(may_be_valid_addr("ask dkl@dd.tt"), false); + assert_eq!(may_be_valid_addr("user@domain.tld."), false); } #[test] diff --git a/src/context.rs b/src/context.rs index 892d64caa..3b757222d 100644 --- a/src/context.rs +++ b/src/context.rs @@ -332,6 +332,12 @@ impl Context { } } + /// Changes encrypted database passphrase. + pub async fn change_passphrase(&self, passphrase: String) -> Result<()> { + self.sql.change_passphrase(passphrase).await?; + Ok(()) + } + /// Returns true if database is open. pub async fn is_open(&self) -> bool { self.sql.is_open().await diff --git a/src/imex.rs b/src/imex.rs index 5ae842b32..7ab6821f6 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -772,6 +772,11 @@ async fn export_database(context: &Context, dest: &Path, passphrase: String) -> let res = conn .query_row("SELECT sqlcipher_export('backup')", [], |_row| Ok(())) .context("failed to export to attached backup database"); + conn.execute( + "UPDATE backup.config SET value='0' WHERE keyname='verified_one_on_one_chats';", + [], + ) + .ok(); // If verified_one_on_one_chats was not set, this errors, which we ignore conn.execute("DETACH DATABASE backup", []) .context("failed to detach backup database")?; res?; @@ -881,55 +886,73 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_export_and_import_backup() -> Result<()> { - let backup_dir = tempfile::tempdir().unwrap(); + for set_verified_oneonone_chats in [true, false] { + let backup_dir = tempfile::tempdir().unwrap(); - let context1 = TestContext::new_alice().await; - assert!(context1.is_configured().await?); + let context1 = TestContext::new_alice().await; + assert!(context1.is_configured().await?); + if set_verified_oneonone_chats { + context1 + .set_config_bool(Config::VerifiedOneOnOneChats, true) + .await?; + } - let context2 = TestContext::new().await; - assert!(!context2.is_configured().await?); - assert!(has_backup(&context2, backup_dir.path()).await.is_err()); + let context2 = TestContext::new().await; + assert!(!context2.is_configured().await?); + assert!(has_backup(&context2, backup_dir.path()).await.is_err()); - // export from context1 - assert!( - imex(&context1, ImexMode::ExportBackup, backup_dir.path(), None) - .await - .is_ok() - ); - let _event = context1 - .evtracker - .get_matching(|evt| matches!(evt, EventType::ImexProgress(1000))) - .await; + // export from context1 + assert!( + imex(&context1, ImexMode::ExportBackup, backup_dir.path(), None) + .await + .is_ok() + ); + let _event = context1 + .evtracker + .get_matching(|evt| matches!(evt, EventType::ImexProgress(1000))) + .await; - // import to context2 - let backup = has_backup(&context2, backup_dir.path()).await?; + // import to context2 + let backup = has_backup(&context2, backup_dir.path()).await?; - // Import of unencrypted backup with incorrect "foobar" backup passphrase fails. - assert!(imex( - &context2, - ImexMode::ImportBackup, - backup.as_ref(), - Some("foobar".to_string()) - ) - .await - .is_err()); + // Import of unencrypted backup with incorrect "foobar" backup passphrase fails. + assert!(imex( + &context2, + ImexMode::ImportBackup, + backup.as_ref(), + Some("foobar".to_string()) + ) + .await + .is_err()); - assert!( - imex(&context2, ImexMode::ImportBackup, backup.as_ref(), None) - .await - .is_ok() - ); - let _event = context2 - .evtracker - .get_matching(|evt| matches!(evt, EventType::ImexProgress(1000))) - .await; - - assert!(context2.is_configured().await?); - assert_eq!( - context2.get_config(Config::Addr).await?, - Some("alice@example.org".to_string()) - ); + assert!( + imex(&context2, ImexMode::ImportBackup, backup.as_ref(), None) + .await + .is_ok() + ); + let _event = context2 + .evtracker + .get_matching(|evt| matches!(evt, EventType::ImexProgress(1000))) + .await; + assert!(context2.is_configured().await?); + assert_eq!( + context2.get_config(Config::Addr).await?, + Some("alice@example.org".to_string()) + ); + assert_eq!( + context2 + .get_config_bool(Config::VerifiedOneOnOneChats) + .await?, + false + ); + assert_eq!( + context1 + .get_config_bool(Config::VerifiedOneOnOneChats) + .await?, + set_verified_oneonone_chats + ); + } Ok(()) } diff --git a/src/message.rs b/src/message.rs index 0a5a656a4..e9e14ecc5 100644 --- a/src/message.rs +++ b/src/message.rs @@ -7,6 +7,7 @@ use anyhow::{ensure, format_err, Context as _, Result}; use deltachat_derive::{FromSql, ToSql}; use serde::{Deserialize, Serialize}; +use crate::blob::BlobObject; use crate::chat::{Chat, ChatId}; use crate::config::Config; use crate::constants::{ @@ -574,14 +575,22 @@ impl Message { if (self.viewtype == Viewtype::Image || self.viewtype == Viewtype::Gif) && !self.param.exists(Param::Width) { - self.param.set_int(Param::Width, 0); - self.param.set_int(Param::Height, 0); + let buf = read_file(context, &path_and_filename).await?; - if let Ok(buf) = read_file(context, path_and_filename).await { - if let Ok((width, height)) = get_filemeta(&buf) { + match get_filemeta(&buf) { + Ok((width, height)) => { self.param.set_int(Param::Width, width as i32); self.param.set_int(Param::Height, height as i32); } + Err(err) => { + self.param.set_int(Param::Width, 0); + self.param.set_int(Param::Height, 0); + warn!( + context, + "Failed to get width and height for {}: {err:#}.", + path_and_filename.display() + ); + } } if !self.id.is_unset() { @@ -972,19 +981,28 @@ impl Message { } } self.param.set(Param::File, file); - if let Some(filemime) = filemime { - self.param.set(Param::MimeType, filemime); - } + self.param.set_optional(Param::MimeType, filemime); + } + + /// Creates a new blob and sets it as a file associated with a message. + pub async fn set_file_from_bytes( + &mut self, + context: &Context, + suggested_name: &str, + data: &[u8], + filemime: Option<&str>, + ) -> Result<()> { + let blob = BlobObject::create(context, suggested_name, data).await?; + self.param.set(Param::File, blob.as_name()); + self.param.set_optional(Param::MimeType, filemime); + Ok(()) } /// Set different sender name for a message. /// This overrides the name set by the `set_config()`-option `displayname`. pub fn set_override_sender_name(&mut self, name: Option) { - if let Some(name) = name { - self.param.set(Param::OverrideSenderDisplayname, name); - } else { - self.param.remove(Param::OverrideSenderDisplayname); - } + self.param + .set_optional(Param::OverrideSenderDisplayname, name); } /// Sets the dimensions of associated image or video file. @@ -1641,35 +1659,36 @@ pub(crate) async fn update_msg_state( // Context functions to work with messages -pub(crate) async fn set_msg_failed(context: &Context, msg_id: MsgId, error: &str) { - if let Ok(mut msg) = Message::load_from_db(context, msg_id).await { - if msg.state.can_fail() { - msg.state = MessageState::OutFailed; - warn!(context, "{} failed: {}", msg_id, error); - } else { - warn!( - context, - "{} seems to have failed ({}), but state is {}", msg_id, error, msg.state - ) - } - - match context - .sql - .execute( - "UPDATE msgs SET state=?, error=? WHERE id=?;", - (msg.state, error, msg_id), - ) - .await - { - Ok(_) => context.emit_event(EventType::MsgFailed { - chat_id: msg.chat_id, - msg_id, - }), - Err(e) => { - warn!(context, "{:?}", e); - } - } +pub(crate) async fn set_msg_failed( + context: &Context, + msg: &mut Message, + error: &str, +) -> Result<()> { + if msg.state.can_fail() { + msg.state = MessageState::OutFailed; + warn!(context, "{} failed: {}", msg.id, error); + } else { + warn!( + context, + "{} seems to have failed ({}), but state is {}", msg.id, error, msg.state + ) } + msg.error = Some(error.to_string()); + + context + .sql + .execute( + "UPDATE msgs SET state=?, error=? WHERE id=?;", + (msg.state, error, msg.id), + ) + .await?; + + context.emit_event(EventType::MsgFailed { + chat_id: msg.chat_id, + msg_id: msg.id, + }); + + Ok(()) } /// The number of messages assigned to unblocked chats @@ -2276,7 +2295,7 @@ mod tests { update_msg_state(&alice, alice_msg.id, MessageState::OutMdnRcvd).await?; assert_state(&alice, alice_msg.id, MessageState::OutMdnRcvd).await; - set_msg_failed(&alice, alice_msg.id, "badly failed").await; + set_msg_failed(&alice, &mut alice_msg, "badly failed").await?; assert_state(&alice, alice_msg.id, MessageState::OutFailed).await; // check incoming message states on receiver side diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 3ba774570..e523d7d81 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -28,7 +28,9 @@ use crate::dehtml::dehtml; use crate::events::EventType; use crate::headerdef::{HeaderDef, HeaderDefMap}; use crate::key::{load_self_secret_key, DcKey, Fingerprint, SignedPublicKey}; -use crate::message::{self, set_msg_failed, update_msg_state, MessageState, MsgId, Viewtype}; +use crate::message::{ + self, set_msg_failed, update_msg_state, Message, MessageState, MsgId, Viewtype, +}; use crate::param::{Param, Params}; use crate::peerstate::Peerstate; use crate::simplify::{simplify, SimplifiedText}; @@ -2153,7 +2155,8 @@ async fn handle_ndn( let mut first = true; for msg in msgs { let (msg_id, chat_id, chat_type) = msg?; - set_msg_failed(context, msg_id, &error).await; + let mut message = Message::load_from_db(context, msg_id).await?; + set_msg_failed(context, &mut message, &error).await?; if first { // Add only one info msg for all failed messages ndn_maybe_add_info_msg(context, failed, chat_id, chat_type).await?; diff --git a/src/param.rs b/src/param.rs index 8768f996d..d0f3bb1aa 100644 --- a/src/param.rs +++ b/src/param.rs @@ -281,6 +281,16 @@ impl Params { self } + /// Sets the given key from an optional value. + /// Removes the key if the value is `None`. + pub fn set_optional(&mut self, key: Param, value: Option) -> &mut Self { + if let Some(value) = value { + self.set(key, value) + } else { + self.remove(key) + } + } + /// Check if there are any values in this. pub fn is_empty(&self) -> bool { self.inner.is_empty() diff --git a/src/provider.rs b/src/provider.rs index 8035acd88..c36f8a77e 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -123,10 +123,10 @@ pub struct Provider { pub overview_page: &'static str, /// List of provider servers. - pub server: Vec, + pub server: &'static [Server], /// Default configuration values to set when provider is configured. - pub config_defaults: Option>, + pub config_defaults: Option<&'static [ConfigDefault]>, /// Type of OAuth 2 authorization if provider supports it. pub oauth2_authorizer: Option, @@ -149,8 +149,8 @@ pub struct ProviderOptions { pub delete_to_trash: bool, } -impl Default for ProviderOptions { - fn default() -> Self { +impl ProviderOptions { + const fn new() -> Self { Self { strict_tls: true, max_smtp_rcpt_to: None, @@ -171,7 +171,7 @@ fn get_resolver() -> Result { let resolver = AsyncResolver::tokio( config::ResolverConfig::default(), config::ResolverOpts::default(), - )?; + ); Ok(resolver) } diff --git a/src/provider/data.rs b/src/provider/data.rs index 32b1ff465..4fa7f2e55 100644 --- a/src/provider/data.rs +++ b/src/provider/data.rs @@ -11,13 +11,13 @@ use std::collections::HashMap; use once_cell::sync::Lazy; // 163.md: 163.com -static P_163: Lazy = Lazy::new(|| Provider { +static P_163: Provider = Provider { id: "163", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/163", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -33,19 +33,19 @@ static P_163: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // aktivix.org.md: aktivix.org -static P_AKTIVIX_ORG: Lazy = Lazy::new(|| Provider { +static P_AKTIVIX_ORG: Provider = Provider { id: "aktivix.org", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/aktivix-org", - server: vec![ + server: &[ Server { protocol: Imap, socket: Starttls, @@ -61,37 +61,35 @@ static P_AKTIVIX_ORG: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // aol.md: aol.com -static P_AOL: Lazy = Lazy::new(|| { - Provider { +static P_AOL: Provider = Provider { id: "aol", status: Status::Preparation, before_login_hint: "To log in to AOL with Delta Chat, you need to set up an app password in the AOL web interface.", after_login_hint: "", overview_page: "https://providers.delta.chat/aol", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "imap.aol.com", port: 993, username_pattern: Email }, Server { protocol: Smtp, socket: Ssl, hostname: "smtp.aol.com", port: 465, username_pattern: Email }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // arcor.de.md: arcor.de -static P_ARCOR_DE: Lazy = Lazy::new(|| Provider { +static P_ARCOR_DE: Provider = Provider { id: "arcor.de", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/arcor-de", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -107,19 +105,19 @@ static P_ARCOR_DE: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // autistici.org.md: autistici.org -static P_AUTISTICI_ORG: Lazy = Lazy::new(|| Provider { +static P_AUTISTICI_ORG: Provider = Provider { id: "autistici.org", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/autistici-org", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -135,19 +133,19 @@ static P_AUTISTICI_ORG: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // blindzeln.org.md: delta.blinzeln.de, delta.blindzeln.org -static P_BLINDZELN_ORG: Lazy = Lazy::new(|| Provider { +static P_BLINDZELN_ORG: Provider = Provider { id: "blindzeln.org", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/blindzeln-org", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -163,19 +161,19 @@ static P_BLINDZELN_ORG: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // bluewin.ch.md: bluewin.ch -static P_BLUEWIN_CH: Lazy = Lazy::new(|| Provider { +static P_BLUEWIN_CH: Provider = Provider { id: "bluewin.ch", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/bluewin-ch", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -191,19 +189,19 @@ static P_BLUEWIN_CH: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // buzon.uy.md: buzon.uy -static P_BUZON_UY: Lazy = Lazy::new(|| Provider { +static P_BUZON_UY: Provider = Provider { id: "buzon.uy", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/buzon-uy", - server: vec![ + server: &[ Server { protocol: Imap, socket: Starttls, @@ -219,19 +217,19 @@ static P_BUZON_UY: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // chello.at.md: chello.at -static P_CHELLO_AT: Lazy = Lazy::new(|| Provider { +static P_CHELLO_AT: Provider = Provider { id: "chello.at", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/chello-at", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -247,45 +245,45 @@ static P_CHELLO_AT: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // comcast.md: xfinity.com, comcast.net -static P_COMCAST: Lazy = Lazy::new(|| Provider { +static P_COMCAST: Provider = Provider { id: "comcast", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/comcast", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // dismail.de.md: dismail.de -static P_DISMAIL_DE: Lazy = Lazy::new(|| Provider { +static P_DISMAIL_DE: Provider = Provider { id: "dismail.de", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/dismail-de", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // disroot.md: disroot.org -static P_DISROOT: Lazy = Lazy::new(|| Provider { +static P_DISROOT: Provider = Provider { id: "disroot", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/disroot", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -301,19 +299,19 @@ static P_DISROOT: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // e.email.md: e.email -static P_E_EMAIL: Lazy = Lazy::new(|| Provider { +static P_E_EMAIL: Provider = Provider { id: "e.email", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/e-email", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -329,51 +327,49 @@ static P_E_EMAIL: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // espiv.net.md: espiv.net -static P_ESPIV_NET: Lazy = Lazy::new(|| Provider { +static P_ESPIV_NET: Provider = Provider { id: "espiv.net", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/espiv-net", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // example.com.md: example.com, example.org, example.net -static P_EXAMPLE_COM: Lazy = Lazy::new(|| { - Provider { +static P_EXAMPLE_COM: Provider = Provider { id: "example.com", status: Status::Broken, before_login_hint: "Hush this provider doesn't exist!", after_login_hint: "This provider doesn't really exist, so you can't use it :/ If you need an email provider for Delta Chat, take a look at providers.delta.chat!", overview_page: "https://providers.delta.chat/example-com", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "imap.example.com", port: 1337, username_pattern: Email }, Server { protocol: Smtp, socket: Starttls, hostname: "smtp.example.com", port: 1337, username_pattern: Email }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // fastmail.md: 123mail.org, 150mail.com, 150ml.com, 16mail.com, 2-mail.com, 4email.net, 50mail.com, airpost.net, allmail.net, bestmail.us, cluemail.com, elitemail.org, emailcorner.net, emailengine.net, emailengine.org, emailgroups.net, emailplus.org, emailuser.net, eml.cc, f-m.fm, fast-email.com, fast-mail.org, fastem.com, fastemail.us, fastemailer.com, fastest.cc, fastimap.com, fastmail.cn, fastmail.co.uk, fastmail.com, fastmail.com.au, fastmail.de, fastmail.es, fastmail.fm, fastmail.fr, fastmail.im, fastmail.in, fastmail.jp, fastmail.mx, fastmail.net, fastmail.nl, fastmail.org, fastmail.se, fastmail.to, fastmail.tw, fastmail.uk, fastmail.us, fastmailbox.net, fastmessaging.com, fea.st, fmail.co.uk, fmailbox.com, fmgirl.com, fmguy.com, ftml.net, h-mail.us, hailmail.net, imap-mail.com, imap.cc, imapmail.org, inoutbox.com, internet-e-mail.com, internet-mail.org, internetemails.net, internetmailing.net, jetemail.net, justemail.net, letterboxes.org, mail-central.com, mail-page.com, mailandftp.com, mailas.com, mailbolt.com, mailc.net, mailcan.com, mailforce.net, mailftp.com, mailhaven.com, mailingaddress.org, mailite.com, mailmight.com, mailnew.com, mailsent.net, mailservice.ms, mailup.net, mailworks.org, ml1.net, mm.st, myfastmail.com, mymacmail.com, nospammail.net, ownmail.net, petml.com, postinbox.com, postpro.net, proinbox.com, promessage.com, realemail.net, reallyfast.biz, reallyfast.info, rushpost.com, sent.as, sent.at, sent.com, speedpost.net, speedymail.org, ssl-mail.com, swift-mail.com, the-fastest.net, the-quickest.com, theinternetemail.com, veryfast.biz, veryspeedy.net, warpmail.net, xsmail.com, yepmail.net, your-mail.com -static P_FASTMAIL: Lazy = Lazy::new(|| Provider { +static P_FASTMAIL: Provider = Provider { id: "fastmail", status: Status::Preparation, before_login_hint: "You must create an app-specific password for Delta Chat before you can log in.", after_login_hint: "", overview_page: "https://providers.delta.chat/fastmail", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -389,37 +385,35 @@ static P_FASTMAIL: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // firemail.de.md: firemail.at, firemail.de -static P_FIREMAIL_DE: Lazy = Lazy::new(|| { - Provider { +static P_FIREMAIL_DE: Provider = Provider { id: "firemail.de", status: Status::Preparation, before_login_hint: "Firemail erlaubt nur bei bezahlten Accounts den vollen Zugriff auf das E-Mail-Protokoll. Wenn Sie nicht für Firemail bezahlen, verwenden Sie bitte einen anderen E-Mail-Anbieter.", after_login_hint: "Leider schränkt Firemail die maximale Gruppengröße ein. Je nach Bezahlmodell sind nur 5 bis 30 Gruppenmitglieder erlaubt.", overview_page: "https://providers.delta.chat/firemail-de", - server: vec![ + server: &[ ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // five.chat.md: five.chat -static P_FIVE_CHAT: Lazy = Lazy::new(|| Provider { +static P_FIVE_CHAT: Provider = Provider { id: "five.chat", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/five-chat", - server: vec![], - opt: Default::default(), - config_defaults: Some(vec![ + server: &[], + opt: ProviderOptions::new(), + config_defaults: Some(&[ ConfigDefault { key: Config::BccSelf, value: "1", @@ -434,55 +428,51 @@ static P_FIVE_CHAT: Lazy = Lazy::new(|| Provider { }, ]), oauth2_authorizer: None, -}); +}; // freenet.de.md: freenet.de -static P_FREENET_DE: Lazy = Lazy::new(|| { - Provider { +static P_FREENET_DE: Provider = Provider { id: "freenet.de", status: Status::Preparation, before_login_hint: "Um deine freenet.de E-Mail-Adresse mit Delta Chat zu benutzen, musst du erst auf der freenet.de-Webseite \"POP3/IMAP/SMTP\" aktivieren.", after_login_hint: "", overview_page: "https://providers.delta.chat/freenet-de", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "mx.freenet.de", port: 993, username_pattern: Email }, Server { protocol: Smtp, socket: Starttls, hostname: "mx.freenet.de", port: 587, username_pattern: Email }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // gmail.md: gmail.com, googlemail.com, google.com -static P_GMAIL: Lazy = Lazy::new(|| { - Provider { +static P_GMAIL: Provider = Provider { id: "gmail", status: Status::Preparation, before_login_hint: "For Gmail accounts, you need to create an app-password if you have \"2-Step Verification\" enabled. If this setting is not available, you need to enable \"less secure apps\".", after_login_hint: "", overview_page: "https://providers.delta.chat/gmail", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "imap.gmail.com", port: 993, username_pattern: Email }, Server { protocol: Smtp, socket: Ssl, hostname: "smtp.gmail.com", port: 465, username_pattern: Email }, ], opt: ProviderOptions { delete_to_trash: true, - ..Default::default() + ..ProviderOptions::new() }, config_defaults: None, oauth2_authorizer: Some(Oauth2Authorizer::Gmail), -} -}); +}; // gmx.net.md: gmx.net, gmx.de, gmx.at, gmx.ch, gmx.org, gmx.eu, gmx.info, gmx.biz, gmx.com -static P_GMX_NET: Lazy = Lazy::new(|| Provider { +static P_GMX_NET: Provider = Provider { id: "gmx.net", status: Status::Preparation, before_login_hint: "You must allow IMAP access to your account before you can login.", after_login_hint: "", overview_page: "https://providers.delta.chat/gmx-net", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -505,24 +495,24 @@ static P_GMX_NET: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // hermes.radio.md: ac.hermes.radio, ac1.hermes.radio, ac2.hermes.radio, ac3.hermes.radio, ac4.hermes.radio, ac5.hermes.radio, ac6.hermes.radio, ac7.hermes.radio, ac8.hermes.radio, ac9.hermes.radio, ac10.hermes.radio, ac11.hermes.radio, ac12.hermes.radio, ac13.hermes.radio, ac14.hermes.radio, ac15.hermes.radio, ka.hermes.radio, ka1.hermes.radio, ka2.hermes.radio, ka3.hermes.radio, ka4.hermes.radio, ka5.hermes.radio, ka6.hermes.radio, ka7.hermes.radio, ka8.hermes.radio, ka9.hermes.radio, ka10.hermes.radio, ka11.hermes.radio, ka12.hermes.radio, ka13.hermes.radio, ka14.hermes.radio, ka15.hermes.radio, ec.hermes.radio, ec1.hermes.radio, ec2.hermes.radio, ec3.hermes.radio, ec4.hermes.radio, ec5.hermes.radio, ec6.hermes.radio, ec7.hermes.radio, ec8.hermes.radio, ec9.hermes.radio, ec10.hermes.radio, ec11.hermes.radio, ec12.hermes.radio, ec13.hermes.radio, ec14.hermes.radio, ec15.hermes.radio, hermes.radio -static P_HERMES_RADIO: Lazy = Lazy::new(|| Provider { +static P_HERMES_RADIO: Provider = Provider { id: "hermes.radio", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/hermes-radio", - server: vec![], + server: &[], opt: ProviderOptions { strict_tls: false, - ..Default::default() + ..ProviderOptions::new() }, - config_defaults: Some(vec![ + config_defaults: Some(&[ ConfigDefault { key: Config::MdnsEnabled, value: "0", @@ -537,58 +527,56 @@ static P_HERMES_RADIO: Lazy = Lazy::new(|| Provider { }, ]), oauth2_authorizer: None, -}); +}; // hey.com.md: hey.com -static P_HEY_COM: Lazy = Lazy::new(|| { - Provider { +static P_HEY_COM: Provider = Provider { id: "hey.com", status: Status::Broken, before_login_hint: "hey.com does not offer the standard IMAP e-mail protocol, so you cannot log in with Delta Chat to hey.com.", after_login_hint: "", overview_page: "https://providers.delta.chat/hey-com", - server: vec![ + server: &[ ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // i.ua.md: i.ua -static P_I_UA: Lazy = Lazy::new(|| Provider { +static P_I_UA: Provider = Provider { id: "i.ua", status: Status::Broken, before_login_hint: "Протокол IMAP не предоставляется и не планируется.", after_login_hint: "", overview_page: "https://providers.delta.chat/i-ua", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // i3.net.md: i3.net -static P_I3_NET: Lazy = Lazy::new(|| Provider { +static P_I3_NET: Provider = Provider { id: "i3.net", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/i3-net", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // icloud.md: icloud.com, me.com, mac.com -static P_ICLOUD: Lazy = Lazy::new(|| Provider { +static P_ICLOUD: Provider = Provider { id: "icloud", status: Status::Preparation, before_login_hint: "You must create an app-specific password for Delta Chat before login.", after_login_hint: "", overview_page: "https://providers.delta.chat/icloud", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -604,19 +592,19 @@ static P_ICLOUD: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // infomaniak.com.md: ik.me -static P_INFOMANIAK_COM: Lazy = Lazy::new(|| Provider { +static P_INFOMANIAK_COM: Provider = Provider { id: "infomaniak.com", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/infomaniak-com", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -634,46 +622,46 @@ static P_INFOMANIAK_COM: Lazy = Lazy::new(|| Provider { ], opt: ProviderOptions { max_smtp_rcpt_to: Some(10), - ..Default::default() + ..ProviderOptions::new() }, config_defaults: None, oauth2_authorizer: None, -}); +}; // kolst.com.md: kolst.com -static P_KOLST_COM: Lazy = Lazy::new(|| Provider { +static P_KOLST_COM: Provider = Provider { id: "kolst.com", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/kolst-com", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // kontent.com.md: kontent.com -static P_KONTENT_COM: Lazy = Lazy::new(|| Provider { +static P_KONTENT_COM: Provider = Provider { id: "kontent.com", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/kontent-com", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // mail.de.md: mail.de -static P_MAIL_DE: Lazy = Lazy::new(|| Provider { +static P_MAIL_DE: Provider = Provider { id: "mail.de", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/mail-de", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -689,37 +677,35 @@ static P_MAIL_DE: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // mail.ru.md: mail.ru, inbox.ru, internet.ru, bk.ru, list.ru -static P_MAIL_RU: Lazy = Lazy::new(|| { - Provider { +static P_MAIL_RU: Provider = Provider { id: "mail.ru", status: Status::Preparation, before_login_hint: "Вам необходимо сгенерировать \"пароль для внешнего приложения\" в веб-интерфейсе mail.ru, чтобы mail.ru работал с Delta Chat.", after_login_hint: "", overview_page: "https://providers.delta.chat/mail-ru", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "imap.mail.ru", port: 993, username_pattern: Email }, Server { protocol: Smtp, socket: Ssl, hostname: "smtp.mail.ru", port: 465, username_pattern: Email }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // mail2tor.md: mail2tor.com -static P_MAIL2TOR: Lazy = Lazy::new(|| Provider { +static P_MAIL2TOR: Provider = Provider { id: "mail2tor", status: Status::Preparation, before_login_hint: "Tor is needed to connect to the email servers.", after_login_hint: "", overview_page: "https://providers.delta.chat/mail2tor", - server: vec![ + server: &[ Server { protocol: Imap, socket: Plain, @@ -735,19 +721,19 @@ static P_MAIL2TOR: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // mailbox.org.md: mailbox.org, secure.mailbox.org -static P_MAILBOX_ORG: Lazy = Lazy::new(|| Provider { +static P_MAILBOX_ORG: Provider = Provider { id: "mailbox.org", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/mailbox-org", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -763,19 +749,19 @@ static P_MAILBOX_ORG: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // mailo.com.md: mailo.com -static P_MAILO_COM: Lazy = Lazy::new(|| Provider { +static P_MAILO_COM: Provider = Provider { id: "mailo.com", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/mailo-com", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -791,19 +777,19 @@ static P_MAILO_COM: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // nauta.cu.md: nauta.cu -static P_NAUTA_CU: Lazy = Lazy::new(|| Provider { +static P_NAUTA_CU: Provider = Provider { id: "nauta.cu", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/nauta-cu", - server: vec![ + server: &[ Server { protocol: Imap, socket: Starttls, @@ -822,9 +808,9 @@ static P_NAUTA_CU: Lazy = Lazy::new(|| Provider { opt: ProviderOptions { max_smtp_rcpt_to: Some(20), strict_tls: false, - ..Default::default() + ..ProviderOptions::new() }, - config_defaults: Some(vec![ + config_defaults: Some(&[ ConfigDefault { key: Config::DeleteServerAfter, value: "1", @@ -851,16 +837,16 @@ static P_NAUTA_CU: Lazy = Lazy::new(|| Provider { }, ]), oauth2_authorizer: None, -}); +}; // naver.md: naver.com -static P_NAVER: Lazy = Lazy::new(|| Provider { +static P_NAVER: Provider = Provider { id: "naver", status: Status::Preparation, before_login_hint: "Manually enabling IMAP/SMTP is required.", after_login_hint: "", overview_page: "https://providers.delta.chat/naver", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -876,19 +862,19 @@ static P_NAVER: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // nubo.coop.md: nubo.coop -static P_NUBO_COOP: Lazy = Lazy::new(|| Provider { +static P_NUBO_COOP: Provider = Provider { id: "nubo.coop", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/nubo-coop", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -904,19 +890,19 @@ static P_NUBO_COOP: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // outlook.com.md: hotmail.com, outlook.com, office365.com, outlook.com.tr, live.com, outlook.de -static P_OUTLOOK_COM: Lazy = Lazy::new(|| Provider { +static P_OUTLOOK_COM: Provider = Provider { id: "outlook.com", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/outlook-com", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -932,19 +918,19 @@ static P_OUTLOOK_COM: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // ouvaton.coop.md: ouvaton.org -static P_OUVATON_COOP: Lazy = Lazy::new(|| Provider { +static P_OUVATON_COOP: Provider = Provider { id: "ouvaton.coop", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/ouvaton-coop", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -960,19 +946,19 @@ static P_OUVATON_COOP: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // posteo.md: posteo.de, posteo.af, posteo.at, posteo.be, posteo.ca, posteo.ch, posteo.cl, posteo.co, posteo.co.uk, posteo.com.br, posteo.cr, posteo.cz, posteo.dk, posteo.ee, posteo.es, posteo.eu, posteo.fi, posteo.gl, posteo.gr, posteo.hn, posteo.hr, posteo.hu, posteo.ie, posteo.in, posteo.is, posteo.it, posteo.jp, posteo.la, posteo.li, posteo.lt, posteo.lu, posteo.me, posteo.mx, posteo.my, posteo.net, posteo.nl, posteo.no, posteo.nz, posteo.org, posteo.pe, posteo.pl, posteo.pm, posteo.pt, posteo.ro, posteo.ru, posteo.se, posteo.sg, posteo.si, posteo.tn, posteo.uk, posteo.us -static P_POSTEO: Lazy = Lazy::new(|| Provider { +static P_POSTEO: Provider = Provider { id: "posteo", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/posteo", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1002,53 +988,49 @@ static P_POSTEO: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // protonmail.md: protonmail.com, protonmail.ch, pm.me -static P_PROTONMAIL: Lazy = Lazy::new(|| { - Provider { +static P_PROTONMAIL: Provider = Provider { id: "protonmail", status: Status::Broken, before_login_hint: "Protonmail does not offer the standard IMAP e-mail protocol, so you cannot log in with Delta Chat to Protonmail.", after_login_hint: "To use Delta Chat with Protonmail, the IMAP bridge must be running in the background. If you have connectivity issues, double check whether it works as expected.", overview_page: "https://providers.delta.chat/protonmail", - server: vec![ + server: &[ ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // qq.md: qq.com, foxmail.com -static P_QQ: Lazy = Lazy::new(|| { - Provider { +static P_QQ: Provider = Provider { id: "qq", status: Status::Preparation, before_login_hint: "Manually enabling IMAP/SMTP and creating an app-specific password for Delta Chat are required.", after_login_hint: "", overview_page: "https://providers.delta.chat/qq", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "imap.qq.com", port: 993, username_pattern: Emaillocalpart }, Server { protocol: Smtp, socket: Ssl, hostname: "smtp.qq.com", port: 465, username_pattern: Email }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // riseup.net.md: riseup.net -static P_RISEUP_NET: Lazy = Lazy::new(|| Provider { +static P_RISEUP_NET: Provider = Provider { id: "riseup.net", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/riseup-net", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1064,45 +1046,45 @@ static P_RISEUP_NET: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // rogers.com.md: rogers.com -static P_ROGERS_COM: Lazy = Lazy::new(|| Provider { +static P_ROGERS_COM: Provider = Provider { id: "rogers.com", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/rogers-com", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // sonic.md: sonic.net -static P_SONIC: Lazy = Lazy::new(|| Provider { +static P_SONIC: Provider = Provider { id: "sonic", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/sonic", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // systemausfall.org.md: systemausfall.org, solidaris.me -static P_SYSTEMAUSFALL_ORG: Lazy = Lazy::new(|| Provider { +static P_SYSTEMAUSFALL_ORG: Provider = Provider { id: "systemausfall.org", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/systemausfall-org", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1118,19 +1100,19 @@ static P_SYSTEMAUSFALL_ORG: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // systemli.org.md: systemli.org -static P_SYSTEMLI_ORG: Lazy = Lazy::new(|| Provider { +static P_SYSTEMLI_ORG: Provider = Provider { id: "systemli.org", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/systemli-org", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1146,37 +1128,35 @@ static P_SYSTEMLI_ORG: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // t-online.md: t-online.de, magenta.de -static P_T_ONLINE: Lazy = Lazy::new(|| { - Provider { +static P_T_ONLINE: Provider = Provider { id: "t-online", status: Status::Preparation, before_login_hint: "To use Delta Chat with a T-Online email address, you need to create an app password in the web interface.", after_login_hint: "", overview_page: "https://providers.delta.chat/t-online", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "secureimap.t-online.de", port: 993, username_pattern: Email }, Server { protocol: Smtp, socket: Ssl, hostname: "securesmtp.t-online.de", port: 465, username_pattern: Email }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // testrun.md: testrun.org -static P_TESTRUN: Lazy = Lazy::new(|| Provider { +static P_TESTRUN: Provider = Provider { id: "testrun", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/testrun", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1199,8 +1179,8 @@ static P_TESTRUN: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), - config_defaults: Some(vec![ + opt: ProviderOptions::new(), + config_defaults: Some(&[ ConfigDefault { key: Config::BccSelf, value: "1", @@ -1215,16 +1195,16 @@ static P_TESTRUN: Lazy = Lazy::new(|| Provider { }, ]), oauth2_authorizer: None, -}); +}; // tiscali.it.md: tiscali.it -static P_TISCALI_IT: Lazy = Lazy::new(|| Provider { +static P_TISCALI_IT: Provider = Provider { id: "tiscali.it", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/tiscali-it", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1240,48 +1220,46 @@ static P_TISCALI_IT: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // tutanota.md: tutanota.com, tutanota.de, tutamail.com, tuta.io, keemail.me -static P_TUTANOTA: Lazy = Lazy::new(|| { - Provider { +static P_TUTANOTA: Provider = Provider { id: "tutanota", status: Status::Broken, before_login_hint: "Tutanota does not offer the standard IMAP e-mail protocol, so you cannot log in with Delta Chat to Tutanota.", after_login_hint: "", overview_page: "https://providers.delta.chat/tutanota", - server: vec![ + server: &[ ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // ukr.net.md: ukr.net -static P_UKR_NET: Lazy = Lazy::new(|| Provider { +static P_UKR_NET: Provider = Provider { id: "ukr.net", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/ukr-net", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // undernet.uy.md: undernet.uy -static P_UNDERNET_UY: Lazy = Lazy::new(|| Provider { +static P_UNDERNET_UY: Provider = Provider { id: "undernet.uy", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/undernet-uy", - server: vec![ + server: &[ Server { protocol: Imap, socket: Starttls, @@ -1297,32 +1275,32 @@ static P_UNDERNET_UY: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // vfemail.md: vfemail.net -static P_VFEMAIL: Lazy = Lazy::new(|| Provider { +static P_VFEMAIL: Provider = Provider { id: "vfemail", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/vfemail", - server: vec![], - opt: Default::default(), + server: &[], + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // vivaldi.md: vivaldi.net -static P_VIVALDI: Lazy = Lazy::new(|| Provider { +static P_VIVALDI: Provider = Provider { id: "vivaldi", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/vivaldi", - server: vec![ + server: &[ Server { protocol: Imap, socket: Starttls, @@ -1338,19 +1316,19 @@ static P_VIVALDI: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // vodafone.de.md: vodafone.de, vodafonemail.de -static P_VODAFONE_DE: Lazy = Lazy::new(|| Provider { +static P_VODAFONE_DE: Provider = Provider { id: "vodafone.de", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/vodafone-de", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1366,56 +1344,52 @@ static P_VODAFONE_DE: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // web.de.md: web.de, email.de, flirt.ms, hallo.ms, kuss.ms, love.ms, magic.ms, singles.ms, cool.ms, kanzler.ms, okay.ms, party.ms, pop.ms, stars.ms, techno.ms, clever.ms, deutschland.ms, genial.ms, ich.ms, online.ms, smart.ms, wichtig.ms, action.ms, fussball.ms, joker.ms, planet.ms, power.ms -static P_WEB_DE: Lazy = Lazy::new(|| { - Provider { +static P_WEB_DE: Provider = Provider { id: "web.de", status: Status::Preparation, before_login_hint: "You must allow IMAP access to your account before you can login.", after_login_hint: "Note: if you have your web.de spam settings too strict, you won't receive contact requests from new people. If you want to receive contact requests, you should disable the \"3-Wege-Spamschutz\" in the web.de settings. Read how: https://hilfe.web.de/email/spam-und-viren/spamschutz-einstellungen.html", overview_page: "https://providers.delta.chat/web-de", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "imap.web.de", port: 993, username_pattern: Emaillocalpart }, Server { protocol: Imap, socket: Starttls, hostname: "imap.web.de", port: 143, username_pattern: Emaillocalpart }, Server { protocol: Smtp, socket: Starttls, hostname: "smtp.web.de", port: 587, username_pattern: Emaillocalpart }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // yahoo.md: yahoo.com, yahoo.de, yahoo.it, yahoo.fr, yahoo.es, yahoo.se, yahoo.co.uk, yahoo.co.nz, yahoo.com.au, yahoo.com.ar, yahoo.com.br, yahoo.com.mx, ymail.com, rocketmail.com, yahoodns.net -static P_YAHOO: Lazy = Lazy::new(|| { - Provider { +static P_YAHOO: Provider = Provider { id: "yahoo", status: Status::Preparation, before_login_hint: "To use Delta Chat with your Yahoo email address you have to create an \"App-Password\" in the account security screen.", after_login_hint: "", overview_page: "https://providers.delta.chat/yahoo", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, hostname: "imap.mail.yahoo.com", port: 993, username_pattern: Email }, Server { protocol: Smtp, socket: Ssl, hostname: "smtp.mail.yahoo.com", port: 465, username_pattern: Email }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -} -}); +}; // yandex.ru.md: yandex.com, yandex.by, yandex.kz, yandex.ru, yandex.ua, ya.ru, narod.ru -static P_YANDEX_RU: Lazy = Lazy::new(|| Provider { +static P_YANDEX_RU: Provider = Provider { id: "yandex.ru", status: Status::Preparation, before_login_hint: "For Yandex accounts, you have to set IMAP protocol option turned on.", after_login_hint: "", overview_page: "https://providers.delta.chat/yandex-ru", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1431,39 +1405,37 @@ static P_YANDEX_RU: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: Some(Oauth2Authorizer::Yandex), -}); +}; // yggmail.md: yggmail -static P_YGGMAIL: Lazy = Lazy::new(|| { - Provider { +static P_YGGMAIL: Provider = Provider { id: "yggmail", status: Status::Preparation, before_login_hint: "An Yggmail companion app needs to be installed on your device to access the Yggmail network.", after_login_hint: "Make sure, the Yggmail companion app runs whenever you want to use this account. Note, that you usually cannot write from @yggmail addresses to normal e-mail-addresses (as @gmx.net). However, you can create another account in the normal e-mail-network for this purpose.", overview_page: "https://providers.delta.chat/yggmail", - server: vec![ + server: &[ Server { protocol: Imap, socket: Plain, hostname: "localhost", port: 1143, username_pattern: Email }, Server { protocol: Smtp, socket: Plain, hostname: "localhost", port: 1025, username_pattern: Email }, ], - opt: Default::default(), - config_defaults: Some(vec![ + opt: ProviderOptions::new(), + config_defaults: Some(&[ ConfigDefault { key: Config::MvboxMove, value: "0" }, ]), oauth2_authorizer: None, -} -}); +}; // ziggo.nl.md: ziggo.nl -static P_ZIGGO_NL: Lazy = Lazy::new(|| Provider { +static P_ZIGGO_NL: Provider = Provider { id: "ziggo.nl", status: Status::Ok, before_login_hint: "", after_login_hint: "", overview_page: "https://providers.delta.chat/ziggo-nl", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1479,19 +1451,19 @@ static P_ZIGGO_NL: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; // zoho.md: zohomail.eu, zohomail.com, zoho.com -static P_ZOHO: Lazy = Lazy::new(|| Provider { +static P_ZOHO: Provider = Provider { id: "zoho", status: Status::Preparation, before_login_hint: "To use Zoho Mail, you have to turn on IMAP in the Zoho Mail backend.", after_login_hint: "", overview_page: "https://providers.delta.chat/zoho", - server: vec![ + server: &[ Server { protocol: Imap, socket: Ssl, @@ -1507,441 +1479,441 @@ static P_ZOHO: Lazy = Lazy::new(|| Provider { username_pattern: Email, }, ], - opt: Default::default(), + opt: ProviderOptions::new(), config_defaults: None, oauth2_authorizer: None, -}); +}; pub(crate) static PROVIDER_DATA: Lazy> = Lazy::new(|| { HashMap::from([ - ("163.com", &*P_163), - ("aktivix.org", &*P_AKTIVIX_ORG), - ("aol.com", &*P_AOL), - ("arcor.de", &*P_ARCOR_DE), - ("autistici.org", &*P_AUTISTICI_ORG), - ("delta.blinzeln.de", &*P_BLINDZELN_ORG), - ("delta.blindzeln.org", &*P_BLINDZELN_ORG), - ("bluewin.ch", &*P_BLUEWIN_CH), - ("buzon.uy", &*P_BUZON_UY), - ("chello.at", &*P_CHELLO_AT), - ("xfinity.com", &*P_COMCAST), - ("comcast.net", &*P_COMCAST), - ("dismail.de", &*P_DISMAIL_DE), - ("disroot.org", &*P_DISROOT), - ("e.email", &*P_E_EMAIL), - ("espiv.net", &*P_ESPIV_NET), - ("example.com", &*P_EXAMPLE_COM), - ("example.org", &*P_EXAMPLE_COM), - ("example.net", &*P_EXAMPLE_COM), - ("123mail.org", &*P_FASTMAIL), - ("150mail.com", &*P_FASTMAIL), - ("150ml.com", &*P_FASTMAIL), - ("16mail.com", &*P_FASTMAIL), - ("2-mail.com", &*P_FASTMAIL), - ("4email.net", &*P_FASTMAIL), - ("50mail.com", &*P_FASTMAIL), - ("airpost.net", &*P_FASTMAIL), - ("allmail.net", &*P_FASTMAIL), - ("bestmail.us", &*P_FASTMAIL), - ("cluemail.com", &*P_FASTMAIL), - ("elitemail.org", &*P_FASTMAIL), - ("emailcorner.net", &*P_FASTMAIL), - ("emailengine.net", &*P_FASTMAIL), - ("emailengine.org", &*P_FASTMAIL), - ("emailgroups.net", &*P_FASTMAIL), - ("emailplus.org", &*P_FASTMAIL), - ("emailuser.net", &*P_FASTMAIL), - ("eml.cc", &*P_FASTMAIL), - ("f-m.fm", &*P_FASTMAIL), - ("fast-email.com", &*P_FASTMAIL), - ("fast-mail.org", &*P_FASTMAIL), - ("fastem.com", &*P_FASTMAIL), - ("fastemail.us", &*P_FASTMAIL), - ("fastemailer.com", &*P_FASTMAIL), - ("fastest.cc", &*P_FASTMAIL), - ("fastimap.com", &*P_FASTMAIL), - ("fastmail.cn", &*P_FASTMAIL), - ("fastmail.co.uk", &*P_FASTMAIL), - ("fastmail.com", &*P_FASTMAIL), - ("fastmail.com.au", &*P_FASTMAIL), - ("fastmail.de", &*P_FASTMAIL), - ("fastmail.es", &*P_FASTMAIL), - ("fastmail.fm", &*P_FASTMAIL), - ("fastmail.fr", &*P_FASTMAIL), - ("fastmail.im", &*P_FASTMAIL), - ("fastmail.in", &*P_FASTMAIL), - ("fastmail.jp", &*P_FASTMAIL), - ("fastmail.mx", &*P_FASTMAIL), - ("fastmail.net", &*P_FASTMAIL), - ("fastmail.nl", &*P_FASTMAIL), - ("fastmail.org", &*P_FASTMAIL), - ("fastmail.se", &*P_FASTMAIL), - ("fastmail.to", &*P_FASTMAIL), - ("fastmail.tw", &*P_FASTMAIL), - ("fastmail.uk", &*P_FASTMAIL), - ("fastmail.us", &*P_FASTMAIL), - ("fastmailbox.net", &*P_FASTMAIL), - ("fastmessaging.com", &*P_FASTMAIL), - ("fea.st", &*P_FASTMAIL), - ("fmail.co.uk", &*P_FASTMAIL), - ("fmailbox.com", &*P_FASTMAIL), - ("fmgirl.com", &*P_FASTMAIL), - ("fmguy.com", &*P_FASTMAIL), - ("ftml.net", &*P_FASTMAIL), - ("h-mail.us", &*P_FASTMAIL), - ("hailmail.net", &*P_FASTMAIL), - ("imap-mail.com", &*P_FASTMAIL), - ("imap.cc", &*P_FASTMAIL), - ("imapmail.org", &*P_FASTMAIL), - ("inoutbox.com", &*P_FASTMAIL), - ("internet-e-mail.com", &*P_FASTMAIL), - ("internet-mail.org", &*P_FASTMAIL), - ("internetemails.net", &*P_FASTMAIL), - ("internetmailing.net", &*P_FASTMAIL), - ("jetemail.net", &*P_FASTMAIL), - ("justemail.net", &*P_FASTMAIL), - ("letterboxes.org", &*P_FASTMAIL), - ("mail-central.com", &*P_FASTMAIL), - ("mail-page.com", &*P_FASTMAIL), - ("mailandftp.com", &*P_FASTMAIL), - ("mailas.com", &*P_FASTMAIL), - ("mailbolt.com", &*P_FASTMAIL), - ("mailc.net", &*P_FASTMAIL), - ("mailcan.com", &*P_FASTMAIL), - ("mailforce.net", &*P_FASTMAIL), - ("mailftp.com", &*P_FASTMAIL), - ("mailhaven.com", &*P_FASTMAIL), - ("mailingaddress.org", &*P_FASTMAIL), - ("mailite.com", &*P_FASTMAIL), - ("mailmight.com", &*P_FASTMAIL), - ("mailnew.com", &*P_FASTMAIL), - ("mailsent.net", &*P_FASTMAIL), - ("mailservice.ms", &*P_FASTMAIL), - ("mailup.net", &*P_FASTMAIL), - ("mailworks.org", &*P_FASTMAIL), - ("ml1.net", &*P_FASTMAIL), - ("mm.st", &*P_FASTMAIL), - ("myfastmail.com", &*P_FASTMAIL), - ("mymacmail.com", &*P_FASTMAIL), - ("nospammail.net", &*P_FASTMAIL), - ("ownmail.net", &*P_FASTMAIL), - ("petml.com", &*P_FASTMAIL), - ("postinbox.com", &*P_FASTMAIL), - ("postpro.net", &*P_FASTMAIL), - ("proinbox.com", &*P_FASTMAIL), - ("promessage.com", &*P_FASTMAIL), - ("realemail.net", &*P_FASTMAIL), - ("reallyfast.biz", &*P_FASTMAIL), - ("reallyfast.info", &*P_FASTMAIL), - ("rushpost.com", &*P_FASTMAIL), - ("sent.as", &*P_FASTMAIL), - ("sent.at", &*P_FASTMAIL), - ("sent.com", &*P_FASTMAIL), - ("speedpost.net", &*P_FASTMAIL), - ("speedymail.org", &*P_FASTMAIL), - ("ssl-mail.com", &*P_FASTMAIL), - ("swift-mail.com", &*P_FASTMAIL), - ("the-fastest.net", &*P_FASTMAIL), - ("the-quickest.com", &*P_FASTMAIL), - ("theinternetemail.com", &*P_FASTMAIL), - ("veryfast.biz", &*P_FASTMAIL), - ("veryspeedy.net", &*P_FASTMAIL), - ("warpmail.net", &*P_FASTMAIL), - ("xsmail.com", &*P_FASTMAIL), - ("yepmail.net", &*P_FASTMAIL), - ("your-mail.com", &*P_FASTMAIL), - ("firemail.at", &*P_FIREMAIL_DE), - ("firemail.de", &*P_FIREMAIL_DE), - ("five.chat", &*P_FIVE_CHAT), - ("freenet.de", &*P_FREENET_DE), - ("gmail.com", &*P_GMAIL), - ("googlemail.com", &*P_GMAIL), - ("google.com", &*P_GMAIL), - ("gmx.net", &*P_GMX_NET), - ("gmx.de", &*P_GMX_NET), - ("gmx.at", &*P_GMX_NET), - ("gmx.ch", &*P_GMX_NET), - ("gmx.org", &*P_GMX_NET), - ("gmx.eu", &*P_GMX_NET), - ("gmx.info", &*P_GMX_NET), - ("gmx.biz", &*P_GMX_NET), - ("gmx.com", &*P_GMX_NET), - ("ac.hermes.radio", &*P_HERMES_RADIO), - ("ac1.hermes.radio", &*P_HERMES_RADIO), - ("ac2.hermes.radio", &*P_HERMES_RADIO), - ("ac3.hermes.radio", &*P_HERMES_RADIO), - ("ac4.hermes.radio", &*P_HERMES_RADIO), - ("ac5.hermes.radio", &*P_HERMES_RADIO), - ("ac6.hermes.radio", &*P_HERMES_RADIO), - ("ac7.hermes.radio", &*P_HERMES_RADIO), - ("ac8.hermes.radio", &*P_HERMES_RADIO), - ("ac9.hermes.radio", &*P_HERMES_RADIO), - ("ac10.hermes.radio", &*P_HERMES_RADIO), - ("ac11.hermes.radio", &*P_HERMES_RADIO), - ("ac12.hermes.radio", &*P_HERMES_RADIO), - ("ac13.hermes.radio", &*P_HERMES_RADIO), - ("ac14.hermes.radio", &*P_HERMES_RADIO), - ("ac15.hermes.radio", &*P_HERMES_RADIO), - ("ka.hermes.radio", &*P_HERMES_RADIO), - ("ka1.hermes.radio", &*P_HERMES_RADIO), - ("ka2.hermes.radio", &*P_HERMES_RADIO), - ("ka3.hermes.radio", &*P_HERMES_RADIO), - ("ka4.hermes.radio", &*P_HERMES_RADIO), - ("ka5.hermes.radio", &*P_HERMES_RADIO), - ("ka6.hermes.radio", &*P_HERMES_RADIO), - ("ka7.hermes.radio", &*P_HERMES_RADIO), - ("ka8.hermes.radio", &*P_HERMES_RADIO), - ("ka9.hermes.radio", &*P_HERMES_RADIO), - ("ka10.hermes.radio", &*P_HERMES_RADIO), - ("ka11.hermes.radio", &*P_HERMES_RADIO), - ("ka12.hermes.radio", &*P_HERMES_RADIO), - ("ka13.hermes.radio", &*P_HERMES_RADIO), - ("ka14.hermes.radio", &*P_HERMES_RADIO), - ("ka15.hermes.radio", &*P_HERMES_RADIO), - ("ec.hermes.radio", &*P_HERMES_RADIO), - ("ec1.hermes.radio", &*P_HERMES_RADIO), - ("ec2.hermes.radio", &*P_HERMES_RADIO), - ("ec3.hermes.radio", &*P_HERMES_RADIO), - ("ec4.hermes.radio", &*P_HERMES_RADIO), - ("ec5.hermes.radio", &*P_HERMES_RADIO), - ("ec6.hermes.radio", &*P_HERMES_RADIO), - ("ec7.hermes.radio", &*P_HERMES_RADIO), - ("ec8.hermes.radio", &*P_HERMES_RADIO), - ("ec9.hermes.radio", &*P_HERMES_RADIO), - ("ec10.hermes.radio", &*P_HERMES_RADIO), - ("ec11.hermes.radio", &*P_HERMES_RADIO), - ("ec12.hermes.radio", &*P_HERMES_RADIO), - ("ec13.hermes.radio", &*P_HERMES_RADIO), - ("ec14.hermes.radio", &*P_HERMES_RADIO), - ("ec15.hermes.radio", &*P_HERMES_RADIO), - ("hermes.radio", &*P_HERMES_RADIO), - ("hey.com", &*P_HEY_COM), - ("i.ua", &*P_I_UA), - ("i3.net", &*P_I3_NET), - ("icloud.com", &*P_ICLOUD), - ("me.com", &*P_ICLOUD), - ("mac.com", &*P_ICLOUD), - ("ik.me", &*P_INFOMANIAK_COM), - ("kolst.com", &*P_KOLST_COM), - ("kontent.com", &*P_KONTENT_COM), - ("mail.de", &*P_MAIL_DE), - ("mail.ru", &*P_MAIL_RU), - ("inbox.ru", &*P_MAIL_RU), - ("internet.ru", &*P_MAIL_RU), - ("bk.ru", &*P_MAIL_RU), - ("list.ru", &*P_MAIL_RU), - ("mail2tor.com", &*P_MAIL2TOR), - ("mailbox.org", &*P_MAILBOX_ORG), - ("secure.mailbox.org", &*P_MAILBOX_ORG), - ("mailo.com", &*P_MAILO_COM), - ("nauta.cu", &*P_NAUTA_CU), - ("naver.com", &*P_NAVER), - ("nubo.coop", &*P_NUBO_COOP), - ("hotmail.com", &*P_OUTLOOK_COM), - ("outlook.com", &*P_OUTLOOK_COM), - ("office365.com", &*P_OUTLOOK_COM), - ("outlook.com.tr", &*P_OUTLOOK_COM), - ("live.com", &*P_OUTLOOK_COM), - ("outlook.de", &*P_OUTLOOK_COM), - ("ouvaton.org", &*P_OUVATON_COOP), - ("posteo.de", &*P_POSTEO), - ("posteo.af", &*P_POSTEO), - ("posteo.at", &*P_POSTEO), - ("posteo.be", &*P_POSTEO), - ("posteo.ca", &*P_POSTEO), - ("posteo.ch", &*P_POSTEO), - ("posteo.cl", &*P_POSTEO), - ("posteo.co", &*P_POSTEO), - ("posteo.co.uk", &*P_POSTEO), - ("posteo.com.br", &*P_POSTEO), - ("posteo.cr", &*P_POSTEO), - ("posteo.cz", &*P_POSTEO), - ("posteo.dk", &*P_POSTEO), - ("posteo.ee", &*P_POSTEO), - ("posteo.es", &*P_POSTEO), - ("posteo.eu", &*P_POSTEO), - ("posteo.fi", &*P_POSTEO), - ("posteo.gl", &*P_POSTEO), - ("posteo.gr", &*P_POSTEO), - ("posteo.hn", &*P_POSTEO), - ("posteo.hr", &*P_POSTEO), - ("posteo.hu", &*P_POSTEO), - ("posteo.ie", &*P_POSTEO), - ("posteo.in", &*P_POSTEO), - ("posteo.is", &*P_POSTEO), - ("posteo.it", &*P_POSTEO), - ("posteo.jp", &*P_POSTEO), - ("posteo.la", &*P_POSTEO), - ("posteo.li", &*P_POSTEO), - ("posteo.lt", &*P_POSTEO), - ("posteo.lu", &*P_POSTEO), - ("posteo.me", &*P_POSTEO), - ("posteo.mx", &*P_POSTEO), - ("posteo.my", &*P_POSTEO), - ("posteo.net", &*P_POSTEO), - ("posteo.nl", &*P_POSTEO), - ("posteo.no", &*P_POSTEO), - ("posteo.nz", &*P_POSTEO), - ("posteo.org", &*P_POSTEO), - ("posteo.pe", &*P_POSTEO), - ("posteo.pl", &*P_POSTEO), - ("posteo.pm", &*P_POSTEO), - ("posteo.pt", &*P_POSTEO), - ("posteo.ro", &*P_POSTEO), - ("posteo.ru", &*P_POSTEO), - ("posteo.se", &*P_POSTEO), - ("posteo.sg", &*P_POSTEO), - ("posteo.si", &*P_POSTEO), - ("posteo.tn", &*P_POSTEO), - ("posteo.uk", &*P_POSTEO), - ("posteo.us", &*P_POSTEO), - ("protonmail.com", &*P_PROTONMAIL), - ("protonmail.ch", &*P_PROTONMAIL), - ("pm.me", &*P_PROTONMAIL), - ("qq.com", &*P_QQ), - ("foxmail.com", &*P_QQ), - ("riseup.net", &*P_RISEUP_NET), - ("rogers.com", &*P_ROGERS_COM), - ("sonic.net", &*P_SONIC), - ("systemausfall.org", &*P_SYSTEMAUSFALL_ORG), - ("solidaris.me", &*P_SYSTEMAUSFALL_ORG), - ("systemli.org", &*P_SYSTEMLI_ORG), - ("t-online.de", &*P_T_ONLINE), - ("magenta.de", &*P_T_ONLINE), - ("testrun.org", &*P_TESTRUN), - ("tiscali.it", &*P_TISCALI_IT), - ("tutanota.com", &*P_TUTANOTA), - ("tutanota.de", &*P_TUTANOTA), - ("tutamail.com", &*P_TUTANOTA), - ("tuta.io", &*P_TUTANOTA), - ("keemail.me", &*P_TUTANOTA), - ("ukr.net", &*P_UKR_NET), - ("undernet.uy", &*P_UNDERNET_UY), - ("vfemail.net", &*P_VFEMAIL), - ("vivaldi.net", &*P_VIVALDI), - ("vodafone.de", &*P_VODAFONE_DE), - ("vodafonemail.de", &*P_VODAFONE_DE), - ("web.de", &*P_WEB_DE), - ("email.de", &*P_WEB_DE), - ("flirt.ms", &*P_WEB_DE), - ("hallo.ms", &*P_WEB_DE), - ("kuss.ms", &*P_WEB_DE), - ("love.ms", &*P_WEB_DE), - ("magic.ms", &*P_WEB_DE), - ("singles.ms", &*P_WEB_DE), - ("cool.ms", &*P_WEB_DE), - ("kanzler.ms", &*P_WEB_DE), - ("okay.ms", &*P_WEB_DE), - ("party.ms", &*P_WEB_DE), - ("pop.ms", &*P_WEB_DE), - ("stars.ms", &*P_WEB_DE), - ("techno.ms", &*P_WEB_DE), - ("clever.ms", &*P_WEB_DE), - ("deutschland.ms", &*P_WEB_DE), - ("genial.ms", &*P_WEB_DE), - ("ich.ms", &*P_WEB_DE), - ("online.ms", &*P_WEB_DE), - ("smart.ms", &*P_WEB_DE), - ("wichtig.ms", &*P_WEB_DE), - ("action.ms", &*P_WEB_DE), - ("fussball.ms", &*P_WEB_DE), - ("joker.ms", &*P_WEB_DE), - ("planet.ms", &*P_WEB_DE), - ("power.ms", &*P_WEB_DE), - ("yahoo.com", &*P_YAHOO), - ("yahoo.de", &*P_YAHOO), - ("yahoo.it", &*P_YAHOO), - ("yahoo.fr", &*P_YAHOO), - ("yahoo.es", &*P_YAHOO), - ("yahoo.se", &*P_YAHOO), - ("yahoo.co.uk", &*P_YAHOO), - ("yahoo.co.nz", &*P_YAHOO), - ("yahoo.com.au", &*P_YAHOO), - ("yahoo.com.ar", &*P_YAHOO), - ("yahoo.com.br", &*P_YAHOO), - ("yahoo.com.mx", &*P_YAHOO), - ("ymail.com", &*P_YAHOO), - ("rocketmail.com", &*P_YAHOO), - ("yahoodns.net", &*P_YAHOO), - ("yandex.com", &*P_YANDEX_RU), - ("yandex.by", &*P_YANDEX_RU), - ("yandex.kz", &*P_YANDEX_RU), - ("yandex.ru", &*P_YANDEX_RU), - ("yandex.ua", &*P_YANDEX_RU), - ("ya.ru", &*P_YANDEX_RU), - ("narod.ru", &*P_YANDEX_RU), - ("yggmail", &*P_YGGMAIL), - ("ziggo.nl", &*P_ZIGGO_NL), - ("zohomail.eu", &*P_ZOHO), - ("zohomail.com", &*P_ZOHO), - ("zoho.com", &*P_ZOHO), + ("163.com", &P_163), + ("aktivix.org", &P_AKTIVIX_ORG), + ("aol.com", &P_AOL), + ("arcor.de", &P_ARCOR_DE), + ("autistici.org", &P_AUTISTICI_ORG), + ("delta.blinzeln.de", &P_BLINDZELN_ORG), + ("delta.blindzeln.org", &P_BLINDZELN_ORG), + ("bluewin.ch", &P_BLUEWIN_CH), + ("buzon.uy", &P_BUZON_UY), + ("chello.at", &P_CHELLO_AT), + ("xfinity.com", &P_COMCAST), + ("comcast.net", &P_COMCAST), + ("dismail.de", &P_DISMAIL_DE), + ("disroot.org", &P_DISROOT), + ("e.email", &P_E_EMAIL), + ("espiv.net", &P_ESPIV_NET), + ("example.com", &P_EXAMPLE_COM), + ("example.org", &P_EXAMPLE_COM), + ("example.net", &P_EXAMPLE_COM), + ("123mail.org", &P_FASTMAIL), + ("150mail.com", &P_FASTMAIL), + ("150ml.com", &P_FASTMAIL), + ("16mail.com", &P_FASTMAIL), + ("2-mail.com", &P_FASTMAIL), + ("4email.net", &P_FASTMAIL), + ("50mail.com", &P_FASTMAIL), + ("airpost.net", &P_FASTMAIL), + ("allmail.net", &P_FASTMAIL), + ("bestmail.us", &P_FASTMAIL), + ("cluemail.com", &P_FASTMAIL), + ("elitemail.org", &P_FASTMAIL), + ("emailcorner.net", &P_FASTMAIL), + ("emailengine.net", &P_FASTMAIL), + ("emailengine.org", &P_FASTMAIL), + ("emailgroups.net", &P_FASTMAIL), + ("emailplus.org", &P_FASTMAIL), + ("emailuser.net", &P_FASTMAIL), + ("eml.cc", &P_FASTMAIL), + ("f-m.fm", &P_FASTMAIL), + ("fast-email.com", &P_FASTMAIL), + ("fast-mail.org", &P_FASTMAIL), + ("fastem.com", &P_FASTMAIL), + ("fastemail.us", &P_FASTMAIL), + ("fastemailer.com", &P_FASTMAIL), + ("fastest.cc", &P_FASTMAIL), + ("fastimap.com", &P_FASTMAIL), + ("fastmail.cn", &P_FASTMAIL), + ("fastmail.co.uk", &P_FASTMAIL), + ("fastmail.com", &P_FASTMAIL), + ("fastmail.com.au", &P_FASTMAIL), + ("fastmail.de", &P_FASTMAIL), + ("fastmail.es", &P_FASTMAIL), + ("fastmail.fm", &P_FASTMAIL), + ("fastmail.fr", &P_FASTMAIL), + ("fastmail.im", &P_FASTMAIL), + ("fastmail.in", &P_FASTMAIL), + ("fastmail.jp", &P_FASTMAIL), + ("fastmail.mx", &P_FASTMAIL), + ("fastmail.net", &P_FASTMAIL), + ("fastmail.nl", &P_FASTMAIL), + ("fastmail.org", &P_FASTMAIL), + ("fastmail.se", &P_FASTMAIL), + ("fastmail.to", &P_FASTMAIL), + ("fastmail.tw", &P_FASTMAIL), + ("fastmail.uk", &P_FASTMAIL), + ("fastmail.us", &P_FASTMAIL), + ("fastmailbox.net", &P_FASTMAIL), + ("fastmessaging.com", &P_FASTMAIL), + ("fea.st", &P_FASTMAIL), + ("fmail.co.uk", &P_FASTMAIL), + ("fmailbox.com", &P_FASTMAIL), + ("fmgirl.com", &P_FASTMAIL), + ("fmguy.com", &P_FASTMAIL), + ("ftml.net", &P_FASTMAIL), + ("h-mail.us", &P_FASTMAIL), + ("hailmail.net", &P_FASTMAIL), + ("imap-mail.com", &P_FASTMAIL), + ("imap.cc", &P_FASTMAIL), + ("imapmail.org", &P_FASTMAIL), + ("inoutbox.com", &P_FASTMAIL), + ("internet-e-mail.com", &P_FASTMAIL), + ("internet-mail.org", &P_FASTMAIL), + ("internetemails.net", &P_FASTMAIL), + ("internetmailing.net", &P_FASTMAIL), + ("jetemail.net", &P_FASTMAIL), + ("justemail.net", &P_FASTMAIL), + ("letterboxes.org", &P_FASTMAIL), + ("mail-central.com", &P_FASTMAIL), + ("mail-page.com", &P_FASTMAIL), + ("mailandftp.com", &P_FASTMAIL), + ("mailas.com", &P_FASTMAIL), + ("mailbolt.com", &P_FASTMAIL), + ("mailc.net", &P_FASTMAIL), + ("mailcan.com", &P_FASTMAIL), + ("mailforce.net", &P_FASTMAIL), + ("mailftp.com", &P_FASTMAIL), + ("mailhaven.com", &P_FASTMAIL), + ("mailingaddress.org", &P_FASTMAIL), + ("mailite.com", &P_FASTMAIL), + ("mailmight.com", &P_FASTMAIL), + ("mailnew.com", &P_FASTMAIL), + ("mailsent.net", &P_FASTMAIL), + ("mailservice.ms", &P_FASTMAIL), + ("mailup.net", &P_FASTMAIL), + ("mailworks.org", &P_FASTMAIL), + ("ml1.net", &P_FASTMAIL), + ("mm.st", &P_FASTMAIL), + ("myfastmail.com", &P_FASTMAIL), + ("mymacmail.com", &P_FASTMAIL), + ("nospammail.net", &P_FASTMAIL), + ("ownmail.net", &P_FASTMAIL), + ("petml.com", &P_FASTMAIL), + ("postinbox.com", &P_FASTMAIL), + ("postpro.net", &P_FASTMAIL), + ("proinbox.com", &P_FASTMAIL), + ("promessage.com", &P_FASTMAIL), + ("realemail.net", &P_FASTMAIL), + ("reallyfast.biz", &P_FASTMAIL), + ("reallyfast.info", &P_FASTMAIL), + ("rushpost.com", &P_FASTMAIL), + ("sent.as", &P_FASTMAIL), + ("sent.at", &P_FASTMAIL), + ("sent.com", &P_FASTMAIL), + ("speedpost.net", &P_FASTMAIL), + ("speedymail.org", &P_FASTMAIL), + ("ssl-mail.com", &P_FASTMAIL), + ("swift-mail.com", &P_FASTMAIL), + ("the-fastest.net", &P_FASTMAIL), + ("the-quickest.com", &P_FASTMAIL), + ("theinternetemail.com", &P_FASTMAIL), + ("veryfast.biz", &P_FASTMAIL), + ("veryspeedy.net", &P_FASTMAIL), + ("warpmail.net", &P_FASTMAIL), + ("xsmail.com", &P_FASTMAIL), + ("yepmail.net", &P_FASTMAIL), + ("your-mail.com", &P_FASTMAIL), + ("firemail.at", &P_FIREMAIL_DE), + ("firemail.de", &P_FIREMAIL_DE), + ("five.chat", &P_FIVE_CHAT), + ("freenet.de", &P_FREENET_DE), + ("gmail.com", &P_GMAIL), + ("googlemail.com", &P_GMAIL), + ("google.com", &P_GMAIL), + ("gmx.net", &P_GMX_NET), + ("gmx.de", &P_GMX_NET), + ("gmx.at", &P_GMX_NET), + ("gmx.ch", &P_GMX_NET), + ("gmx.org", &P_GMX_NET), + ("gmx.eu", &P_GMX_NET), + ("gmx.info", &P_GMX_NET), + ("gmx.biz", &P_GMX_NET), + ("gmx.com", &P_GMX_NET), + ("ac.hermes.radio", &P_HERMES_RADIO), + ("ac1.hermes.radio", &P_HERMES_RADIO), + ("ac2.hermes.radio", &P_HERMES_RADIO), + ("ac3.hermes.radio", &P_HERMES_RADIO), + ("ac4.hermes.radio", &P_HERMES_RADIO), + ("ac5.hermes.radio", &P_HERMES_RADIO), + ("ac6.hermes.radio", &P_HERMES_RADIO), + ("ac7.hermes.radio", &P_HERMES_RADIO), + ("ac8.hermes.radio", &P_HERMES_RADIO), + ("ac9.hermes.radio", &P_HERMES_RADIO), + ("ac10.hermes.radio", &P_HERMES_RADIO), + ("ac11.hermes.radio", &P_HERMES_RADIO), + ("ac12.hermes.radio", &P_HERMES_RADIO), + ("ac13.hermes.radio", &P_HERMES_RADIO), + ("ac14.hermes.radio", &P_HERMES_RADIO), + ("ac15.hermes.radio", &P_HERMES_RADIO), + ("ka.hermes.radio", &P_HERMES_RADIO), + ("ka1.hermes.radio", &P_HERMES_RADIO), + ("ka2.hermes.radio", &P_HERMES_RADIO), + ("ka3.hermes.radio", &P_HERMES_RADIO), + ("ka4.hermes.radio", &P_HERMES_RADIO), + ("ka5.hermes.radio", &P_HERMES_RADIO), + ("ka6.hermes.radio", &P_HERMES_RADIO), + ("ka7.hermes.radio", &P_HERMES_RADIO), + ("ka8.hermes.radio", &P_HERMES_RADIO), + ("ka9.hermes.radio", &P_HERMES_RADIO), + ("ka10.hermes.radio", &P_HERMES_RADIO), + ("ka11.hermes.radio", &P_HERMES_RADIO), + ("ka12.hermes.radio", &P_HERMES_RADIO), + ("ka13.hermes.radio", &P_HERMES_RADIO), + ("ka14.hermes.radio", &P_HERMES_RADIO), + ("ka15.hermes.radio", &P_HERMES_RADIO), + ("ec.hermes.radio", &P_HERMES_RADIO), + ("ec1.hermes.radio", &P_HERMES_RADIO), + ("ec2.hermes.radio", &P_HERMES_RADIO), + ("ec3.hermes.radio", &P_HERMES_RADIO), + ("ec4.hermes.radio", &P_HERMES_RADIO), + ("ec5.hermes.radio", &P_HERMES_RADIO), + ("ec6.hermes.radio", &P_HERMES_RADIO), + ("ec7.hermes.radio", &P_HERMES_RADIO), + ("ec8.hermes.radio", &P_HERMES_RADIO), + ("ec9.hermes.radio", &P_HERMES_RADIO), + ("ec10.hermes.radio", &P_HERMES_RADIO), + ("ec11.hermes.radio", &P_HERMES_RADIO), + ("ec12.hermes.radio", &P_HERMES_RADIO), + ("ec13.hermes.radio", &P_HERMES_RADIO), + ("ec14.hermes.radio", &P_HERMES_RADIO), + ("ec15.hermes.radio", &P_HERMES_RADIO), + ("hermes.radio", &P_HERMES_RADIO), + ("hey.com", &P_HEY_COM), + ("i.ua", &P_I_UA), + ("i3.net", &P_I3_NET), + ("icloud.com", &P_ICLOUD), + ("me.com", &P_ICLOUD), + ("mac.com", &P_ICLOUD), + ("ik.me", &P_INFOMANIAK_COM), + ("kolst.com", &P_KOLST_COM), + ("kontent.com", &P_KONTENT_COM), + ("mail.de", &P_MAIL_DE), + ("mail.ru", &P_MAIL_RU), + ("inbox.ru", &P_MAIL_RU), + ("internet.ru", &P_MAIL_RU), + ("bk.ru", &P_MAIL_RU), + ("list.ru", &P_MAIL_RU), + ("mail2tor.com", &P_MAIL2TOR), + ("mailbox.org", &P_MAILBOX_ORG), + ("secure.mailbox.org", &P_MAILBOX_ORG), + ("mailo.com", &P_MAILO_COM), + ("nauta.cu", &P_NAUTA_CU), + ("naver.com", &P_NAVER), + ("nubo.coop", &P_NUBO_COOP), + ("hotmail.com", &P_OUTLOOK_COM), + ("outlook.com", &P_OUTLOOK_COM), + ("office365.com", &P_OUTLOOK_COM), + ("outlook.com.tr", &P_OUTLOOK_COM), + ("live.com", &P_OUTLOOK_COM), + ("outlook.de", &P_OUTLOOK_COM), + ("ouvaton.org", &P_OUVATON_COOP), + ("posteo.de", &P_POSTEO), + ("posteo.af", &P_POSTEO), + ("posteo.at", &P_POSTEO), + ("posteo.be", &P_POSTEO), + ("posteo.ca", &P_POSTEO), + ("posteo.ch", &P_POSTEO), + ("posteo.cl", &P_POSTEO), + ("posteo.co", &P_POSTEO), + ("posteo.co.uk", &P_POSTEO), + ("posteo.com.br", &P_POSTEO), + ("posteo.cr", &P_POSTEO), + ("posteo.cz", &P_POSTEO), + ("posteo.dk", &P_POSTEO), + ("posteo.ee", &P_POSTEO), + ("posteo.es", &P_POSTEO), + ("posteo.eu", &P_POSTEO), + ("posteo.fi", &P_POSTEO), + ("posteo.gl", &P_POSTEO), + ("posteo.gr", &P_POSTEO), + ("posteo.hn", &P_POSTEO), + ("posteo.hr", &P_POSTEO), + ("posteo.hu", &P_POSTEO), + ("posteo.ie", &P_POSTEO), + ("posteo.in", &P_POSTEO), + ("posteo.is", &P_POSTEO), + ("posteo.it", &P_POSTEO), + ("posteo.jp", &P_POSTEO), + ("posteo.la", &P_POSTEO), + ("posteo.li", &P_POSTEO), + ("posteo.lt", &P_POSTEO), + ("posteo.lu", &P_POSTEO), + ("posteo.me", &P_POSTEO), + ("posteo.mx", &P_POSTEO), + ("posteo.my", &P_POSTEO), + ("posteo.net", &P_POSTEO), + ("posteo.nl", &P_POSTEO), + ("posteo.no", &P_POSTEO), + ("posteo.nz", &P_POSTEO), + ("posteo.org", &P_POSTEO), + ("posteo.pe", &P_POSTEO), + ("posteo.pl", &P_POSTEO), + ("posteo.pm", &P_POSTEO), + ("posteo.pt", &P_POSTEO), + ("posteo.ro", &P_POSTEO), + ("posteo.ru", &P_POSTEO), + ("posteo.se", &P_POSTEO), + ("posteo.sg", &P_POSTEO), + ("posteo.si", &P_POSTEO), + ("posteo.tn", &P_POSTEO), + ("posteo.uk", &P_POSTEO), + ("posteo.us", &P_POSTEO), + ("protonmail.com", &P_PROTONMAIL), + ("protonmail.ch", &P_PROTONMAIL), + ("pm.me", &P_PROTONMAIL), + ("qq.com", &P_QQ), + ("foxmail.com", &P_QQ), + ("riseup.net", &P_RISEUP_NET), + ("rogers.com", &P_ROGERS_COM), + ("sonic.net", &P_SONIC), + ("systemausfall.org", &P_SYSTEMAUSFALL_ORG), + ("solidaris.me", &P_SYSTEMAUSFALL_ORG), + ("systemli.org", &P_SYSTEMLI_ORG), + ("t-online.de", &P_T_ONLINE), + ("magenta.de", &P_T_ONLINE), + ("testrun.org", &P_TESTRUN), + ("tiscali.it", &P_TISCALI_IT), + ("tutanota.com", &P_TUTANOTA), + ("tutanota.de", &P_TUTANOTA), + ("tutamail.com", &P_TUTANOTA), + ("tuta.io", &P_TUTANOTA), + ("keemail.me", &P_TUTANOTA), + ("ukr.net", &P_UKR_NET), + ("undernet.uy", &P_UNDERNET_UY), + ("vfemail.net", &P_VFEMAIL), + ("vivaldi.net", &P_VIVALDI), + ("vodafone.de", &P_VODAFONE_DE), + ("vodafonemail.de", &P_VODAFONE_DE), + ("web.de", &P_WEB_DE), + ("email.de", &P_WEB_DE), + ("flirt.ms", &P_WEB_DE), + ("hallo.ms", &P_WEB_DE), + ("kuss.ms", &P_WEB_DE), + ("love.ms", &P_WEB_DE), + ("magic.ms", &P_WEB_DE), + ("singles.ms", &P_WEB_DE), + ("cool.ms", &P_WEB_DE), + ("kanzler.ms", &P_WEB_DE), + ("okay.ms", &P_WEB_DE), + ("party.ms", &P_WEB_DE), + ("pop.ms", &P_WEB_DE), + ("stars.ms", &P_WEB_DE), + ("techno.ms", &P_WEB_DE), + ("clever.ms", &P_WEB_DE), + ("deutschland.ms", &P_WEB_DE), + ("genial.ms", &P_WEB_DE), + ("ich.ms", &P_WEB_DE), + ("online.ms", &P_WEB_DE), + ("smart.ms", &P_WEB_DE), + ("wichtig.ms", &P_WEB_DE), + ("action.ms", &P_WEB_DE), + ("fussball.ms", &P_WEB_DE), + ("joker.ms", &P_WEB_DE), + ("planet.ms", &P_WEB_DE), + ("power.ms", &P_WEB_DE), + ("yahoo.com", &P_YAHOO), + ("yahoo.de", &P_YAHOO), + ("yahoo.it", &P_YAHOO), + ("yahoo.fr", &P_YAHOO), + ("yahoo.es", &P_YAHOO), + ("yahoo.se", &P_YAHOO), + ("yahoo.co.uk", &P_YAHOO), + ("yahoo.co.nz", &P_YAHOO), + ("yahoo.com.au", &P_YAHOO), + ("yahoo.com.ar", &P_YAHOO), + ("yahoo.com.br", &P_YAHOO), + ("yahoo.com.mx", &P_YAHOO), + ("ymail.com", &P_YAHOO), + ("rocketmail.com", &P_YAHOO), + ("yahoodns.net", &P_YAHOO), + ("yandex.com", &P_YANDEX_RU), + ("yandex.by", &P_YANDEX_RU), + ("yandex.kz", &P_YANDEX_RU), + ("yandex.ru", &P_YANDEX_RU), + ("yandex.ua", &P_YANDEX_RU), + ("ya.ru", &P_YANDEX_RU), + ("narod.ru", &P_YANDEX_RU), + ("yggmail", &P_YGGMAIL), + ("ziggo.nl", &P_ZIGGO_NL), + ("zohomail.eu", &P_ZOHO), + ("zohomail.com", &P_ZOHO), + ("zoho.com", &P_ZOHO), ]) }); pub(crate) static PROVIDER_IDS: Lazy> = Lazy::new(|| { HashMap::from([ - ("163", &*P_163), - ("aktivix.org", &*P_AKTIVIX_ORG), - ("aol", &*P_AOL), - ("arcor.de", &*P_ARCOR_DE), - ("autistici.org", &*P_AUTISTICI_ORG), - ("blindzeln.org", &*P_BLINDZELN_ORG), - ("bluewin.ch", &*P_BLUEWIN_CH), - ("buzon.uy", &*P_BUZON_UY), - ("chello.at", &*P_CHELLO_AT), - ("comcast", &*P_COMCAST), - ("dismail.de", &*P_DISMAIL_DE), - ("disroot", &*P_DISROOT), - ("e.email", &*P_E_EMAIL), - ("espiv.net", &*P_ESPIV_NET), - ("example.com", &*P_EXAMPLE_COM), - ("fastmail", &*P_FASTMAIL), - ("firemail.de", &*P_FIREMAIL_DE), - ("five.chat", &*P_FIVE_CHAT), - ("freenet.de", &*P_FREENET_DE), - ("gmail", &*P_GMAIL), - ("gmx.net", &*P_GMX_NET), - ("hermes.radio", &*P_HERMES_RADIO), - ("hey.com", &*P_HEY_COM), - ("i.ua", &*P_I_UA), - ("i3.net", &*P_I3_NET), - ("icloud", &*P_ICLOUD), - ("infomaniak.com", &*P_INFOMANIAK_COM), - ("kolst.com", &*P_KOLST_COM), - ("kontent.com", &*P_KONTENT_COM), - ("mail.de", &*P_MAIL_DE), - ("mail.ru", &*P_MAIL_RU), - ("mail2tor", &*P_MAIL2TOR), - ("mailbox.org", &*P_MAILBOX_ORG), - ("mailo.com", &*P_MAILO_COM), - ("nauta.cu", &*P_NAUTA_CU), - ("naver", &*P_NAVER), - ("nubo.coop", &*P_NUBO_COOP), - ("outlook.com", &*P_OUTLOOK_COM), - ("ouvaton.coop", &*P_OUVATON_COOP), - ("posteo", &*P_POSTEO), - ("protonmail", &*P_PROTONMAIL), - ("qq", &*P_QQ), - ("riseup.net", &*P_RISEUP_NET), - ("rogers.com", &*P_ROGERS_COM), - ("sonic", &*P_SONIC), - ("systemausfall.org", &*P_SYSTEMAUSFALL_ORG), - ("systemli.org", &*P_SYSTEMLI_ORG), - ("t-online", &*P_T_ONLINE), - ("testrun", &*P_TESTRUN), - ("tiscali.it", &*P_TISCALI_IT), - ("tutanota", &*P_TUTANOTA), - ("ukr.net", &*P_UKR_NET), - ("undernet.uy", &*P_UNDERNET_UY), - ("vfemail", &*P_VFEMAIL), - ("vivaldi", &*P_VIVALDI), - ("vodafone.de", &*P_VODAFONE_DE), - ("web.de", &*P_WEB_DE), - ("yahoo", &*P_YAHOO), - ("yandex.ru", &*P_YANDEX_RU), - ("yggmail", &*P_YGGMAIL), - ("ziggo.nl", &*P_ZIGGO_NL), - ("zoho", &*P_ZOHO), + ("163", &P_163), + ("aktivix.org", &P_AKTIVIX_ORG), + ("aol", &P_AOL), + ("arcor.de", &P_ARCOR_DE), + ("autistici.org", &P_AUTISTICI_ORG), + ("blindzeln.org", &P_BLINDZELN_ORG), + ("bluewin.ch", &P_BLUEWIN_CH), + ("buzon.uy", &P_BUZON_UY), + ("chello.at", &P_CHELLO_AT), + ("comcast", &P_COMCAST), + ("dismail.de", &P_DISMAIL_DE), + ("disroot", &P_DISROOT), + ("e.email", &P_E_EMAIL), + ("espiv.net", &P_ESPIV_NET), + ("example.com", &P_EXAMPLE_COM), + ("fastmail", &P_FASTMAIL), + ("firemail.de", &P_FIREMAIL_DE), + ("five.chat", &P_FIVE_CHAT), + ("freenet.de", &P_FREENET_DE), + ("gmail", &P_GMAIL), + ("gmx.net", &P_GMX_NET), + ("hermes.radio", &P_HERMES_RADIO), + ("hey.com", &P_HEY_COM), + ("i.ua", &P_I_UA), + ("i3.net", &P_I3_NET), + ("icloud", &P_ICLOUD), + ("infomaniak.com", &P_INFOMANIAK_COM), + ("kolst.com", &P_KOLST_COM), + ("kontent.com", &P_KONTENT_COM), + ("mail.de", &P_MAIL_DE), + ("mail.ru", &P_MAIL_RU), + ("mail2tor", &P_MAIL2TOR), + ("mailbox.org", &P_MAILBOX_ORG), + ("mailo.com", &P_MAILO_COM), + ("nauta.cu", &P_NAUTA_CU), + ("naver", &P_NAVER), + ("nubo.coop", &P_NUBO_COOP), + ("outlook.com", &P_OUTLOOK_COM), + ("ouvaton.coop", &P_OUVATON_COOP), + ("posteo", &P_POSTEO), + ("protonmail", &P_PROTONMAIL), + ("qq", &P_QQ), + ("riseup.net", &P_RISEUP_NET), + ("rogers.com", &P_ROGERS_COM), + ("sonic", &P_SONIC), + ("systemausfall.org", &P_SYSTEMAUSFALL_ORG), + ("systemli.org", &P_SYSTEMLI_ORG), + ("t-online", &P_T_ONLINE), + ("testrun", &P_TESTRUN), + ("tiscali.it", &P_TISCALI_IT), + ("tutanota", &P_TUTANOTA), + ("ukr.net", &P_UKR_NET), + ("undernet.uy", &P_UNDERNET_UY), + ("vfemail", &P_VFEMAIL), + ("vivaldi", &P_VIVALDI), + ("vodafone.de", &P_VODAFONE_DE), + ("web.de", &P_WEB_DE), + ("yahoo", &P_YAHOO), + ("yandex.ru", &P_YANDEX_RU), + ("yggmail", &P_YGGMAIL), + ("ziggo.nl", &P_ZIGGO_NL), + ("zoho", &P_ZOHO), ]) }); diff --git a/src/smtp.rs b/src/smtp.rs index 5195826a0..457023623 100644 --- a/src/smtp.rs +++ b/src/smtp.rs @@ -493,7 +493,20 @@ pub(crate) async fn smtp_send( if let SendResult::Failure(err) = &status { // We couldn't send the message, so mark it as failed - message::set_msg_failed(context, msg_id, &err.to_string()).await; + match Message::load_from_db(context, msg_id).await { + Ok(mut msg) => { + if let Err(err) = message::set_msg_failed(context, &mut msg, &err.to_string()).await + { + error!(context, "Failed to mark {msg_id} as failed: {err:#}."); + } + } + Err(err) => { + error!( + context, + "Failed to load {msg_id} to mark it as failed: {err:#}." + ); + } + } } status } @@ -540,7 +553,8 @@ pub(crate) async fn send_msg_to_smtp( ) .await?; if retries > 6 { - message::set_msg_failed(context, msg_id, "Number of retries exceeded the limit.").await; + let mut msg = Message::load_from_db(context, msg_id).await?; + message::set_msg_failed(context, &mut msg, "Number of retries exceeded the limit.").await?; context .sql .execute("DELETE FROM smtp WHERE id=?", (rowid,)) diff --git a/src/sql.rs b/src/sql.rs index 90549dd4b..ab780a452 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -304,6 +304,20 @@ impl Sql { } } + /// Changes the passphrase of encrypted database. + /// + /// The database must already be encrypted and the passphrase cannot be empty. + /// It is impossible to turn encrypted database into unencrypted + /// and vice versa this way, use import/export for this. + pub async fn change_passphrase(&self, passphrase: String) -> Result<()> { + self.call_write(move |conn| { + conn.pragma_update(None, "rekey", passphrase) + .context("failed to set PRAGMA rekey")?; + Ok(()) + }) + .await + } + /// Locks the write transactions mutex in order to make sure that there never are /// multiple write transactions at once. /// @@ -1246,6 +1260,49 @@ mod tests { sql.open(&t, "foo".to_string()) .await .context("failed to open the database second time")?; + + Ok(()) + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_change_passphrase() -> Result<()> { + use tempfile::tempdir; + + // The context is used only for logging. + let t = TestContext::new().await; + + // Create a separate empty database for testing. + let dir = tempdir()?; + let dbfile = dir.path().join("testdb.sqlite"); + let sql = Sql::new(dbfile.clone()); + + sql.open(&t, "foo".to_string()) + .await + .context("failed to open the database first time")?; + sql.close().await; + + // Change the passphrase from "foo" to "bar". + let sql = Sql::new(dbfile.clone()); + sql.open(&t, "foo".to_string()) + .await + .context("failed to open the database second time")?; + sql.change_passphrase("bar".to_string()) + .await + .context("failed to change passphrase")?; + sql.close().await; + + let sql = Sql::new(dbfile); + + // Test that old passphrase is not working. + assert!(sql.open(&t, "foo".to_string()).await.is_err()); + + // Open the database with the new passphrase. + sql.check_passphrase("bar".to_string()).await?; + sql.open(&t, "bar".to_string()) + .await + .context("failed to open the database third time")?; + sql.close().await; + Ok(()) } } diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index 7a6e1f2a3..b358adb84 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -516,7 +516,8 @@ DO UPDATE SET rfc724_mid=excluded.rfc724_mid, id INTEGER PRIMARY KEY AUTOINCREMENT, msg_id INTEGER, update_item TEXT DEFAULT '', -update_item_read INTEGER DEFAULT 0); +update_item_read INTEGER DEFAULT 0 -- XXX unused +); CREATE INDEX msgs_status_updates_index1 ON msgs_status_updates (msg_id);"#, 84, ) diff --git a/src/tools.rs b/src/tools.rs index b0ba5d6f7..43dd51f01 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -323,17 +323,16 @@ pub fn get_filemeta(buf: &[u8]) -> Result<(u32, u32)> { /// /// If `path` starts with "$BLOBDIR", replaces it with the blobdir path. /// Otherwise, returns path as is. -pub(crate) fn get_abs_path(context: &Context, path: impl AsRef) -> PathBuf { - let p: &Path = path.as_ref(); - if let Ok(p) = p.strip_prefix("$BLOBDIR") { +pub(crate) fn get_abs_path(context: &Context, path: &Path) -> PathBuf { + if let Ok(p) = path.strip_prefix("$BLOBDIR") { context.get_blobdir().join(p) } else { - p.into() + path.into() } } pub(crate) async fn get_filebytes(context: &Context, path: impl AsRef) -> Result { - let path_abs = get_abs_path(context, &path); + let path_abs = get_abs_path(context, path.as_ref()); let meta = fs::metadata(&path_abs).await?; Ok(meta.len()) } @@ -377,7 +376,7 @@ pub(crate) async fn create_folder( context: &Context, path: impl AsRef, ) -> Result<(), io::Error> { - let path_abs = get_abs_path(context, &path); + let path_abs = get_abs_path(context, path.as_ref()); if !path_abs.exists() { match fs::create_dir_all(path_abs).await { Ok(_) => Ok(()), @@ -402,7 +401,7 @@ pub(crate) async fn write_file( path: impl AsRef, buf: &[u8], ) -> Result<(), io::Error> { - let path_abs = get_abs_path(context, &path); + let path_abs = get_abs_path(context, path.as_ref()); fs::write(&path_abs, buf).await.map_err(|err| { warn!( context, @@ -417,7 +416,7 @@ pub(crate) async fn write_file( /// Reads the file and returns its context as a byte vector. pub async fn read_file(context: &Context, path: impl AsRef) -> Result> { - let path_abs = get_abs_path(context, &path); + let path_abs = get_abs_path(context, path.as_ref()); match fs::read(&path_abs).await { Ok(bytes) => Ok(bytes), @@ -434,7 +433,7 @@ pub async fn read_file(context: &Context, path: impl AsRef) -> Result) -> Result { - let path_abs = get_abs_path(context, &path); + let path_abs = get_abs_path(context, path.as_ref()); match fs::File::open(&path_abs).await { Ok(bytes) => Ok(bytes), @@ -450,12 +449,8 @@ pub async fn open_file(context: &Context, path: impl AsRef) -> Result>( - context: &Context, - path: P, -) -> Result { - let p: PathBuf = path.as_ref().into(); - let path_abs = get_abs_path(context, p); +pub fn open_file_std(context: &Context, path: impl AsRef) -> Result { + let path_abs = get_abs_path(context, path.as_ref()); match std::fs::File::open(path_abs) { Ok(bytes) => Ok(bytes), @@ -540,6 +535,9 @@ impl EmailAddress { if domain.is_empty() { bail!("missing domain after '@' in {:?}", input); } + if domain.ends_with('.') { + bail!("Domain {domain:?} should not contain the dot in the end"); + } Ok(EmailAddress { local: (*local).to_string(), domain: (*domain).to_string(), @@ -1001,7 +999,7 @@ DKIM Results: Passed=true, Works=true, Allow_Keychange=true"; assert_eq!(EmailAddress::new("dd.tt").is_ok(), false); assert!(EmailAddress::new("tt.dd@uu").is_ok()); assert!(EmailAddress::new("u@d").is_ok()); - assert!(EmailAddress::new("u@d.").is_ok()); + assert!(EmailAddress::new("u@d.").is_err()); assert!(EmailAddress::new("u@d.t").is_ok()); assert_eq!( EmailAddress::new("u@d.tt").unwrap(), diff --git a/src/webxdc.rs b/src/webxdc.rs index a47f3d8e0..3b00028fd 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -1,4 +1,18 @@ //! # Handle webxdc messages. +//! +//! Internally status updates are stored in the `msgs_status_updates` SQL table. +//! `msgs_status_updates` contains the following columns: +//! - `id` - status update serial number +//! - `msg_id` - ID of the message in the `msgs` table +//! - `update_item` - JSON representation of the status update +//! +//! Status updates are scheduled for sending by adding a record +//! to `smtp_status_updates_table` SQL table. +//! `smtp_status_updates` contains the following columns: +//! - `msg_id` - ID of the message in the `msgs` table +//! - `first_serial` - serial number of the first status update to send +//! - `last_serial` - serial number of the last status update to send +//! - `descr` - text to send along with the updates use std::convert::TryFrom; use std::path::Path; @@ -665,6 +679,10 @@ impl Context { /// /// Example: `{"updates": [{"payload":"any update data"}, /// {"payload":"another update data"}]}` + /// + /// `range` is an optional range of status update serials to send. + /// If it is `None`, all updates are sent. + /// This is used when a message is resent using [`crate::chat::resend_msgs`]. pub(crate) async fn render_webxdc_status_update_object( &self, instance_msg_id: MsgId, @@ -895,10 +913,8 @@ mod tests { } async fn create_webxdc_instance(t: &TestContext, name: &str, bytes: &[u8]) -> Result { - let file = t.get_blobdir().join(name); - tokio::fs::write(&file, bytes).await?; let mut instance = Message::new(Viewtype::File); - instance.set_file(file.to_str().unwrap(), None); + instance.set_file_from_bytes(t, name, bytes, None).await?; Ok(instance) } @@ -926,10 +942,10 @@ mod tests { assert_eq!(instance.chat_id, chat_id); // sending using bad extension is not working, even when setting Viewtype to webxdc - let file = t.get_blobdir().join("index.html"); - tokio::fs::write(&file, b"ola!").await?; let mut instance = Message::new(Viewtype::Webxdc); - instance.set_file(file.to_str().unwrap(), None); + instance + .set_file_from_bytes(&t, "index.html", b"ola!", None) + .await?; assert!(send_msg(&t, chat_id, &mut instance).await.is_err()); Ok(()) @@ -953,14 +969,15 @@ mod tests { assert_eq!(test.viewtype, Viewtype::File); // sending invalid .xdc as Viewtype::Webxdc should fail already on sending - let file = t.get_blobdir().join("invalid2.xdc"); - tokio::fs::write( - &file, - include_bytes!("../test-data/webxdc/invalid-no-zip-but-7z.xdc"), - ) - .await?; let mut instance = Message::new(Viewtype::Webxdc); - instance.set_file(file.to_str().unwrap(), None); + instance + .set_file_from_bytes( + &t, + "invalid2.xdc", + include_bytes!("../test-data/webxdc/invalid-no-zip-but-7z.xdc"), + None, + ) + .await?; assert!(send_msg(&t, chat_id, &mut instance).await.is_err()); Ok(())