Update to latest ruma/master rev

next
Devin Ragotzy 2020-07-25 14:25:24 -04:00
parent 61458536ab
commit 60381ddcf4
7 changed files with 248 additions and 218 deletions

242
Cargo.lock generated
View File

@ -23,57 +23,56 @@ checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
[[package]] [[package]]
name = "aead" name = "aead"
version = "0.2.0" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cf01b9b56e767bb57b94ebf91a58b338002963785cdd7013e21c0d4679471e4" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331"
dependencies = [ dependencies = [
"generic-array", "generic-array",
] ]
[[package]] [[package]]
name = "aes" name = "aes"
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 = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" checksum = "f7001367fde4c768a19d1029f0a8be5abd9308e1119846d5bd9ad26297b8faf5"
dependencies = [ dependencies = [
"aes-soft", "aes-soft",
"aesni", "aesni",
"block-cipher-trait", "block-cipher",
] ]
[[package]] [[package]]
name = "aes-gcm" name = "aes-gcm"
version = "0.5.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "834a6bda386024dbb7c8fc51322856c10ffe69559f972261c868485f5759c638" checksum = "86f5007801316299f922a6198d1d09a0bae95786815d066d5880d13f7c45ead1"
dependencies = [ dependencies = [
"aead", "aead",
"aes", "aes",
"block-cipher-trait", "block-cipher",
"ghash", "ghash",
"subtle 2.2.3", "subtle",
"zeroize",
] ]
[[package]] [[package]]
name = "aes-soft" name = "aes-soft"
version = "0.3.3" 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 = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" checksum = "4925647ee64e5056cf231608957ce7c81e12d6d6e316b9ce1404778cc1d35fa7"
dependencies = [ dependencies = [
"block-cipher-trait", "block-cipher",
"byteorder", "byteorder",
"opaque-debug", "opaque-debug 0.2.3",
] ]
[[package]] [[package]]
name = "aesni" name = "aesni"
version = "0.6.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" checksum = "d050d39b0b7688b3a3254394c3e30a9d66c41dcf9b05b0e2dbdc623f6505d264"
dependencies = [ dependencies = [
"block-cipher-trait", "block-cipher",
"opaque-debug", "opaque-debug 0.2.3",
] ]
[[package]] [[package]]
@ -191,32 +190,20 @@ dependencies = [
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.7.3" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array",
]
[[package]]
name = "block-cipher-trait"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774"
dependencies = [ dependencies = [
"generic-array", "generic-array",
] ]
[[package]] [[package]]
name = "block-padding" name = "block-cipher"
version = "0.1.5" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" checksum = "fa136449e765dc7faa244561ccae839c394048667929af599b5d931ebe7b7f10"
dependencies = [ dependencies = [
"byte-tools", "generic-array",
] ]
[[package]] [[package]]
@ -225,17 +212,11 @@ version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
[[package]]
name = "byte-tools"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.2.0" version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37fa13df2292ecb479ec23aa06f4507928bef07839be9ef15281411076629431" checksum = "d40636046a60a45ee5185e885a3ccb771f7a2065fb7cbcc2a7ecfd9896d1c365"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
@ -306,9 +287,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]] [[package]]
name = "cookie" name = "cookie"
version = "0.14.1" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca761767cf3fa9068cc893ec8c247a22d0fd0535848e65640c0548bd1f8bbb36" checksum = "1373a16a4937bc34efec7b391f9c1500c30b8478a701a4f44c9165cc0475a6e0"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"base64 0.12.3", "base64 0.12.3",
@ -317,6 +298,7 @@ dependencies = [
"rand", "rand",
"sha2", "sha2",
"time 0.2.16", "time 0.2.16",
"version_check",
] ]
[[package]] [[package]]
@ -335,6 +317,12 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]]
name = "cpuid-bool"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.2.0" version = "1.2.0"
@ -372,12 +360,12 @@ dependencies = [
[[package]] [[package]]
name = "crypto-mac" name = "crypto-mac"
version = "0.7.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"subtle 1.0.0", "subtle",
] ]
[[package]] [[package]]
@ -422,9 +410,9 @@ dependencies = [
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.8.1" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [ dependencies = [
"generic-array", "generic-array",
] ]
@ -471,12 +459,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -505,7 +487,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00"
dependencies = [ dependencies = [
"matches", "matches",
"percent-encoding 2.1.0", "percent-encoding",
] ]
[[package]] [[package]]
@ -640,11 +622,12 @@ dependencies = [
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.12.3" version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" checksum = "60fb4bb6bba52f78a471264d9a3b7d026cc0af47b22cd2cffbc0b787ca003e63"
dependencies = [ dependencies = [
"typenum", "typenum",
"version_check",
] ]
[[package]] [[package]]
@ -660,9 +643,9 @@ dependencies = [
[[package]] [[package]]
name = "ghash" name = "ghash"
version = "0.2.3" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f0930ed19a7184089ea46d2fedead2f6dc2b674c5db4276b7da336c7cd83252" checksum = "d6e27f0689a6e15944bdce7e45425efb87eaa8ab0c6e87f11d0987a9133e2531"
dependencies = [ dependencies = [
"polyval", "polyval",
] ]
@ -737,9 +720,9 @@ dependencies = [
[[package]] [[package]]
name = "hkdf" name = "hkdf"
version = "0.8.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" checksum = "fe1149865383e4526a43aee8495f9a325f0b806c63ce6427d06336a590abbbc9"
dependencies = [ dependencies = [
"digest", "digest",
"hmac", "hmac",
@ -747,9 +730,9 @@ dependencies = [
[[package]] [[package]]
name = "hmac" name = "hmac"
version = "0.7.1" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
dependencies = [ dependencies = [
"crypto-mac", "crypto-mac",
"digest", "digest",
@ -862,6 +845,12 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb6ee2a7da03bfc3b66ca47c92c2e392fcc053ea040a85561749b026f7aad09a" checksum = "cb6ee2a7da03bfc3b66ca47c92c2e392fcc053ea040a85561749b026f7aad09a"
[[package]]
name = "instant"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
[[package]] [[package]]
name = "iovec" name = "iovec"
version = "0.1.4" version = "0.1.4"
@ -871,6 +860,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "ipnet"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135"
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "0.4.6" version = "0.4.6"
@ -1151,6 +1146,12 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "opaque-debug"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.30" version = "0.10.30"
@ -1289,9 +1290,9 @@ dependencies = [
[[package]] [[package]]
name = "polyval" name = "polyval"
version = "0.3.3" 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 = "7ec3341498978de3bfd12d1b22f1af1de22818f5473a11e8a6ef997989e3a212" checksum = "d9a50142b55ab3ed0e9f68dfb3709f1d90d29da24e91033f28b96330643107dc"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"universal-hash", "universal-hash",
@ -1317,7 +1318,7 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.18" version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
dependencies = [ dependencies = [
@ -1434,9 +1435,9 @@ dependencies = [
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.10.6" version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680" checksum = "12427a5577082c24419c9c417db35cfeb65962efc7675bb6b0d5f1f9d315bfe6"
dependencies = [ dependencies = [
"base64 0.12.3", "base64 0.12.3",
"bytes", "bytes",
@ -1447,6 +1448,7 @@ dependencies = [
"http-body", "http-body",
"hyper", "hyper",
"hyper-tls", "hyper-tls",
"ipnet",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
"log", "log",
@ -1543,26 +1545,27 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"ruma-api", "ruma-api",
"ruma-client-api", "ruma-client-api",
"ruma-common", "ruma-common",
"ruma-events", "ruma-events",
"ruma-federation-api", "ruma-federation-api",
"ruma-identifiers", "ruma-identifiers 0.17.0 (git+https://github.com/ruma/ruma?rev=08fbace)",
"ruma-identifiers-macros",
"ruma-signatures", "ruma-signatures",
] ]
[[package]] [[package]]
name = "ruma-api" name = "ruma-api"
version = "0.16.1" version = "0.16.1"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"http", "http",
"percent-encoding", "percent-encoding",
"ruma-api-macros", "ruma-api-macros",
"ruma-identifiers", "ruma-identifiers 0.17.0 (git+https://github.com/ruma/ruma?rev=08fbace)",
"ruma-serde", "ruma-serde",
"serde", "serde",
"serde_json", "serde_json",
@ -1572,7 +1575,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-api-macros" name = "ruma-api-macros"
version = "0.16.1" version = "0.16.1"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1582,14 +1585,14 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"http", "http",
"js_int", "js_int",
"ruma-api", "ruma-api",
"ruma-common", "ruma-common",
"ruma-events", "ruma-events",
"ruma-identifiers", "ruma-identifiers 0.17.0 (git+https://github.com/ruma/ruma?rev=08fbace)",
"ruma-serde", "ruma-serde",
"serde", "serde",
"serde_json", "serde_json",
@ -1598,11 +1601,10 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.1.3" version = "0.2.0"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"js_int", "js_int",
"matches",
"ruma-serde", "ruma-serde",
"serde", "serde",
"serde_json", "serde_json",
@ -1612,12 +1614,12 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.21.3" version = "0.21.3"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
"ruma-events-macros", "ruma-events-macros",
"ruma-identifiers", "ruma-identifiers 0.17.0 (git+https://github.com/ruma/ruma?rev=08fbace)",
"ruma-serde", "ruma-serde",
"serde", "serde",
"serde_json", "serde_json",
@ -1627,7 +1629,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events-macros" name = "ruma-events-macros"
version = "0.21.3" version = "0.21.3"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1637,14 +1639,13 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.0.2" version = "0.0.2"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"js_int", "js_int",
"matches",
"ruma-api", "ruma-api",
"ruma-common", "ruma-common",
"ruma-events", "ruma-events",
"ruma-identifiers", "ruma-identifiers 0.17.0 (git+https://github.com/ruma/ruma?rev=08fbace)",
"ruma-serde", "ruma-serde",
"serde", "serde",
"serde_json", "serde_json",
@ -1652,19 +1653,39 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers" name = "ruma-identifiers"
version = "0.17.0-pre.1" version = "0.17.0"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"matches",
"rand", "rand",
"serde", "serde",
"strum", "strum",
] ]
[[package]]
name = "ruma-identifiers"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7046d6ff26cf4f5b8bc77af68527544c61e32cab5810c40035c6491c08da0d3"
dependencies = [
"serde",
"strum",
]
[[package]]
name = "ruma-identifiers-macros"
version = "0.17.0"
source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [
"proc-macro2",
"quote",
"ruma-identifiers 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syn",
]
[[package]] [[package]]
name = "ruma-serde" name = "ruma-serde"
version = "0.2.2" version = "0.2.2"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"itoa", "itoa",
@ -1676,7 +1697,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.6.0-dev.1" version = "0.6.0-dev.1"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029" source = "git+https://github.com/ruma/ruma?rev=08fbace#08fbace022f732319b9c5d2b97954b935bf39bf2"
dependencies = [ dependencies = [
"base64 0.12.3", "base64 0.12.3",
"ring", "ring",
@ -1857,14 +1878,15 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
[[package]] [[package]]
name = "sha2" name = "sha2"
version = "0.8.2" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1"
dependencies = [ dependencies = [
"block-buffer", "block-buffer",
"cfg-if",
"cpuid-bool",
"digest", "digest",
"fake-simd", "opaque-debug 0.3.0",
"opaque-debug",
] ]
[[package]] [[package]]
@ -2010,12 +2032,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "subtle"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee"
[[package]] [[package]]
name = "subtle" name = "subtle"
version = "2.2.3" version = "2.2.3"
@ -2024,7 +2040,7 @@ checksum = "502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.33" version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0" checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0"
dependencies = [ dependencies = [
@ -2123,9 +2139,9 @@ checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "0.2.21" version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
@ -2208,9 +2224,9 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
[[package]] [[package]]
name = "tracing" name = "tracing"
version = "0.1.16" version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e2a2de6b0d5cbb13fc21193a2296888eaab62b6044479aafb3c54c01c29fcd" checksum = "dbdf4ccd1652592b01286a5dbe1e2a77d78afaa34beadd9872a5f7396f92aaa9"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"log", "log",
@ -2279,12 +2295,12 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]] [[package]]
name = "universal-hash" name = "universal-hash"
version = "0.3.0" 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 = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"subtle 2.2.3", "subtle",
] ]
[[package]] [[package]]
@ -2478,9 +2494,3 @@ name = "yansi"
version = "0.5.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71"
[[package]]
name = "zeroize"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8"

View File

@ -27,4 +27,4 @@ reqwest = "0.10.6"
base64 = "0.12.1" base64 = "0.12.1"
thiserror = "1.0.19" thiserror = "1.0.19"
image = { version = "0.23.4", default-features = false, features = ["jpeg", "png", "gif"] } image = { version = "0.23.4", default-features = false, features = ["jpeg", "png", "gif"] }
ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "b55f827" } ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "08fbace" }

View File

@ -169,14 +169,14 @@ pub fn register_route(
if let Some(auth) = &body.auth { if let Some(auth) = &body.auth {
let (worked, uiaainfo) = let (worked, uiaainfo) =
db.uiaa db.uiaa
.try_auth(&user_id, "", auth, &uiaainfo, &db.users, &db.globals)?; .try_auth(&user_id, "".into(), auth, &uiaainfo, &db.users, &db.globals)?;
if !worked { if !worked {
return Err(Error::Uiaa(uiaainfo)); return Err(Error::Uiaa(uiaainfo));
} }
// Success! // Success!
} else { } else {
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH)); uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
db.uiaa.create(&user_id, "", &uiaainfo)?; db.uiaa.create(&user_id, "".into(), &uiaainfo)?;
return Err(Error::Uiaa(uiaainfo)); return Err(Error::Uiaa(uiaainfo));
} }
@ -189,7 +189,7 @@ pub fn register_route(
let device_id = body let device_id = body
.device_id .device_id
.clone() .clone()
.unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH)); .unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH).into());
// Generate new token for the device // Generate new token for the device
let token = utils::random_string(TOKEN_LENGTH); let token = utils::random_string(TOKEN_LENGTH);
@ -300,7 +300,7 @@ pub fn logout_route(
let user_id = body.user_id.as_ref().expect("user is authenticated"); let user_id = body.user_id.as_ref().expect("user is authenticated");
let device_id = body.device_id.as_ref().expect("user is authenticated"); let device_id = body.device_id.as_ref().expect("user is authenticated");
db.users.remove_device(&user_id, &device_id)?; db.users.remove_device(&user_id, device_id)?;
Ok(logout::Response.into()) Ok(logout::Response.into())
} }
@ -340,14 +340,9 @@ pub fn change_password_route(
}; };
if let Some(auth) = &body.auth { if let Some(auth) = &body.auth {
let (worked, uiaainfo) = db.uiaa.try_auth( let (worked, uiaainfo) =
&user_id, db.uiaa
&device_id, .try_auth(&user_id, device_id, auth, &uiaainfo, &db.users, &db.globals)?;
auth,
&uiaainfo,
&db.users,
&db.globals,
)?;
if !worked { if !worked {
return Err(Error::Uiaa(uiaainfo)); return Err(Error::Uiaa(uiaainfo));
} }
@ -452,11 +447,11 @@ pub fn deactivate_route(
pub fn get_capabilities_route() -> ConduitResult<get_capabilities::Response> { pub fn get_capabilities_route() -> ConduitResult<get_capabilities::Response> {
let mut available = BTreeMap::new(); let mut available = BTreeMap::new();
available.insert( available.insert(
RoomVersionId::version_5(), RoomVersionId::Version5,
get_capabilities::RoomVersionStability::Stable, get_capabilities::RoomVersionStability::Stable,
); );
available.insert( available.insert(
RoomVersionId::version_6(), RoomVersionId::Version6,
get_capabilities::RoomVersionStability::Stable, get_capabilities::RoomVersionStability::Stable,
); );
@ -890,7 +885,7 @@ pub fn get_keys_route(
device_display_name: metadata.display_name, device_display_name: metadata.display_name,
}); });
container.insert(device_id.into(), keys); container.insert(device_id, keys);
} }
} }
device_keys.insert(user_id.clone(), container); device_keys.insert(user_id.clone(), container);
@ -909,7 +904,7 @@ pub fn get_keys_route(
device_display_name: metadata.display_name, device_display_name: metadata.display_name,
}); });
container.insert(device_id.as_ref().into(), keys); container.insert(device_id.clone(), keys);
} }
device_keys.insert(user_id.clone(), container); device_keys.insert(user_id.clone(), container);
} }
@ -1212,7 +1207,7 @@ pub fn create_room_route(
.creation_content .creation_content
.as_ref() .as_ref()
.and_then(|c| c.predecessor.clone()); .and_then(|c| c.predecessor.clone());
content.room_version = RoomVersionId::version_6(); content.room_version = RoomVersionId::Version6;
// 1. The room create event // 1. The room create event
db.rooms.append_pdu( db.rooms.append_pdu(
@ -1298,15 +1293,14 @@ pub fn create_room_route(
user_id.clone(), user_id.clone(),
EventType::RoomJoinRules, EventType::RoomJoinRules,
match preset { match preset {
create_room::RoomPreset::PublicChat => { create_room::RoomPreset::PublicChat => serde_json::to_value(
serde_json::to_value(join_rules::JoinRulesEventContent { join_rules::JoinRulesEventContent::new(join_rules::JoinRule::Public),
join_rule: join_rules::JoinRule::Public, )
}) .expect("event is valid, we just created it"),
.expect("event is valid, we just created it") // according to spec "invite" is the default
} _ => serde_json::to_value(join_rules::JoinRulesEventContent::new(
_ => serde_json::to_value(join_rules::JoinRulesEventContent { join_rules::JoinRule::Invite,
join_rule: join_rules::JoinRule::Invite, ))
})
.expect("event is valid, we just created it"), .expect("event is valid, we just created it"),
}, },
None, None,

View File

@ -4,7 +4,7 @@ use ruma::{
error::ErrorKind, error::ErrorKind,
r0::uiaa::{AuthData, UiaaInfo}, r0::uiaa::{AuthData, UiaaInfo},
}, },
identifiers::UserId, identifiers::{DeviceId, UserId},
}; };
pub struct Uiaa { pub struct Uiaa {
@ -13,14 +13,19 @@ pub struct Uiaa {
impl Uiaa { impl Uiaa {
/// Creates a new Uiaa session. Make sure the session token is unique. /// Creates a new Uiaa session. Make sure the session token is unique.
pub fn create(&self, user_id: &UserId, device_id: &str, uiaainfo: &UiaaInfo) -> Result<()> { pub fn create(
&self,
user_id: &UserId,
device_id: &DeviceId,
uiaainfo: &UiaaInfo,
) -> Result<()> {
self.update_uiaa_session(user_id, device_id, Some(uiaainfo)) self.update_uiaa_session(user_id, device_id, Some(uiaainfo))
} }
pub fn try_auth( pub fn try_auth(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
auth: &AuthData, auth: &AuthData,
uiaainfo: &UiaaInfo, uiaainfo: &UiaaInfo,
users: &super::users::Users, users: &super::users::Users,
@ -130,7 +135,7 @@ impl Uiaa {
// UIAA was successful! Remove this session and return true // UIAA was successful! Remove this session and return true
self.update_uiaa_session(user_id, device_id, None)?; self.update_uiaa_session(user_id, device_id, None)?;
return Ok((true, uiaainfo)); Ok((true, uiaainfo))
} else { } else {
panic!("FallbackAcknowledgement is not supported yet"); panic!("FallbackAcknowledgement is not supported yet");
} }
@ -139,12 +144,12 @@ impl Uiaa {
fn update_uiaa_session( fn update_uiaa_session(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
uiaainfo: Option<&UiaaInfo>, uiaainfo: Option<&UiaaInfo>,
) -> Result<()> { ) -> Result<()> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
if let Some(uiaainfo) = uiaainfo { if let Some(uiaainfo) = uiaainfo {
self.userdeviceid_uiaainfo.insert( self.userdeviceid_uiaainfo.insert(
@ -161,12 +166,12 @@ impl Uiaa {
fn get_uiaa_session( fn get_uiaa_session(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
session: &str, session: &str,
) -> Result<UiaaInfo> { ) -> Result<UiaaInfo> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
let uiaainfo = serde_json::from_slice::<UiaaInfo>( let uiaainfo = serde_json::from_slice::<UiaaInfo>(
&self &self

View File

@ -177,7 +177,7 @@ impl Users {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
self.userdeviceid_metadata.insert( self.userdeviceid_metadata.insert(
userdeviceid, userdeviceid,
@ -191,16 +191,16 @@ impl Users {
.as_bytes(), .as_bytes(),
)?; )?;
self.set_token(user_id, device_id, token)?; self.set_token(user_id, &device_id, token)?;
Ok(()) Ok(())
} }
/// Removes a device from a user. /// Removes a device from a user.
pub fn remove_device(&self, user_id: &UserId, device_id: &str) -> Result<()> { pub fn remove_device(&self, user_id: &UserId, device_id: &DeviceId) -> Result<()> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
// Remove tokens // Remove tokens
if let Some(old_token) = self.userdeviceid_token.remove(&userdeviceid)? { if let Some(old_token) = self.userdeviceid_token.remove(&userdeviceid)? {
@ -223,7 +223,7 @@ impl Users {
} }
/// Returns an iterator over all device ids of this user. /// Returns an iterator over all device ids of this user.
pub fn all_device_ids(&self, user_id: &UserId) -> impl Iterator<Item = Result<String>> { pub fn all_device_ids(&self, user_id: &UserId) -> impl Iterator<Item = Result<Box<DeviceId>>> {
let mut prefix = user_id.to_string().as_bytes().to_vec(); let mut prefix = user_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
// All devices have metadata // All devices have metadata
@ -237,17 +237,16 @@ impl Users {
.next() .next()
.ok_or_else(|| Error::bad_database("UserDevice ID in db is invalid."))?, .ok_or_else(|| Error::bad_database("UserDevice ID in db is invalid."))?,
) )
.map_err(|_| { .map_err(|_| Error::bad_database("Device ID in userdeviceid_metadata is invalid."))?
Error::bad_database("Device ID in userdeviceid_metadata is invalid.") .into())
})?)
}) })
} }
/// Replaces the access token of one device. /// Replaces the access token of one device.
fn set_token(&self, user_id: &UserId, device_id: &str, token: &str) -> Result<()> { fn set_token(&self, user_id: &UserId, device_id: &DeviceId, token: &str) -> Result<()> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
// All devices have metadata // All devices have metadata
assert!(self.userdeviceid_metadata.get(&userdeviceid)?.is_some()); assert!(self.userdeviceid_metadata.get(&userdeviceid)?.is_some());
@ -268,13 +267,13 @@ impl Users {
pub fn add_one_time_key( pub fn add_one_time_key(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
one_time_key_key: &AlgorithmAndDeviceId, one_time_key_key: &AlgorithmAndDeviceId,
one_time_key_value: &OneTimeKey, one_time_key_value: &OneTimeKey,
) -> Result<()> { ) -> Result<()> {
let mut key = user_id.to_string().as_bytes().to_vec(); let mut key = user_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);
key.extend_from_slice(device_id.as_bytes()); key.extend_from_slice(device_id.as_str().as_bytes());
// All devices have metadata // All devices have metadata
// Only existing devices should be able to call this. // Only existing devices should be able to call this.
@ -301,12 +300,12 @@ impl Users {
pub fn take_one_time_key( pub fn take_one_time_key(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
key_algorithm: &KeyAlgorithm, key_algorithm: &KeyAlgorithm,
) -> Result<Option<(AlgorithmAndDeviceId, OneTimeKey)>> { ) -> Result<Option<(AlgorithmAndDeviceId, OneTimeKey)>> {
let mut prefix = user_id.to_string().as_bytes().to_vec(); let mut prefix = user_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
prefix.extend_from_slice(device_id.as_bytes()); prefix.extend_from_slice(device_id.as_str().as_bytes());
prefix.push(0xff); prefix.push(0xff);
prefix.push(b'"'); // Annoying quotation mark prefix.push(b'"'); // Annoying quotation mark
prefix.extend_from_slice(key_algorithm.to_string().as_bytes()); prefix.extend_from_slice(key_algorithm.to_string().as_bytes());
@ -337,11 +336,11 @@ impl Users {
pub fn count_one_time_keys( pub fn count_one_time_keys(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
) -> Result<BTreeMap<KeyAlgorithm, UInt>> { ) -> Result<BTreeMap<KeyAlgorithm, UInt>> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
let mut counts = BTreeMap::new(); let mut counts = BTreeMap::new();
@ -370,13 +369,13 @@ impl Users {
pub fn add_device_keys( pub fn add_device_keys(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
device_keys: &DeviceKeys, device_keys: &DeviceKeys,
globals: &super::globals::Globals, globals: &super::globals::Globals,
) -> Result<()> { ) -> Result<()> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
self.keyid_key.insert( self.keyid_key.insert(
&userdeviceid, &userdeviceid,
@ -550,10 +549,14 @@ impl Users {
}) })
} }
pub fn get_device_keys(&self, user_id: &UserId, device_id: &str) -> Result<Option<DeviceKeys>> { pub fn get_device_keys(
&self,
user_id: &UserId,
device_id: &DeviceId,
) -> Result<Option<DeviceKeys>> {
let mut key = user_id.to_string().as_bytes().to_vec(); let mut key = user_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);
key.extend_from_slice(device_id.as_bytes()); key.extend_from_slice(device_id.as_str().as_bytes());
self.keyid_key.get(key)?.map_or(Ok(None), |bytes| { self.keyid_key.get(key)?.map_or(Ok(None), |bytes| {
Ok(Some(serde_json::from_slice(&bytes).map_err(|_| { Ok(Some(serde_json::from_slice(&bytes).map_err(|_| {
@ -633,14 +636,14 @@ impl Users {
&self, &self,
sender: &UserId, sender: &UserId,
target_user_id: &UserId, target_user_id: &UserId,
target_device_id: &str, target_device_id: &DeviceId,
event_type: &EventType, event_type: &EventType,
content: serde_json::Value, content: serde_json::Value,
globals: &super::globals::Globals, globals: &super::globals::Globals,
) -> Result<()> { ) -> Result<()> {
let mut key = target_user_id.to_string().as_bytes().to_vec(); let mut key = target_user_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);
key.extend_from_slice(target_device_id.as_bytes()); key.extend_from_slice(target_device_id.as_str().as_bytes());
key.push(0xff); key.push(0xff);
key.extend_from_slice(&globals.next_count()?.to_be_bytes()); key.extend_from_slice(&globals.next_count()?.to_be_bytes());
@ -660,14 +663,14 @@ impl Users {
pub fn take_to_device_events( pub fn take_to_device_events(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
max: usize, max: usize,
) -> Result<Vec<EventJson<AnyToDeviceEvent>>> { ) -> Result<Vec<EventJson<AnyToDeviceEvent>>> {
let mut events = Vec::new(); let mut events = Vec::new();
let mut prefix = user_id.to_string().as_bytes().to_vec(); let mut prefix = user_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
prefix.extend_from_slice(device_id.as_bytes()); prefix.extend_from_slice(device_id.as_str().as_bytes());
prefix.push(0xff); prefix.push(0xff);
for result in self.todeviceid_events.scan_prefix(&prefix).take(max) { for result in self.todeviceid_events.scan_prefix(&prefix).take(max) {
@ -685,12 +688,12 @@ impl Users {
pub fn update_device_metadata( pub fn update_device_metadata(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &str, device_id: &DeviceId,
device: &Device, device: &Device,
) -> Result<()> { ) -> Result<()> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
// Only existing devices should be able to call this. // Only existing devices should be able to call this.
assert!(self.userdeviceid_metadata.get(&userdeviceid)?.is_some()); assert!(self.userdeviceid_metadata.get(&userdeviceid)?.is_some());
@ -706,10 +709,14 @@ impl Users {
} }
/// Get device metadata. /// Get device metadata.
pub fn get_device_metadata(&self, user_id: &UserId, device_id: &str) -> Result<Option<Device>> { pub fn get_device_metadata(
&self,
user_id: &UserId,
device_id: &DeviceId,
) -> Result<Option<Device>> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_str().as_bytes());
self.userdeviceid_metadata self.userdeviceid_metadata
.get(&userdeviceid)? .get(&userdeviceid)?

View File

@ -2,47 +2,46 @@ use js_int::uint;
use ruma::{ use ruma::{
identifiers::UserId, identifiers::UserId,
push::{ push::{
Action, ConditionalPushRule, PatternedPushRule, PushCondition, RoomMemberCountIs, Ruleset, Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule,
Tweak, PatternedPushRuleInit, PushCondition, RoomMemberCountIs, Ruleset, Tweak,
}, },
}; };
pub fn default_pushrules(user_id: &UserId) -> Ruleset { pub fn default_pushrules(user_id: &UserId) -> Ruleset {
Ruleset { let mut rules = Ruleset::default();
content: vec![contains_user_name_rule(&user_id)], rules.content = vec![contains_user_name_rule(&user_id)];
override_: vec![ rules.override_ = vec![
master_rule(), master_rule(),
suppress_notices_rule(), suppress_notices_rule(),
invite_for_me_rule(), invite_for_me_rule(),
member_event_rule(), member_event_rule(),
contains_display_name_rule(), contains_display_name_rule(),
tombstone_rule(), tombstone_rule(),
roomnotif_rule(), roomnotif_rule(),
], ];
room: vec![], rules.underride = vec![
sender: vec![], call_rule(),
underride: vec![ encrypted_room_one_to_one_rule(),
call_rule(), room_one_to_one_rule(),
encrypted_room_one_to_one_rule(), message_rule(),
room_one_to_one_rule(), encrypted_rule(),
message_rule(), ];
encrypted_rule(), rules
],
}
} }
pub fn master_rule() -> ConditionalPushRule { pub fn master_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![Action::DontNotify], actions: vec![Action::DontNotify],
default: true, default: true,
enabled: false, enabled: false,
rule_id: ".m.rule.master".to_owned(), rule_id: ".m.rule.master".to_owned(),
conditions: vec![], conditions: vec![],
} }
.into()
} }
pub fn suppress_notices_rule() -> ConditionalPushRule { pub fn suppress_notices_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![Action::DontNotify], actions: vec![Action::DontNotify],
default: true, default: true,
enabled: true, enabled: true,
@ -52,10 +51,11 @@ pub fn suppress_notices_rule() -> ConditionalPushRule {
pattern: "m.notice".to_owned(), pattern: "m.notice".to_owned(),
}], }],
} }
.into()
} }
pub fn invite_for_me_rule() -> ConditionalPushRule { pub fn invite_for_me_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![ actions: vec![
Action::Notify, Action::Notify,
Action::SetTweak(Tweak::Sound("default".to_owned())), Action::SetTweak(Tweak::Sound("default".to_owned())),
@ -69,10 +69,11 @@ pub fn invite_for_me_rule() -> ConditionalPushRule {
pattern: "m.invite".to_owned(), pattern: "m.invite".to_owned(),
}], }],
} }
.into()
} }
pub fn member_event_rule() -> ConditionalPushRule { pub fn member_event_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![Action::DontNotify], actions: vec![Action::DontNotify],
default: true, default: true,
enabled: true, enabled: true,
@ -82,10 +83,11 @@ pub fn member_event_rule() -> ConditionalPushRule {
pattern: "type".to_owned(), pattern: "type".to_owned(),
}], }],
} }
.into()
} }
pub fn contains_display_name_rule() -> ConditionalPushRule { pub fn contains_display_name_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![ actions: vec![
Action::Notify, Action::Notify,
Action::SetTweak(Tweak::Sound("default".to_owned())), Action::SetTweak(Tweak::Sound("default".to_owned())),
@ -96,10 +98,11 @@ pub fn contains_display_name_rule() -> ConditionalPushRule {
rule_id: ".m.rule.contains_display_name".to_owned(), rule_id: ".m.rule.contains_display_name".to_owned(),
conditions: vec![PushCondition::ContainsDisplayName], conditions: vec![PushCondition::ContainsDisplayName],
} }
.into()
} }
pub fn tombstone_rule() -> ConditionalPushRule { pub fn tombstone_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(true))], actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(true))],
default: true, default: true,
enabled: true, enabled: true,
@ -115,10 +118,11 @@ pub fn tombstone_rule() -> ConditionalPushRule {
}, },
], ],
} }
.into()
} }
pub fn roomnotif_rule() -> ConditionalPushRule { pub fn roomnotif_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(true))], actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(true))],
default: true, default: true,
enabled: true, enabled: true,
@ -133,10 +137,11 @@ pub fn roomnotif_rule() -> ConditionalPushRule {
}, },
], ],
} }
.into()
} }
pub fn contains_user_name_rule(user_id: &UserId) -> PatternedPushRule { pub fn contains_user_name_rule(user_id: &UserId) -> PatternedPushRule {
PatternedPushRule { PatternedPushRuleInit {
actions: vec![ actions: vec![
Action::Notify, Action::Notify,
Action::SetTweak(Tweak::Sound("default".to_owned())), Action::SetTweak(Tweak::Sound("default".to_owned())),
@ -147,10 +152,11 @@ pub fn contains_user_name_rule(user_id: &UserId) -> PatternedPushRule {
rule_id: ".m.rule.contains_user_name".to_owned(), rule_id: ".m.rule.contains_user_name".to_owned(),
pattern: user_id.localpart().to_owned(), pattern: user_id.localpart().to_owned(),
} }
.into()
} }
pub fn call_rule() -> ConditionalPushRule { pub fn call_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![ actions: vec![
Action::Notify, Action::Notify,
Action::SetTweak(Tweak::Sound("ring".to_owned())), Action::SetTweak(Tweak::Sound("ring".to_owned())),
@ -164,10 +170,11 @@ pub fn call_rule() -> ConditionalPushRule {
pattern: "m.call.invite".to_owned(), pattern: "m.call.invite".to_owned(),
}], }],
} }
.into()
} }
pub fn encrypted_room_one_to_one_rule() -> ConditionalPushRule { pub fn encrypted_room_one_to_one_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![ actions: vec![
Action::Notify, Action::Notify,
Action::SetTweak(Tweak::Sound("default".to_owned())), Action::SetTweak(Tweak::Sound("default".to_owned())),
@ -186,10 +193,11 @@ pub fn encrypted_room_one_to_one_rule() -> ConditionalPushRule {
}, },
], ],
} }
.into()
} }
pub fn room_one_to_one_rule() -> ConditionalPushRule { pub fn room_one_to_one_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![ actions: vec![
Action::Notify, Action::Notify,
Action::SetTweak(Tweak::Sound("default".to_owned())), Action::SetTweak(Tweak::Sound("default".to_owned())),
@ -208,10 +216,11 @@ pub fn room_one_to_one_rule() -> ConditionalPushRule {
}, },
], ],
} }
.into()
} }
pub fn message_rule() -> ConditionalPushRule { pub fn message_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(false))], actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(false))],
default: true, default: true,
enabled: true, enabled: true,
@ -221,10 +230,11 @@ pub fn message_rule() -> ConditionalPushRule {
pattern: "m.room.message".to_owned(), pattern: "m.room.message".to_owned(),
}], }],
} }
.into()
} }
pub fn encrypted_rule() -> ConditionalPushRule { pub fn encrypted_rule() -> ConditionalPushRule {
ConditionalPushRule { ConditionalPushRuleInit {
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(false))], actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(false))],
default: true, default: true,
enabled: true, enabled: true,
@ -234,4 +244,5 @@ pub fn encrypted_rule() -> ConditionalPushRule {
pattern: "m.room.encrypted".to_owned(), pattern: "m.room.encrypted".to_owned(),
}], }],
} }
.into()
} }

View File

@ -7,7 +7,10 @@ use rocket::{
Outcome::*, Outcome::*,
Request, State, Request, State,
}; };
use ruma::{api::Endpoint, identifiers::UserId}; use ruma::{
api::Endpoint,
identifiers::{DeviceId, UserId},
};
use std::{convert::TryInto, io::Cursor, ops::Deref}; use std::{convert::TryInto, io::Cursor, ops::Deref};
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
@ -18,7 +21,7 @@ const MESSAGE_LIMIT: u64 = 20 * 1024 * 1024; // 20 MB
pub struct Ruma<T> { pub struct Ruma<T> {
pub body: T, pub body: T,
pub user_id: Option<UserId>, pub user_id: Option<UserId>,
pub device_id: Option<String>, pub device_id: Option<Box<DeviceId>>,
pub json_body: Option<Box<serde_json::value::RawValue>>, // This is None when body is not a valid string pub json_body: Option<Box<serde_json::value::RawValue>>, // This is None when body is not a valid string
} }
@ -63,7 +66,7 @@ impl<'a, T: Endpoint> FromTransformedData<'a> for Ruma<T> {
match db.users.find_from_token(&token).unwrap() { match db.users.find_from_token(&token).unwrap() {
// TODO: M_UNKNOWN_TOKEN // TODO: M_UNKNOWN_TOKEN
None => return Failure((Status::Unauthorized, ())), None => return Failure((Status::Unauthorized, ())),
Some((user_id, device_id)) => (Some(user_id), Some(device_id)), Some((user_id, device_id)) => (Some(user_id), Some(device_id.into())),
} }
} else { } else {
(None, None) (None, None)