Update to Matrix SDK from git (breaking, probably 0.5 prerelease)

This commit is contained in:
Olivier 'reivilibre' 2021-11-23 22:24:09 +00:00
parent f77ccefd7c
commit 808d45b893
5 changed files with 100 additions and 125 deletions

192
Cargo.lock generated
View File

@ -67,12 +67,48 @@ version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7" checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7"
[[package]]
name = "anymap2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c"
[[package]] [[package]]
name = "assign" name = "assign"
version = "1.1.1" version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f093eed78becd229346bf859eec0aa4dd7ddde0757287b2b4107a1f09c80002" checksum = "5f093eed78becd229346bf859eec0aa4dd7ddde0757287b2b4107a1f09c80002"
[[package]]
name = "async-lock"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b"
dependencies = [
"event-listener",
]
[[package]]
name = "async-stream"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625"
dependencies = [
"async-stream-impl",
"futures-core",
]
[[package]]
name = "async-stream-impl"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308"
dependencies = [
"proc-macro2 1.0.32",
"quote 1.0.10",
"syn 1.0.81",
]
[[package]] [[package]]
name = "async-trait" name = "async-trait"
version = "0.1.51" version = "0.1.51"
@ -134,6 +170,12 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "bs58"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3"
[[package]] [[package]]
name = "buf_redux" name = "buf_redux"
version = "0.8.4" version = "0.8.4"
@ -514,7 +556,6 @@ checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-executor",
"futures-io", "futures-io",
"futures-sink", "futures-sink",
"futures-task", "futures-task",
@ -537,45 +578,12 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d"
[[package]]
name = "futures-executor"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.17" version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377"
[[package]]
name = "futures-locks"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50c4e684ddb2d8a4db5ca8a02b35156da129674ba4412b6f528698d58c594954"
dependencies = [
"futures",
]
[[package]]
name = "futures-macro"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
dependencies = [
"autocfg",
"proc-macro-hack",
"proc-macro2 1.0.32",
"quote 1.0.10",
"syn 1.0.81",
]
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.17" version = "0.3.17"
@ -607,15 +615,10 @@ dependencies = [
"autocfg", "autocfg",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-io",
"futures-macro",
"futures-sink", "futures-sink",
"futures-task", "futures-task",
"memchr",
"pin-project-lite", "pin-project-lite",
"pin-utils", "pin-utils",
"proc-macro-hack",
"proc-macro-nested",
"slab", "slab",
] ]
@ -1039,8 +1042,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "matrix-qrcode" name = "matrix-qrcode"
version = "0.2.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa#a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa"
checksum = "4231739aa2ff90c6c55b07d7179c52b496622a86fc2f7e0431336d109ba7838d"
dependencies = [ dependencies = [
"base64", "base64",
"byteorder", "byteorder",
@ -1054,15 +1056,17 @@ dependencies = [
[[package]] [[package]]
name = "matrix-sdk" name = "matrix-sdk"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa#a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa"
checksum = "5834b96fef26d6d61c8ffd21dda3569c7c0fc688f9cc8aebd35f6f8c3068a186"
dependencies = [ dependencies = [
"anymap2",
"async-stream",
"backoff", "backoff",
"bytes", "bytes",
"dashmap", "dashmap",
"event-listener", "event-listener",
"futures", "futures-core",
"futures-timer", "futures-timer",
"futures-util",
"http", "http",
"matrix-sdk-base", "matrix-sdk-base",
"matrix-sdk-common", "matrix-sdk-common",
@ -1074,7 +1078,6 @@ dependencies = [
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
"tracing-futures",
"url", "url",
"zeroize", "zeroize",
] ]
@ -1082,12 +1085,12 @@ dependencies = [
[[package]] [[package]]
name = "matrix-sdk-base" name = "matrix-sdk-base"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa#a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa"
checksum = "b97c4d675ff70395c1b0cd94fae869cea4efd3f148b74bf4186e969ee622a9c7"
dependencies = [ dependencies = [
"chacha20poly1305", "chacha20poly1305",
"dashmap", "dashmap",
"futures", "futures-core",
"futures-util",
"hmac", "hmac",
"lru", "lru",
"matrix-sdk-common", "matrix-sdk-common",
@ -1108,12 +1111,11 @@ dependencies = [
[[package]] [[package]]
name = "matrix-sdk-common" name = "matrix-sdk-common"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa#a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa"
checksum = "31c004ca5d02a17eb827a2c3d8e34c9a84c075b42cfed7022895ba6418372ea5"
dependencies = [ dependencies = [
"async-lock",
"async-trait", "async-trait",
"futures", "futures-util",
"futures-locks",
"instant", "instant",
"ruma", "ruma",
"serde", "serde",
@ -1125,22 +1127,23 @@ dependencies = [
[[package]] [[package]]
name = "matrix-sdk-crypto" name = "matrix-sdk-crypto"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa#a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa"
checksum = "d36626b188e0ea1d244eef6fe39ab1758c401de6ec84d0389df88f9f6ad761b9"
dependencies = [ dependencies = [
"aes", "aes",
"aes-gcm", "aes-gcm",
"atomic", "atomic",
"base64", "base64",
"bs58",
"byteorder", "byteorder",
"dashmap", "dashmap",
"futures", "futures-util",
"getrandom 0.2.3", "getrandom 0.2.3",
"hmac", "hmac",
"matrix-qrcode", "matrix-qrcode",
"matrix-sdk-common", "matrix-sdk-common",
"olm-rs", "olm-rs",
"pbkdf2", "pbkdf2",
"rand 0.8.4",
"ruma", "ruma",
"serde", "serde",
"serde_json", "serde_json",
@ -1352,9 +1355,9 @@ dependencies = [
[[package]] [[package]]
name = "olm-rs" name = "olm-rs"
version = "2.0.1" version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33a5773f317476f5687fc8200fc0120d97b075c30c133a5b15ca558252743720" checksum = "28d071397525c2c184bb916a608d8e0be8f0c14f0ae4075c2949c7a7fbae52ad"
dependencies = [ dependencies = [
"getrandom 0.2.3", "getrandom 0.2.3",
"olm-sys", "olm-sys",
@ -1563,18 +1566,6 @@ dependencies = [
"toml", "toml",
] ]
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro-nested"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "0.4.30" version = "0.4.30"
@ -1788,9 +1779,9 @@ dependencies = [
[[package]] [[package]]
name = "rqrr" name = "rqrr"
version = "0.3.2" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a63da014e6f18dbe76e3084feb2f6c5a570ad8d524cc1afff4a6db18404cd" checksum = "6fa79947f53b20adb909a323d828d0fd744fa9d854792df07913b083bcd4d63b"
dependencies = [ dependencies = [
"g2p", "g2p",
"image", "image",
@ -1800,8 +1791,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "668031e3108d6a2cfbe6eca271d8698f4593440e71a44afdadcf67ce3cb93c1f"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -1819,8 +1809,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-api" name = "ruma-api"
version = "0.18.5" version = "0.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "eda5ec9cf6163bb6be82c8a3994de09fdcd349dcf651aa6cabf649451f361eee"
dependencies = [ dependencies = [
"bytes", "bytes",
"http", "http",
@ -1836,8 +1825,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-api-macros" name = "ruma-api-macros"
version = "0.18.5" version = "0.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "72984e25b5e66fcce3267e97288e8dab96e966b151d4d205846049f5b2819e97"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2 1.0.32", "proc-macro2 1.0.32",
@ -1848,8 +1836,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.12.3" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "ef8acd3e66bf9d63d9472ecd17b9f497062ce1caaf13673b101d6697358b41a7"
dependencies = [ dependencies = [
"assign", "assign",
"bytes", "bytes",
@ -1869,8 +1856,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.6.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "41d5b7605f58dc0d9cf1848cc7f1af2bae4e4bcd1d2b7a87bbb9864c8a785b91"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"js_int", "js_int",
@ -1885,8 +1871,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.24.6" version = "0.24.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "5ba40ba9f4b6bdf6dc82b18ee7dfd7a029c86a12f9785a0efe4df04bd5dfa3c8"
dependencies = [ dependencies = [
"indoc", "indoc",
"js_int", "js_int",
@ -1902,8 +1887,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events-macros" name = "ruma-events-macros"
version = "0.24.6" version = "0.24.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "431a3dfadb48a8b7df9d00776274e32fed68df96cc19d9d9346bfed62540f91a"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2 1.0.32", "proc-macro2 1.0.32",
@ -1914,8 +1898,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.3.1" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "fa3d1db1a064ab26484df6ef5d96c384fc053022004f34d96c3b4939e13dc204"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-api", "ruma-api",
@ -1930,10 +1913,10 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers" name = "ruma-identifiers"
version = "0.20.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "cb417d091e8dd5a633e4e5998231a156049d7fcc221045cfdc0642eb72067732"
dependencies = [ dependencies = [
"paste", "paste",
"percent-encoding",
"ruma-identifiers-macros", "ruma-identifiers-macros",
"ruma-identifiers-validation", "ruma-identifiers-validation",
"ruma-serde", "ruma-serde",
@ -1944,8 +1927,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-macros" name = "ruma-identifiers-macros"
version = "0.20.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "c708edad7f605638f26c951cbad7501fbf28ab01009e5ca65ea5a2db74a882b1"
dependencies = [ dependencies = [
"quote 1.0.10", "quote 1.0.10",
"ruma-identifiers-validation", "ruma-identifiers-validation",
@ -1955,14 +1937,15 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.5.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "42285e7fb5d5f2d5268e45bb683e36d5c6fd9fc1e11a4559ba3c3521f3bbb2cb" dependencies = [
"thiserror",
]
[[package]] [[package]]
name = "ruma-serde" name = "ruma-serde"
version = "0.5.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "8b2b22aae842e7ecda695e42b7b39d4558959d9d9a27acc2a16acf4f4f7f00c3"
dependencies = [ dependencies = [
"bytes", "bytes",
"form_urlencoded", "form_urlencoded",
@ -1976,8 +1959,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-serde-macros" name = "ruma-serde-macros"
version = "0.5.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "243e9bef188b08f94c79bc2f8fd1eb307a9e636b2b8e4571acf8c7be16381d28"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2 1.0.32", "proc-macro2 1.0.32",
@ -1988,8 +1970,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.9.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "4a4f64027165b59500162d10d435b1253898bf3ad4f5002cb0d56913fe7f76d7"
dependencies = [ dependencies = [
"base64", "base64",
"ed25519-dalek", "ed25519-dalek",
@ -2006,8 +1987,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-state-res" name = "ruma-state-res"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/ruma/ruma?rev=ac6ecc3e5#ac6ecc3e5e28197765f345c4d5a7732b41b057e7"
checksum = "518c1afbddfcc5ffac8818a5cf0902709e6eca11aca8f24f6479df6f0601f1ba"
dependencies = [ dependencies = [
"itertools", "itertools",
"js_int", "js_int",
@ -2459,16 +2439,6 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.2.3" version = "0.2.3"

View File

@ -6,7 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
matrix-sdk = { version = "0.4.1", features = [ "encryption", "sled_cryptostore" ] } # we use new features not quite yet in a released matrix rust SDK
#matrix-sdk = { version = "0.4.1", features = [ "encryption", "sled_cryptostore" ] }
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git", rev = "a49a7fe1f93a4e8791dbbe4fd6876c587c33d2fa", features = ["encryption", "sled_cryptostore"] }
#monzo-lib = "0.4.0" #monzo-lib = "0.4.0"
monzo-lib = { git = "https://github.com/danieleades/monzo-lib.git", rev = "e54ff827" } monzo-lib = { git = "https://github.com/danieleades/monzo-lib.git", rev = "e54ff827" }
tokio = { version = "1.13.0", features = [ "full" ] } tokio = { version = "1.13.0", features = [ "full" ] }

View File

@ -1,11 +1,12 @@
use crate::monzo::monzo_client_freshened; use crate::monzo::monzo_client_freshened;
use crate::state::{Config, MonzoState, State, StateInner}; use crate::state::{Config, MonzoState, State, StateInner};
use crate::web::warp_main; use crate::web::warp_main;
use matrix_sdk::config::{ClientConfig, SyncSettings};
use matrix_sdk::room::Room; use matrix_sdk::room::Room;
use matrix_sdk::ruma::events::room::message::{MessageEventContent, MessageType}; use matrix_sdk::ruma::events::room::message::{MessageType, RoomMessageEventContent};
use matrix_sdk::ruma::events::SyncMessageEvent; use matrix_sdk::ruma::events::SyncMessageEvent;
use matrix_sdk::ruma::UserId; use matrix_sdk::ruma::UserId;
use matrix_sdk::{Client, ClientConfig, SyncSettings}; use matrix_sdk::{Client, Session};
use std::convert::TryFrom; use std::convert::TryFrom;
use std::sync::Arc; use std::sync::Arc;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
@ -16,7 +17,7 @@ pub mod state;
pub mod web; pub mod web;
async fn on_room_message( async fn on_room_message(
event: &SyncMessageEvent<MessageEventContent>, event: &SyncMessageEvent<RoomMessageEventContent>,
room: Room, room: Room,
state: &State, state: &State,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
@ -45,10 +46,10 @@ async fn on_room_message(
buf.push_str("?currency"); buf.push_str("?currency");
} }
} }
let content = MessageEventContent::text_plain(&buf); let content = RoomMessageEventContent::text_plain(&buf);
room.send(content, None).await.unwrap(); room.send(content, None).await.unwrap();
} else { } else {
let content = MessageEventContent::text_plain("Not linked :(."); let content = RoomMessageEventContent::text_plain("Not linked :(.");
room.send(content, None).await.unwrap(); room.send(content, None).await.unwrap();
} }
} }
@ -69,7 +70,7 @@ async fn main() -> anyhow::Result<()> {
let client_config = ClientConfig::new().store_path(store_path); let client_config = ClientConfig::new().store_path(store_path);
let client = Client::new_from_user_id_with_config(mxid.clone(), client_config).await?; let client = Client::new_from_user_id_with_config(&mxid, client_config).await?;
let state = State { let state = State {
config: Arc::new(config.clone()), config: Arc::new(config.clone()),
@ -111,7 +112,7 @@ async fn main() -> anyhow::Result<()> {
client client
.register_event_handler( .register_event_handler(
move |ev: SyncMessageEvent<MessageEventContent>, room: Room| { move |ev: SyncMessageEvent<RoomMessageEventContent>, room: Room| {
let state_arc = state_arc.clone(); let state_arc = state_arc.clone();
async move { async move {
if let Err(error) = on_room_message(&ev, room, &state_arc).await { if let Err(error) = on_room_message(&ev, room, &state_arc).await {

View File

@ -73,7 +73,11 @@ pub async fn monzo_client_freshened(
drop(state_inner); drop(state_inner);
let needs_refresh = exp_at_instant < SystemTime::now(); let needs_refresh = exp_at_instant < SystemTime::now();
if needs_refresh { if needs_refresh {
eprintln!("Refreshing token; expiry {:?}; now {:?}.", exp_at_instant, SystemTime::now()); eprintln!(
"Refreshing token; expiry {:?}; now {:?}.",
exp_at_instant,
SystemTime::now()
);
eprintln!("DEBUG refresh_token being used {:?}", &refresh_token); eprintln!("DEBUG refresh_token being used {:?}", &refresh_token);
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let resp = client let resp = client
@ -87,8 +91,7 @@ pub async fn monzo_client_freshened(
.send() .send()
.await?; .await?;
eprintln!("DEBUG response status {:?}", resp.status()); eprintln!("DEBUG response status {:?}", resp.status());
let jv: serde_json::Value = resp.json() let jv: serde_json::Value = resp.json().await?;
.await?;
eprintln!("DEBUG raw JV {:#?}", jv); eprintln!("DEBUG raw JV {:#?}", jv);
let auth_resp: MonzoAuthResponse = serde_json::from_value(jv)?; let auth_resp: MonzoAuthResponse = serde_json::from_value(jv)?;
let mut state_inner = state.inner.write().await; let mut state_inner = state.inner.write().await;

View File

@ -3,7 +3,7 @@ use crate::monzo::{
}; };
use crate::state::State; use crate::state::State;
use matrix_sdk::room::Room; use matrix_sdk::room::Room;
use matrix_sdk::ruma::events::room::message::MessageEventContent; use matrix_sdk::ruma::events::room::message::RoomMessageEventContent;
use matrix_sdk::ruma::RoomId; use matrix_sdk::ruma::RoomId;
use monzo::accounts::Type; use monzo::accounts::Type;
use serde::Deserialize; use serde::Deserialize;
@ -191,10 +191,9 @@ async fn monzo_hook(hook: MonzoHook, state: State) -> anyhow::Result<impl warp::
eprintln!("when querying balance after webhook: {:?}", err); eprintln!("when querying balance after webhook: {:?}", err);
} }
} }
} }
let content = MessageEventContent::text_plain(&buf); let content = RoomMessageEventContent::text_plain(&buf);
room.send(content, None).await.unwrap(); room.send(content, None).await.unwrap();
} else { } else {
eprintln!("Not in room."); eprintln!("Not in room.");