diff --git a/Cargo.lock b/Cargo.lock index 6e9bae001..cca6100c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -124,43 +124,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" [[package]] name = "arrayref" @@ -206,7 +206,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -266,7 +266,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -277,7 +277,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -305,7 +305,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -562,9 +562,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -766,7 +766,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -856,9 +856,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "colored" @@ -1082,7 +1082,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -1118,7 +1118,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -1142,7 +1142,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -1153,7 +1153,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -1194,28 +1194,19 @@ dependencies = [ [[package]] name = "derive_more" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "1.0.0" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] name = "diesel" -version = "2.2.4" -source = "git+https://github.com/diesel-rs/diesel?branch=master#73a9d3eb29c946f052a9da5bf4e9636f4261df84" +version = "2.2.0" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "diesel_derives", "downcast-rs", @@ -1245,19 +1236,19 @@ dependencies = [ [[package]] name = "diesel_derives" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#73a9d3eb29c946f052a9da5bf4e9636f4261df84" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "diesel_table_macro_syntax", "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] name = "diesel_migrations" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#73a9d3eb29c946f052a9da5bf4e9636f4261df84" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "diesel", "migrations_internals", @@ -1267,9 +1258,9 @@ dependencies = [ [[package]] name = "diesel_table_macro_syntax" version = "0.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#73a9d3eb29c946f052a9da5bf4e9636f4261df84" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -1350,14 +1341,14 @@ checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dsl_auto_type" version = "0.1.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#73a9d3eb29c946f052a9da5bf4e9636f4261df84" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "darling", "either", "heck", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -1489,9 +1480,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.35" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -1676,7 +1667,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.85", + "syn 2.0.82", "toml 0.8.19", "walkdir", ] @@ -1694,7 +1685,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -1720,7 +1711,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.85", + "syn 2.0.82", "tempfile", "thiserror", "tiny-keccak", @@ -2087,7 +2078,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -3160,7 +3151,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "migrations_internals" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#73a9d3eb29c946f052a9da5bf4e9636f4261df84" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "serde", "toml 0.8.19", @@ -3169,7 +3160,7 @@ dependencies = [ [[package]] name = "migrations_macros" version = "2.2.0" -source = "git+https://github.com/diesel-rs/diesel?branch=master#73a9d3eb29c946f052a9da5bf4e9636f4261df84" +source = "git+https://github.com/diesel-rs/diesel?branch=master#b170af753cc3c6774f578aae1081711a09dfa2ac" dependencies = [ "migrations_internals", "proc-macro2", @@ -3194,9 +3185,9 @@ dependencies = [ [[package]] name = "minicov" -version = "0.3.6" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def6d99771d7c499c26ad4d40eb6645eafd3a1553b35fc26ea5a489a45e82d9a" +checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169" dependencies = [ "cc", "walkdir", @@ -3289,7 +3280,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -3371,7 +3362,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -3386,7 +3377,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -3504,7 +3495,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -3661,7 +3652,7 @@ dependencies = [ "quote", "rstest", "rstest_reuse", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -3675,9 +3666,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -3696,7 +3687,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -3707,18 +3698,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.4.0+3.4.0" +version = "300.3.2+3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" +checksum = "a211a18d945ef7e648cc6e0058f4c548ee46aab922ea203e0d30e966ea23647b" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -3997,7 +3988,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -4020,29 +4011,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -4188,12 +4179,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" dependencies = [ "proc-macro2", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -4230,9 +4221,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -4280,7 +4271,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.85", + "syn 2.0.82", "tempfile", ] @@ -4294,7 +4285,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -4422,9 +4413,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -4824,9 +4815,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.5" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aa7ffc1c0ef49b0452c6e2986abf2b07743320641ffd5fc63d552458e3b779b" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", "derive_more", @@ -4836,14 +4827,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.5" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46385cc24172cf615450267463f937c10072516359b3ff1cb24228a4a08bf951" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.85", + "syn 1.0.109", ] [[package]] @@ -4893,7 +4884,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -4992,9 +4983,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.213" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -5012,13 +5003,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -5293,7 +5284,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -5413,9 +5404,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -5535,22 +5526,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -5669,14 +5660,14 @@ checksum = "8d9ef545650e79f30233c0003bcc2504d7efac6dad25fca40744de773fe2049c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] name = "tokio" -version = "1.41.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -5699,7 +5690,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -5930,7 +5921,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -6010,7 +6001,7 @@ checksum = "70977707304198400eb4835a78f6a9f928bf41bba420deb8fdb175cd965d77a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -6190,7 +6181,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2c801f0f05b06df456a2da4c41b9c2c4fdccc6b9916643c6c67275c4c9e4d07" dependencies = [ "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -6221,7 +6212,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.85", + "syn 2.0.82", "toml 0.5.11", "uniffi_meta", ] @@ -6338,9 +6329,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" +checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" dependencies = [ "value-bag-serde1", "value-bag-sval2", @@ -6348,9 +6339,9 @@ dependencies = [ [[package]] name = "value-bag-serde1" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb773bd36fd59c7ca6e336c94454d9c66386416734817927ac93d81cb3c5b0b" +checksum = "ccacf50c5cb077a9abb723c5bcb5e0754c1a433f1e1de89edc328e2760b6328b" dependencies = [ "erased-serde", "serde", @@ -6359,9 +6350,9 @@ dependencies = [ [[package]] name = "value-bag-sval2" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a916a702cac43a88694c97657d449775667bcd14b70419441d05b7fea4a83a" +checksum = "1785bae486022dfb9703915d42287dcb284c1ee37bd1080eeba78cc04721285b" dependencies = [ "sval", "sval_buffer", @@ -6475,7 +6466,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", "wasm-bindgen-shared", ] @@ -6509,7 +6500,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6543,7 +6534,7 @@ checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -7192,7 +7183,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] @@ -7212,7 +7203,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.82", ] [[package]] diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 57ec0cf5a..78df78ad3 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -21,7 +21,7 @@ use xmtp_mls::storage::group_message::SortDirection; use xmtp_mls::{ api::ApiClientWrapper, builder::ClientBuilder, - client::{Client as MlsClient, ClientError, FindGroupParams}, + client::{Client as MlsClient, ClientError}, groups::{ group_metadata::{ConversationType, GroupMetadata}, group_mutable_metadata::MetadataField, @@ -38,12 +38,12 @@ use xmtp_mls::{ retry::Retry, storage::{ consent_record::{ConsentState, ConsentType, StoredConsentRecord}, + group::GroupQueryArgs, group_message::{DeliveryStatus, GroupMessageKind, StoredGroupMessage}, EncryptedMessageStore, EncryptionKey, StorageOption, }, AbortHandle, GenericStreamHandle, StreamHandle, }; - pub type RustXmtpClient = MlsClient; /// It returns a new client of the specified `inbox_id`. @@ -529,6 +529,17 @@ pub struct FfiListConversationsOptions { pub created_after_ns: Option, pub created_before_ns: Option, pub limit: Option, + pub consent_state: Option, +} + +impl From for GroupQueryArgs { + fn from(opts: FfiListConversationsOptions) -> GroupQueryArgs { + GroupQueryArgs::default() + .maybe_created_before_ns(opts.created_before_ns) + .maybe_created_after_ns(opts.created_after_ns) + .maybe_limit(opts.limit) + .maybe_consent_state(opts.consent_state.map(Into::into)) + } } #[derive(uniffi::Object)] @@ -837,10 +848,7 @@ impl FfiConversations { pub async fn sync_all_conversations(&self) -> Result { let inner = self.inner_client.as_ref(); - let groups = inner.find_groups(FindGroupParams { - conversation_type: None, - ..FindGroupParams::default() - })?; + let groups = inner.find_groups(GroupQueryArgs::default())?; log::info!( "groups for client inbox id {:?}: {:?}", @@ -862,13 +870,7 @@ impl FfiConversations { ) -> Result>, GenericError> { let inner = self.inner_client.as_ref(); let convo_list: Vec> = inner - .find_groups(FindGroupParams { - allowed_states: None, - created_after_ns: opts.created_after_ns, - created_before_ns: opts.created_before_ns, - limit: opts.limit, - conversation_type: None, - })? + .find_groups(opts.into())? .into_iter() .map(|group| Arc::new(group.into())) .collect(); @@ -882,13 +884,7 @@ impl FfiConversations { ) -> Result>, GenericError> { let inner = self.inner_client.as_ref(); let convo_list: Vec> = inner - .find_groups(FindGroupParams { - allowed_states: None, - created_after_ns: opts.created_after_ns, - created_before_ns: opts.created_before_ns, - limit: opts.limit, - conversation_type: Some(ConversationType::Group), - })? + .find_groups(GroupQueryArgs::from(opts).conversation_type(ConversationType::Group))? .into_iter() .map(|group| Arc::new(group.into())) .collect(); @@ -902,13 +898,7 @@ impl FfiConversations { ) -> Result>, GenericError> { let inner = self.inner_client.as_ref(); let convo_list: Vec> = inner - .find_groups(FindGroupParams { - allowed_states: None, - created_after_ns: opts.created_after_ns, - created_before_ns: opts.created_before_ns, - limit: opts.limit, - conversation_type: Some(ConversationType::Dm), - })? + .find_groups(GroupQueryArgs::from(opts).conversation_type(ConversationType::Dm))? .into_iter() .map(|group| Arc::new(group.into())) .collect(); diff --git a/bindings_node/src/conversations.rs b/bindings_node/src/conversations.rs index 3e5db4806..56bb8d0e8 100644 --- a/bindings_node/src/conversations.rs +++ b/bindings_node/src/conversations.rs @@ -6,10 +6,10 @@ use napi::bindgen_prelude::{Error, Result, Uint8Array}; use napi::threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode}; use napi::JsFunction; use napi_derive::napi; -use xmtp_mls::client::FindGroupParams; use xmtp_mls::groups::group_metadata::ConversationType; use xmtp_mls::groups::{GroupMetadataOptions, PreconfiguredPolicies}; use xmtp_mls::storage::group::GroupMembershipState; +use xmtp_mls::storage::group::GroupQueryArgs; use crate::messages::NapiMessage; use crate::permissions::NapiGroupPermissionsOptions; @@ -82,17 +82,18 @@ pub struct NapiListConversationsOptions { pub conversation_type: Option, } -impl From for FindGroupParams { - fn from(opts: NapiListConversationsOptions) -> Self { - FindGroupParams { - allowed_states: opts - .allowed_states - .map(|states| states.into_iter().map(From::from).collect()), - conversation_type: opts.conversation_type.map(|ct| ct.into()), - created_after_ns: opts.created_after_ns, - created_before_ns: opts.created_before_ns, - limit: opts.limit, - } +impl From for GroupQueryArgs { + fn from(opts: NapiListConversationsOptions) -> GroupQueryArgs { + GroupQueryArgs::default() + .maybe_allowed_states( + opts + .allowed_states + .map(|states| states.into_iter().map(From::from).collect()), + ) + .maybe_conversation_type(opts.conversation_type.map(|ct| ct.into())) + .maybe_created_after_ns(opts.created_after_ns) + .maybe_created_before_ns(opts.created_before_ns) + .maybe_limit(opts.limit) } } diff --git a/bindings_wasm/src/conversations.rs b/bindings_wasm/src/conversations.rs index 55da820a0..ecb1240a4 100644 --- a/bindings_wasm/src/conversations.rs +++ b/bindings_wasm/src/conversations.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::{JsError, JsValue}; -use xmtp_mls::client::FindGroupParams; use xmtp_mls::groups::{GroupMetadataOptions, PreconfiguredPolicies}; +use xmtp_mls::storage::group::GroupQueryArgs; use crate::messages::WasmMessage; use crate::permissions::WasmGroupPermissionsOptions; @@ -15,6 +15,20 @@ pub struct WasmListConversationsOptions { pub limit: Option, } +impl From for GroupQueryArgs { + fn from(opts: WasmListConversationsOptions) -> GroupQueryArgs { + let WasmListConversationsOptions { + created_after_ns, + created_before_ns, + limit, + } = opts; + GroupQueryArgs::default() + .maybe_created_after_ns(created_after_ns) + .maybe_created_before_ns(created_before_ns) + .maybe_limit(limit) + } +} + #[wasm_bindgen] impl WasmListConversationsOptions { #[wasm_bindgen(constructor)] @@ -195,12 +209,7 @@ impl WasmConversations { }; let convo_list: js_sys::Array = self .inner_client - .find_groups(FindGroupParams { - created_after_ns: opts.created_after_ns, - created_before_ns: opts.created_before_ns, - limit: opts.limit, - ..FindGroupParams::default() - }) + .find_groups(opts.into()) .map_err(|e| JsError::new(format!("{}", e).as_str()))? .into_iter() .map(|group| { diff --git a/examples/cli/cli-client.rs b/examples/cli/cli-client.rs index 4cb059a31..09b6dca56 100755 --- a/examples/cli/cli-client.rs +++ b/examples/cli/cli-client.rs @@ -20,9 +20,8 @@ use kv_log_macro::{error, info}; use prost::Message; use xmtp_api_grpc::replication_client::ClientV4; use xmtp_id::associations::unverified::{UnverifiedRecoverableEcdsaSignature, UnverifiedSignature}; -use xmtp_mls::client::FindGroupParams; - use xmtp_mls::groups::device_sync::DeviceSyncContent; +use xmtp_mls::storage::group::GroupQueryArgs; use xmtp_mls::storage::group_message::{GroupMessageKind, MsgQueryArgs}; use xmtp_mls::XmtpApi; @@ -238,7 +237,7 @@ async fn main() { // recv(&client).await.unwrap(); let group_list = client - .find_groups(FindGroupParams::default()) + .find_groups(GroupQueryArgs::default()) .expect("failed to list groups"); for group in group_list.iter() { group.sync().await.expect("error syncing group"); diff --git a/xmtp_mls/src/client.rs b/xmtp_mls/src/client.rs index 525a7aef9..ebf5f369d 100644 --- a/xmtp_mls/src/client.rs +++ b/xmtp_mls/src/client.rs @@ -38,9 +38,8 @@ use xmtp_proto::xmtp::mls::api::v1::{ use crate::{ api::ApiClientWrapper, groups::{ - group_metadata::ConversationType, group_permissions::PolicySet, - validated_commit::CommitValidationError, GroupError, GroupMetadataOptions, IntentError, - MlsGroup, + group_permissions::PolicySet, validated_commit::CommitValidationError, GroupError, + GroupMetadataOptions, IntentError, MlsGroup, }, identity::{parse_credential, Identity, IdentityError}, identity_updates::{load_identity_updates, IdentityUpdateError}, @@ -48,6 +47,7 @@ use crate::{ mutex_registry::MutexRegistry, retry::Retry, retry_async, retryable, + storage::group::GroupQueryArgs, storage::{ consent_record::{ConsentState, ConsentType, StoredConsentRecord}, db_connection::DbConnection, @@ -217,15 +217,6 @@ impl From<&str> for ClientError { } } -#[derive(Debug, Default)] -pub struct FindGroupParams { - pub allowed_states: Option>, - pub created_after_ns: Option, - pub created_before_ns: Option, - pub limit: Option, - pub conversation_type: Option, -} - /// Clients manage access to the network, identity, and data store pub struct Client> { pub(crate) api_client: Arc>, @@ -671,17 +662,11 @@ where /// - created_after_ns: only return groups created after the given timestamp (in nanoseconds) /// - created_before_ns: only return groups created before the given timestamp (in nanoseconds) /// - limit: only return the first `limit` groups - pub fn find_groups(&self, params: FindGroupParams) -> Result>, ClientError> { + pub fn find_groups(&self, args: GroupQueryArgs) -> Result>, ClientError> { Ok(self .store() .conn()? - .find_groups( - params.allowed_states, - params.created_after_ns, - params.created_before_ns, - params.limit, - params.conversation_type, - )? + .find_groups(args)? .into_iter() .map(|stored_group| { MlsGroup::new(self.clone(), stored_group.id, stored_group.created_at_ns) @@ -972,12 +957,12 @@ pub(crate) mod tests { use crate::{ builder::ClientBuilder, - client::FindGroupParams, groups::GroupMetadataOptions, hpke::{decrypt_welcome, encrypt_welcome}, identity::serialize_key_package_hash_ref, storage::{ consent_record::{ConsentState, ConsentType, StoredConsentRecord}, + group::GroupQueryArgs, group_message::MsgQueryArgs, schema::identity_updates, }, @@ -1082,7 +1067,7 @@ pub(crate) mod tests { .create_group(None, GroupMetadataOptions::default()) .unwrap(); - let groups = client.find_groups(FindGroupParams::default()).unwrap(); + let groups = client.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(groups.len(), 2); assert_eq!(groups[0].group_id, group_1.group_id); assert_eq!(groups[1].group_id, group_2.group_id); @@ -1163,7 +1148,7 @@ pub(crate) mod tests { let bob_received_groups = bo.sync_welcomes(&bo.store().conn().unwrap()).await.unwrap(); assert_eq!(bob_received_groups.len(), 2); - let bo_groups = bo.find_groups(FindGroupParams::default()).unwrap(); + let bo_groups = bo.find_groups(GroupQueryArgs::default()).unwrap(); let bo_group1 = bo.group(alix_bo_group1.clone().group_id).unwrap(); let bo_messages1 = bo_group1.find_messages(&MsgQueryArgs::default()).unwrap(); assert_eq!(bo_messages1.len(), 0); @@ -1239,7 +1224,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(Default::default()).unwrap(); assert_eq!(bola_groups.len(), 1); let bola_group = bola_groups.first().unwrap(); tracing::info!("Syncing bolas messages"); @@ -1377,7 +1362,7 @@ pub(crate) mod tests { bo.sync_welcomes(&bo.store().conn().unwrap()).await.unwrap(); // Bo should have two groups now - let bo_groups = bo.find_groups(FindGroupParams::default()).unwrap(); + let bo_groups = bo.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(bo_groups.len(), 2); // Bo's original key should be deleted diff --git a/xmtp_mls/src/groups/device_sync.rs b/xmtp_mls/src/groups/device_sync.rs index 09bed12fd..d5426b1d7 100644 --- a/xmtp_mls/src/groups/device_sync.rs +++ b/xmtp_mls/src/groups/device_sync.rs @@ -1,6 +1,7 @@ use super::group_metadata::ConversationType; use super::{GroupError, MlsGroup}; use crate::configuration::NS_IN_HOUR; +use crate::storage::group::GroupQueryArgs; use crate::storage::group_message::MsgQueryArgs; use crate::storage::DbConnection; use crate::utils::time::now_ns; @@ -289,7 +290,8 @@ where self.sync_welcomes(provider.conn_ref()).await?; - let groups = conn.find_groups(None, None, None, None, Some(ConversationType::Group))?; + let groups = + conn.find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))?; for crate::storage::group::StoredGroup { id, .. } in groups.into_iter() { let group = self.group(id)?; Box::pin(group.sync()).await?; @@ -303,7 +305,8 @@ where conn: &DbConnection, inbox_id: &str, ) -> Result<(), GroupError> { - let groups = conn.find_groups(None, None, None, None, Some(ConversationType::Group))?; + let groups = + conn.find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))?; for group in groups { let group = self.group(group.id)?; Box::pin(group.add_members_by_inbox_id(&[inbox_id.to_string()])).await?; diff --git a/xmtp_mls/src/groups/device_sync/message_sync.rs b/xmtp_mls/src/groups/device_sync/message_sync.rs index 96cb6ffc7..95d88ef31 100644 --- a/xmtp_mls/src/groups/device_sync/message_sync.rs +++ b/xmtp_mls/src/groups/device_sync/message_sync.rs @@ -1,4 +1,5 @@ use super::*; +use crate::storage::group::GroupQueryArgs; use crate::storage::group_message::MsgQueryArgs; use crate::XmtpApi; use crate::{storage::group::StoredGroup, Client}; @@ -53,7 +54,7 @@ where fn syncable_groups(&self, conn: &DbConnection) -> Result, DeviceSyncError> { let groups = conn - .find_groups(None, None, None, None, Some(ConversationType::Group))? + .find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))? .into_iter() .map(Syncable::Group) .collect(); @@ -61,7 +62,8 @@ where } fn syncable_messages(&self, conn: &DbConnection) -> Result, DeviceSyncError> { - let groups = conn.find_groups(None, None, None, None, Some(ConversationType::Group))?; + let groups = + conn.find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))?; let mut all_messages = vec![]; for StoredGroup { id, .. } in groups.into_iter() { diff --git a/xmtp_mls/src/groups/message_history.rs b/xmtp_mls/src/groups/message_history.rs index 5efad7054..4856ef94a 100644 --- a/xmtp_mls/src/groups/message_history.rs +++ b/xmtp_mls/src/groups/message_history.rs @@ -29,6 +29,7 @@ use xmtp_proto::{ use super::group_metadata::ConversationType; use super::{GroupError, MlsGroup}; +use crate::storage::group::GroupQueryArgs; use crate::storage::group_message::MsgQueryArgs; use crate::XmtpApi; use crate::{ @@ -139,7 +140,8 @@ where pub async fn ensure_member_of_all_groups(&self, inbox_id: String) -> Result<(), GroupError> { let conn = self.store().conn()?; - let groups = conn.find_groups(None, None, None, None, Some(ConversationType::Group))?; + let groups = + conn.find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))?; for group in groups { let group = self.group(group.id)?; Box::pin(group.add_members_by_inbox_id(vec![inbox_id.clone()])).await?; @@ -368,7 +370,9 @@ where self.sync_welcomes().await?; let conn = self.store().conn()?; - let groups = conn.find_groups(None, None, None, None, Some(ConversationType::Group))?; + let groups = conn.find_groups( + GroupQueryArgs::default().conversation_type(ConversationType::Group), + )?; for crate::storage::group::StoredGroup { id, .. } in groups.into_iter() { let group = self.group(id)?; Box::pin(group.sync()).await?; @@ -481,14 +485,15 @@ where async fn prepare_groups_to_sync(&self) -> Result, MessageHistoryError> { let conn = self.store().conn()?; - Ok(conn.find_groups(None, None, None, None, Some(ConversationType::Group))?) + Ok(conn.find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))?) } async fn prepare_messages_to_sync( &self, ) -> Result, MessageHistoryError> { let conn = self.store().conn()?; - let groups = conn.find_groups(None, None, None, None, Some(ConversationType::Group))?; + let groups = + conn.find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group))?; let mut all_messages: Vec = vec![]; for StoredGroup { id, .. } in groups.into_iter() { diff --git a/xmtp_mls/src/groups/mod.rs b/xmtp_mls/src/groups/mod.rs index d0d4c66fc..91347c2f5 100644 --- a/xmtp_mls/src/groups/mod.rs +++ b/xmtp_mls/src/groups/mod.rs @@ -666,7 +666,6 @@ impl MlsGroup { ) -> Result, GroupError> { let conn = self.context().store().conn()?; let messages = conn.get_group_messages(&self.group_id, args)?; - Ok(messages) } @@ -1522,7 +1521,7 @@ pub(crate) mod tests { use crate::{ assert_err, builder::ClientBuilder, - client::{FindGroupParams, MessageProcessingError}, + client::MessageProcessingError, codecs::{group_updated::GroupUpdatedCodec, ContentCodec}, groups::{ build_dm_protected_metadata_extension, build_mutable_metadata_extension_default, @@ -1536,6 +1535,7 @@ pub(crate) mod tests { }, storage::{ consent_record::ConsentState, + group::GroupQueryArgs, group::Purpose, group_intent::{IntentKind, IntentState}, group_message::{GroupMessageKind, MsgQueryArgs, StoredGroupMessage}, @@ -1552,7 +1552,7 @@ pub(crate) mod tests { .sync_welcomes(&client.store().conn().unwrap()) .await .unwrap(); - let mut groups = client.find_groups(FindGroupParams::default()).unwrap(); + let mut groups = client.find_groups(GroupQueryArgs::default()).unwrap(); groups.remove(0) } @@ -1867,7 +1867,7 @@ pub(crate) mod tests { // Bo should not be able to actually read this group bo.sync_welcomes(&bo.store().conn().unwrap()).await.unwrap(); - let groups = bo.find_groups(FindGroupParams::default()).unwrap(); + let groups = bo.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(groups.len(), 0); assert_logged!("failed to create group from welcome", 1); }); @@ -1997,7 +1997,7 @@ pub(crate) mod tests { .sync_welcomes(&bola_client.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola_client.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola_client.find_groups(GroupQueryArgs::default()).unwrap(); let bola_group = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); let bola_messages = bola_group.find_messages(&MsgQueryArgs::default()).unwrap(); @@ -2354,7 +2354,8 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(bola_groups.len(), 1); let bola_group = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); @@ -2524,7 +2525,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(bola_groups.len(), 1); let bola_group = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); @@ -2606,7 +2607,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(bola_groups.len(), 1); let bola_group = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); @@ -2624,7 +2625,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(bola_groups.len(), 1); let bola_group: &MlsGroup<_> = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); @@ -2690,7 +2691,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(bola_groups.len(), 1); let bola_group: &MlsGroup<_> = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); @@ -2721,7 +2722,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(bola_groups.len(), 1); let bola_group = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); @@ -2739,7 +2740,8 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); + assert_eq!(bola_groups.len(), 1); let bola_group: &MlsGroup<_> = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); @@ -2995,7 +2997,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); let bola_group: &MlsGroup<_> = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); bola_group @@ -3063,7 +3065,8 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); + let bola_group: &MlsGroup<_> = bola_groups.first().unwrap(); bola_group.sync().await.unwrap(); let result = bola_group.add_members_by_inbox_id(&[caro.inbox_id()]).await; @@ -3220,12 +3223,8 @@ pub(crate) mod tests { // Bola can message amal let _ = bola.sync_welcomes(&bola.store().conn().unwrap()).await; - let bola_groups = bola - .find_groups(FindGroupParams { - conversation_type: None, - ..FindGroupParams::default() - }) - .unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); + let bola_dm: &MlsGroup<_> = bola_groups.first().unwrap(); bola_dm.send_message(b"test one").await.unwrap(); @@ -3572,7 +3571,7 @@ pub(crate) mod tests { bola.sync_welcomes(&bola.store().conn().unwrap()) .await .unwrap(); - let bola_groups = bola.find_groups(FindGroupParams::default()).unwrap(); + let bola_groups = bola.find_groups(GroupQueryArgs::default()).unwrap(); let bola_group = bola_groups.first().unwrap(); // group consent state should default to unknown for users who did not create the group assert_eq!(bola_group.consent_state().unwrap(), ConsentState::Unknown); @@ -3593,7 +3592,7 @@ pub(crate) mod tests { caro.sync_welcomes(&caro.store().conn().unwrap()) .await .unwrap(); - let caro_groups = caro.find_groups(FindGroupParams::default()).unwrap(); + let caro_groups = caro.find_groups(GroupQueryArgs::default()).unwrap(); let caro_group = caro_groups.first().unwrap(); caro_group @@ -3622,8 +3621,9 @@ pub(crate) mod tests { ) .await .unwrap(); + bo.sync_welcomes(&bo.store().conn().unwrap()).await.unwrap(); - let bo_groups = bo.find_groups(FindGroupParams::default()).unwrap(); + let bo_groups = bo.find_groups(GroupQueryArgs::default()).unwrap(); let bo_group = bo_groups.first().unwrap(); // Both members see the same amount of messages to start diff --git a/xmtp_mls/src/storage/encrypted_store/group.rs b/xmtp_mls/src/storage/encrypted_store/group.rs index 2c2fac955..8babb7e5c 100644 --- a/xmtp_mls/src/storage/encrypted_store/group.rs +++ b/xmtp_mls/src/storage/encrypted_store/group.rs @@ -1,7 +1,6 @@ //! The Group database table. Stored information surrounding group membership and ID's. - use super::{ - consent_record::StoredConsentRecord, + consent_record::{ConsentState, StoredConsentRecord}, db_connection::DbConnection, schema::groups::{self, dsl}, Sqlite, @@ -12,6 +11,7 @@ use crate::{ use diesel::{ backend::Backend, deserialize::{self, FromSql, FromSqlRow}, + dsl::sql, expression::AsExpression, prelude::*, serialize::{self, IsNull, Output, ToSql}, @@ -19,7 +19,6 @@ use diesel::{ }; use serde::{Deserialize, Serialize}; -/// The Group ID type. pub type ID = Vec; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Insertable, Identifiable, Queryable)] @@ -116,49 +115,167 @@ impl StoredGroup { } } +#[derive(Debug, Default)] +pub struct GroupQueryArgs { + pub allowed_states: Option>, + pub created_after_ns: Option, + pub created_before_ns: Option, + pub limit: Option, + pub conversation_type: Option, + pub consent_state: Option, +} + +impl AsRef for GroupQueryArgs { + fn as_ref(&self) -> &GroupQueryArgs { + self + } +} + +impl GroupQueryArgs { + pub fn allowed_states(self, allowed_states: Vec) -> Self { + self.maybe_allowed_states(Some(allowed_states)) + } + + pub fn maybe_allowed_states( + mut self, + allowed_states: Option>, + ) -> Self { + self.allowed_states = allowed_states; + self + } + + pub fn created_after_ns(self, created_after_ns: i64) -> Self { + self.maybe_created_after_ns(Some(created_after_ns)) + } + + pub fn maybe_created_after_ns(mut self, created_after_ns: Option) -> Self { + self.created_after_ns = created_after_ns; + self + } + + pub fn created_before_ns(self, created_before_ns: i64) -> Self { + self.maybe_created_before_ns(Some(created_before_ns)) + } + + pub fn maybe_created_before_ns(mut self, created_before_ns: Option) -> Self { + self.created_before_ns = created_before_ns; + self + } + + pub fn limit(self, limit: i64) -> Self { + self.maybe_limit(Some(limit)) + } + + pub fn maybe_limit(mut self, limit: Option) -> Self { + self.limit = limit; + self + } + + pub fn conversation_type(self, conversation_type: ConversationType) -> Self { + self.maybe_conversation_type(Some(conversation_type)) + } + + pub fn maybe_conversation_type(mut self, conversation_type: Option) -> Self { + self.conversation_type = conversation_type; + self + } + + pub fn consent_state(self, consent_state: ConsentState) -> Self { + self.maybe_consent_state(Some(consent_state)) + } + + pub fn maybe_consent_state(mut self, consent_state: Option) -> Self { + self.consent_state = consent_state; + self + } +} + impl DbConnection { /// Return regular [`Purpose::Conversation`] groups with additional optional filters - pub fn find_groups( + pub fn find_groups>( &self, - allowed_states: Option>, - created_after_ns: Option, - created_before_ns: Option, - limit: Option, - conversation_type: Option, + args: A, ) -> Result, StorageError> { - let mut query = dsl::groups.order(dsl::created_at_ns.asc()).into_boxed(); + use crate::storage::schema::consent_records::dsl as consent_dsl; + use crate::storage::schema::groups::dsl as groups_dsl; + let GroupQueryArgs { + allowed_states, + created_after_ns, + created_before_ns, + limit, + conversation_type, + consent_state, + } = args.as_ref(); + + let mut query = groups_dsl::groups + .order(groups_dsl::created_at_ns.asc()) + .into_boxed(); + + if let Some(limit) = limit { + query = query.limit(*limit); + } if let Some(allowed_states) = allowed_states { - query = query.filter(dsl::membership_state.eq_any(allowed_states)); + query = query.filter(groups_dsl::membership_state.eq_any(allowed_states)); } if let Some(created_after_ns) = created_after_ns { - query = query.filter(dsl::created_at_ns.gt(created_after_ns)); + query = query.filter(groups_dsl::created_at_ns.gt(created_after_ns)); } if let Some(created_before_ns) = created_before_ns { - query = query.filter(dsl::created_at_ns.lt(created_before_ns)); - } - - if let Some(limit) = limit { - query = query.limit(limit); + query = query.filter(groups_dsl::created_at_ns.lt(created_before_ns)); } if let Some(conversation_type) = conversation_type { match conversation_type { ConversationType::Group => { - query = query.filter(dsl::dm_inbox_id.is_null()); + query = query.filter(groups_dsl::dm_inbox_id.is_null()); } ConversationType::Dm => { - query = query.filter(dsl::dm_inbox_id.is_not_null()); + query = query.filter(groups_dsl::dm_inbox_id.is_not_null()); } ConversationType::Sync => {} } } - query = query.filter(dsl::purpose.eq(Purpose::Conversation)); + query = query.filter(groups_dsl::purpose.eq(Purpose::Conversation)); + + let groups = if let Some(consent_state) = consent_state { + if *consent_state == ConsentState::Unknown { + let query = query + .left_join( + consent_dsl::consent_records + .on(sql::("lower(hex(groups.id))") + .eq(consent_dsl::entity)), + ) + .filter( + consent_dsl::state + .is_null() + .or(consent_dsl::state.eq(ConsentState::Unknown)), + ) + .select(groups_dsl::groups::all_columns()) + .order(groups_dsl::created_at_ns.asc()); + + self.raw_query(|conn| query.load::(conn))? + } else { + let query = query + .inner_join( + consent_dsl::consent_records + .on(sql::("lower(hex(groups.id))") + .eq(consent_dsl::entity)), + ) + .filter(consent_dsl::state.eq(*consent_state)) + .select(groups_dsl::groups::all_columns()) + .order(groups_dsl::created_at_ns.asc()); + + self.raw_query(|conn| query.load::(conn))? + } + } else { + self.raw_query(|conn| query.load::(conn))? + }; - Ok(self.raw_query(|conn| query.load(conn))?) + Ok(groups) } pub fn consent_records(&self) -> Result, StorageError> { @@ -403,7 +520,10 @@ pub(crate) mod tests { use super::*; use crate::{ assert_ok, - storage::encrypted_store::{schema::groups::dsl::groups, tests::with_connection}, + storage::{ + consent_record::{ConsentType, StoredConsentRecord}, + encrypted_store::{schema::groups::dsl::groups, tests::with_connection}, + }, utils::{test::rand_vec, time::now_ns}, Fetch, Store, }; @@ -422,6 +542,19 @@ pub(crate) mod tests { ) } + /// Generate a test consent + fn generate_consent_record( + entity_type: ConsentType, + state: ConsentState, + entity: String, + ) -> StoredConsentRecord { + StoredConsentRecord { + entity_type, + state, + entity, + } + } + /// Generate a test dm group pub fn generate_dm(state: Option) -> StoredGroup { let id = rand_vec(); @@ -505,17 +638,15 @@ pub(crate) mod tests { test_group_3.store(conn).unwrap(); let all_results = conn - .find_groups(None, None, None, None, Some(ConversationType::Group)) + .find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Group)) .unwrap(); assert_eq!(all_results.len(), 2); let pending_results = conn .find_groups( - Some(vec![GroupMembershipState::Pending]), - None, - None, - None, - Some(ConversationType::Group), + GroupQueryArgs::default() + .allowed_states(vec![GroupMembershipState::Pending]) + .conversation_type(ConversationType::Group), ) .unwrap(); assert_eq!(pending_results[0].id, test_group_1.id); @@ -523,18 +654,21 @@ pub(crate) mod tests { // Offset and limit let results_with_limit = conn - .find_groups(None, None, None, Some(1), Some(ConversationType::Group)) + .find_groups( + GroupQueryArgs::default() + .limit(1) + .conversation_type(ConversationType::Group), + ) .unwrap(); assert_eq!(results_with_limit.len(), 1); assert_eq!(results_with_limit[0].id, test_group_1.id); let results_with_created_at_ns_after = conn .find_groups( - None, - Some(test_group_1.created_at_ns), - None, - Some(1), - Some(ConversationType::Group), + GroupQueryArgs::default() + .created_after_ns(test_group_1.created_at_ns) + .conversation_type(ConversationType::Group) + .limit(1), ) .unwrap(); assert_eq!(results_with_created_at_ns_after.len(), 1); @@ -545,7 +679,7 @@ pub(crate) mod tests { assert!(synced_groups.is_none()); // test that dm groups are included - let dm_results = conn.find_groups(None, None, None, None, None).unwrap(); + let dm_results = conn.find_groups(GroupQueryArgs::default()).unwrap(); assert_eq!(dm_results.len(), 3); assert_eq!(dm_results[2].id, test_group_3.id); @@ -555,7 +689,7 @@ pub(crate) mod tests { // test only dms are returned let dm_results = conn - .find_groups(None, None, None, None, Some(ConversationType::Dm)) + .find_groups(GroupQueryArgs::default().conversation_type(ConversationType::Dm)) .unwrap(); assert_eq!(dm_results.len(), 1); assert_eq!(dm_results[0].id, test_group_3.id); @@ -627,4 +761,59 @@ pub(crate) mod tests { }) .await } + + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] + #[cfg_attr(not(target_arch = "wasm32"), tokio::test)] + async fn test_find_groups_by_consent_state() { + with_connection(|conn| { + let test_group_1 = generate_group(Some(GroupMembershipState::Allowed)); + test_group_1.store(conn).unwrap(); + let test_group_2 = generate_group(Some(GroupMembershipState::Allowed)); + test_group_2.store(conn).unwrap(); + let test_group_3 = generate_dm(Some(GroupMembershipState::Allowed)); + test_group_3.store(conn).unwrap(); + let test_group_4 = generate_dm(Some(GroupMembershipState::Allowed)); + test_group_4.store(conn).unwrap(); + + let test_group_1_consent = generate_consent_record( + ConsentType::ConversationId, + ConsentState::Allowed, + hex::encode(test_group_1.id.clone()), + ); + test_group_1_consent.store(conn).unwrap(); + let test_group_2_consent = generate_consent_record( + ConsentType::ConversationId, + ConsentState::Denied, + hex::encode(test_group_2.id.clone()), + ); + test_group_2_consent.store(conn).unwrap(); + let test_group_3_consent = generate_consent_record( + ConsentType::ConversationId, + ConsentState::Allowed, + hex::encode(test_group_3.id.clone()), + ); + test_group_3_consent.store(conn).unwrap(); + + let all_results = conn.find_groups(GroupQueryArgs::default()).unwrap(); + assert_eq!(all_results.len(), 4); + + let allowed_results = conn + .find_groups(GroupQueryArgs::default().consent_state(ConsentState::Allowed)) + .unwrap(); + assert_eq!(allowed_results.len(), 2); + + let denied_results = conn + .find_groups(GroupQueryArgs::default().consent_state(ConsentState::Denied)) + .unwrap(); + assert_eq!(denied_results.len(), 1); + assert_eq!(denied_results[0].id, test_group_2.id); + + let unknown_results = conn + .find_groups(GroupQueryArgs::default().consent_state(ConsentState::Unknown)) + .unwrap(); + assert_eq!(unknown_results.len(), 1); + assert_eq!(unknown_results[0].id, test_group_4.id); + }) + .await + } } diff --git a/xmtp_mls/src/subscriptions.rs b/xmtp_mls/src/subscriptions.rs index d6467df35..2a0939db0 100644 --- a/xmtp_mls/src/subscriptions.rs +++ b/xmtp_mls/src/subscriptions.rs @@ -12,8 +12,9 @@ use crate::{ retry::Retry, retry::RetryableError, retry_async, retryable, - storage::StorageError, - storage::{group::StoredGroup, group_message::StoredGroupMessage}, + storage::{ + group::GroupQueryArgs, group::StoredGroup, group_message::StoredGroupMessage, StorageError, + }, Client, XmtpApi, }; @@ -276,7 +277,7 @@ where let mut group_id_to_info = self .store() .conn()? - .find_groups(None, None, None, None, conversation_type)? + .find_groups(GroupQueryArgs::default().maybe_conversation_type(conversation_type))? .into_iter() .map(Into::into) .collect::, MessagesStreamInfo>>(); @@ -388,9 +389,8 @@ pub(crate) mod tests { use crate::{ builder::ClientBuilder, - client::FindGroupParams, groups::{group_metadata::ConversationType, GroupMetadataOptions}, - storage::group_message::StoredGroupMessage, + storage::{group::GroupQueryArgs, group_message::StoredGroupMessage}, utils::test::{Delivery, FullXmtpClient, TestClient}, Client, StreamHandle, }; @@ -769,7 +769,7 @@ pub(crate) mod tests { alix.sync_welcomes(&alix.store().conn().unwrap()) .await .unwrap(); - let find_groups_results = alix.find_groups(FindGroupParams::default()).unwrap(); + let find_groups_results = alix.find_groups(GroupQueryArgs::default()).unwrap(); { let grps = groups.lock();