forked from jmug/stoatchat
Migrate the rest of the code.
This commit is contained in:
197
Cargo.lock
generated
197
Cargo.lock
generated
@@ -94,6 +94,7 @@ dependencies = [
|
|||||||
"num_cpus",
|
"num_cpus",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"tokio 0.2.25",
|
"tokio 0.2.25",
|
||||||
|
"tokio 1.9.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -501,16 +502,6 @@ version = "0.1.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cookie"
|
|
||||||
version = "0.15.0-dev"
|
|
||||||
source = "git+https://github.com/SergioBenitez/cookie-rs.git?rev=1c3ca83#1c3ca838543b60a4448d279dc4b903cc7a2bc22a"
|
|
||||||
dependencies = [
|
|
||||||
"percent-encoding",
|
|
||||||
"time 0.2.25",
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cookie"
|
name = "cookie"
|
||||||
version = "0.15.1"
|
version = "0.15.1"
|
||||||
@@ -641,32 +632,14 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "devise"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047"
|
|
||||||
dependencies = [
|
|
||||||
"devise_codegen 0.3.0",
|
|
||||||
"devise_core 0.3.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "devise"
|
name = "devise"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "50c7580b072f1c8476148f16e0a0d5dedddab787da98d86c5082c5e9ed8ab595"
|
checksum = "50c7580b072f1c8476148f16e0a0d5dedddab787da98d86c5082c5e9ed8ab595"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devise_codegen 0.3.1",
|
"devise_codegen",
|
||||||
"devise_core 0.3.1",
|
"devise_core",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "devise_codegen"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047"
|
|
||||||
dependencies = [
|
|
||||||
"devise_core 0.3.0",
|
|
||||||
"quote",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -675,22 +648,10 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "123c73e7a6e51b05c75fe1a1b2f4e241399ea5740ed810b0e3e6cacd9db5e7b2"
|
checksum = "123c73e7a6e51b05c75fe1a1b2f4e241399ea5740ed810b0e3e6cacd9db5e7b2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devise_core 0.3.1",
|
"devise_core",
|
||||||
"quote",
|
"quote",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "devise_core"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "git+https://github.com/SergioBenitez/Devise.git?rev=3648468#3648468a9ede9ca896cd35bc1eb818c7a9fb3047"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"proc-macro2",
|
|
||||||
"proc-macro2-diagnostics",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "devise_core"
|
name = "devise_core"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -1690,17 +1651,6 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mio-uds"
|
|
||||||
version = "0.6.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
|
|
||||||
dependencies = [
|
|
||||||
"iovec",
|
|
||||||
"libc",
|
|
||||||
"mio 0.6.23",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miow"
|
name = "miow"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@@ -2272,20 +2222,6 @@ dependencies = [
|
|||||||
"yansi",
|
"yansi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "prometheus"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c8425533e7122f0c3cc7a37e6244b16ad3a2cc32ae7ac6276e2a75da0d9c200d"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"fnv",
|
|
||||||
"lazy_static",
|
|
||||||
"parking_lot",
|
|
||||||
"regex",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quanta"
|
name = "quanta"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
@@ -2541,7 +2477,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rauth"
|
name = "rauth"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://gitlab.insrt.uk/insert/rauth?rev=51546e5a1ba0dfe3ec3bd0b060fa51fc3102c96f#51546e5a1ba0dfe3ec3bd0b060fa51fc3102c96f"
|
source = "git+https://gitlab.insrt.uk/insert/rauth?rev=840ad003263fd5570aba4866e7d72e4fc1b3e95a#840ad003263fd5570aba4866e7d72e4fc1b3e95a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"handlebars",
|
"handlebars",
|
||||||
@@ -2552,8 +2488,7 @@ dependencies = [
|
|||||||
"nanoid 0.3.0",
|
"nanoid 0.3.0",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rocket 0.5.0-dev",
|
"rocket",
|
||||||
"rocket_contrib",
|
|
||||||
"rust-argon2",
|
"rust-argon2",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -2711,10 +2646,9 @@ dependencies = [
|
|||||||
"rauth",
|
"rauth",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rocket 0.5.0-rc.1",
|
"rocket",
|
||||||
"rocket-governor",
|
"rocket-governor",
|
||||||
"rocket_cors",
|
"rocket_cors",
|
||||||
"rocket_prometheus",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"time 0.2.25",
|
"time 0.2.25",
|
||||||
@@ -2739,35 +2673,6 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rocket"
|
|
||||||
version = "0.5.0-dev"
|
|
||||||
source = "git+https://github.com/SergioBenitez/Rocket?rev=031948c1daaa146128d8a435be116476f2adde00#031948c1daaa146128d8a435be116476f2adde00"
|
|
||||||
dependencies = [
|
|
||||||
"async-trait",
|
|
||||||
"atomic",
|
|
||||||
"atty",
|
|
||||||
"binascii",
|
|
||||||
"either",
|
|
||||||
"figment",
|
|
||||||
"futures",
|
|
||||||
"log",
|
|
||||||
"memchr",
|
|
||||||
"num_cpus",
|
|
||||||
"parking_lot",
|
|
||||||
"rand 0.7.3",
|
|
||||||
"ref-cast",
|
|
||||||
"rocket_codegen 0.5.0-dev",
|
|
||||||
"rocket_http 0.5.0-dev",
|
|
||||||
"serde",
|
|
||||||
"state 0.4.2",
|
|
||||||
"time 0.2.25",
|
|
||||||
"tokio 0.2.25",
|
|
||||||
"ubyte",
|
|
||||||
"version_check",
|
|
||||||
"yansi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket"
|
name = "rocket"
|
||||||
version = "0.5.0-rc.1"
|
version = "0.5.0-rc.1"
|
||||||
@@ -2792,11 +2697,11 @@ dependencies = [
|
|||||||
"pin-project-lite 0.2.4",
|
"pin-project-lite 0.2.4",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
"ref-cast",
|
"ref-cast",
|
||||||
"rocket_codegen 0.5.0-rc.1",
|
"rocket_codegen",
|
||||||
"rocket_http 0.5.0-rc.1",
|
"rocket_http",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"state 0.5.2",
|
"state",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"time 0.2.25",
|
"time 0.2.25",
|
||||||
"tokio 1.9.0",
|
"tokio 1.9.0",
|
||||||
@@ -2815,19 +2720,7 @@ checksum = "3a7603d1d66d1c4c41997f1f80fb624c16fd8a063a0f562d6e511e7eec4d26d2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"governor",
|
"governor",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"rocket 0.5.0-rc.1",
|
"rocket",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rocket_codegen"
|
|
||||||
version = "0.5.0-dev"
|
|
||||||
source = "git+https://github.com/SergioBenitez/Rocket?rev=031948c1daaa146128d8a435be116476f2adde00#031948c1daaa146128d8a435be116476f2adde00"
|
|
||||||
dependencies = [
|
|
||||||
"devise 0.3.0",
|
|
||||||
"glob",
|
|
||||||
"indexmap",
|
|
||||||
"quote",
|
|
||||||
"rocket_http 0.5.0-dev",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2836,36 +2729,24 @@ version = "0.5.0-rc.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "66f5fa462f7eb958bba8710c17c5d774bbbd59809fa76fb1957af7e545aea8bb"
|
checksum = "66f5fa462f7eb958bba8710c17c5d774bbbd59809fa76fb1957af7e545aea8bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devise 0.3.1",
|
"devise",
|
||||||
"glob",
|
"glob",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rocket_http 0.5.0-rc.1",
|
"rocket_http",
|
||||||
"syn",
|
"syn",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rocket_contrib"
|
|
||||||
version = "0.5.0-dev"
|
|
||||||
source = "git+https://github.com/SergioBenitez/Rocket?rev=031948c1daaa146128d8a435be116476f2adde00#031948c1daaa146128d8a435be116476f2adde00"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
"rocket 0.5.0-dev",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"tokio 0.2.25",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket_cors"
|
name = "rocket_cors"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
source = "git+https://github.com/insertish/rocket_cors?branch=master#a301882a3ae80be9cbe2de7030c5ca7842e1307e"
|
source = "git+https://github.com/lawliet89/rocket_cors?rev=5843861a88958c16bfaa0b40f0d8910772bcd2f6#5843861a88958c16bfaa0b40f0d8910772bcd2f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
"rocket 0.5.0-dev",
|
"rocket",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"unicase",
|
"unicase",
|
||||||
@@ -2873,38 +2754,13 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rocket_http"
|
|
||||||
version = "0.5.0-dev"
|
|
||||||
source = "git+https://github.com/SergioBenitez/Rocket?rev=031948c1daaa146128d8a435be116476f2adde00#031948c1daaa146128d8a435be116476f2adde00"
|
|
||||||
dependencies = [
|
|
||||||
"cookie 0.15.0-dev",
|
|
||||||
"either",
|
|
||||||
"http",
|
|
||||||
"hyper 0.13.10",
|
|
||||||
"indexmap",
|
|
||||||
"log",
|
|
||||||
"mime",
|
|
||||||
"parking_lot",
|
|
||||||
"pear",
|
|
||||||
"percent-encoding",
|
|
||||||
"ref-cast",
|
|
||||||
"smallvec",
|
|
||||||
"state 0.4.2",
|
|
||||||
"time 0.2.25",
|
|
||||||
"tokio 0.2.25",
|
|
||||||
"uncased",
|
|
||||||
"unicode-xid",
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket_http"
|
name = "rocket_http"
|
||||||
version = "0.5.0-rc.1"
|
version = "0.5.0-rc.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23c8b7d512d2fcac2316ebe590cde67573844b99e6cc9ee0f53375fa16e25ebd"
|
checksum = "23c8b7d512d2fcac2316ebe590cde67573844b99e6cc9ee0f53375fa16e25ebd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cookie 0.15.1",
|
"cookie",
|
||||||
"either",
|
"either",
|
||||||
"http",
|
"http",
|
||||||
"hyper 0.14.11",
|
"hyper 0.14.11",
|
||||||
@@ -2920,21 +2776,12 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"stable-pattern",
|
"stable-pattern",
|
||||||
"state 0.5.2",
|
"state",
|
||||||
"time 0.2.25",
|
"time 0.2.25",
|
||||||
"tokio 1.9.0",
|
"tokio 1.9.0",
|
||||||
"uncased",
|
"uncased",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rocket_prometheus"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "git+https://github.com/insertish/rocket_prometheus?rev=3d825aedb42793246c306a81fe67c5b187948983#3d825aedb42793246c306a81fe67c5b187948983"
|
|
||||||
dependencies = [
|
|
||||||
"prometheus",
|
|
||||||
"rocket 0.5.0-dev",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-argon2"
|
name = "rust-argon2"
|
||||||
version = "0.8.3"
|
version = "0.8.3"
|
||||||
@@ -3275,12 +3122,6 @@ dependencies = [
|
|||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "state"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "state"
|
name = "state"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
@@ -3529,16 +3370,12 @@ dependencies = [
|
|||||||
"futures-core",
|
"futures-core",
|
||||||
"iovec",
|
"iovec",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
|
||||||
"memchr",
|
"memchr",
|
||||||
"mio 0.6.23",
|
"mio 0.6.23",
|
||||||
"mio-uds",
|
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"pin-project-lite 0.1.11",
|
"pin-project-lite 0.1.11",
|
||||||
"signal-hook-registry",
|
|
||||||
"slab",
|
"slab",
|
||||||
"tokio-macros 0.2.6",
|
"tokio-macros 0.2.6",
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -33,16 +33,15 @@ lazy_static = "1.4.0"
|
|||||||
urlencoding = "1.1.1"
|
urlencoding = "1.1.1"
|
||||||
many-to-many = "0.1.2"
|
many-to-many = "0.1.2"
|
||||||
lettre = "0.10.0-alpha.4"
|
lettre = "0.10.0-alpha.4"
|
||||||
rocket-governor = "0.0.1-rc.9"
|
|
||||||
reqwest = { version = "0.10.8", features = ["json"] }
|
reqwest = { version = "0.10.8", features = ["json"] }
|
||||||
serde = { version = "1.0.115", features = ["derive"] }
|
serde = { version = "1.0.115", features = ["derive"] }
|
||||||
validator = { version = "0.11", features = ["derive"] }
|
validator = { version = "0.11", features = ["derive"] }
|
||||||
ctrlc = { version = "3.0", features = ["termination"] }
|
ctrlc = { version = "3.0", features = ["termination"] }
|
||||||
async-std = { version = "1.8.0", features = ["tokio02", "attributes"] }
|
rocket-governor = { version = "0.0.1-rc.9", features = ["logger"] }
|
||||||
async-tungstenite = { version = "0.10.0", features = ["async-std-runtime"] }
|
async-tungstenite = { version = "0.10.0", features = ["async-std-runtime"] }
|
||||||
|
async-std = { version = "1.8.0", features = ["tokio1", "tokio02", "attributes"] }
|
||||||
rocket = { version = "0.5.0-rc.1", default-features = false, features = ["json"] }
|
rocket = { version = "0.5.0-rc.1", default-features = false, features = ["json"] }
|
||||||
rocket_cors = { git = "https://github.com/insertish/rocket_cors", branch = "master" }
|
|
||||||
mongodb = { version = "1.2.2", features = ["tokio-runtime"], default-features = false }
|
mongodb = { version = "1.2.2", features = ["tokio-runtime"], default-features = false }
|
||||||
rauth = { git = "https://gitlab.insrt.uk/insert/rauth", rev = "51546e5a1ba0dfe3ec3bd0b060fa51fc3102c96f" }
|
rauth = { git = "https://gitlab.insrt.uk/insert/rauth", rev = "840ad003263fd5570aba4866e7d72e4fc1b3e95a" }
|
||||||
rocket_prometheus = { git = "https://github.com/insertish/rocket_prometheus", rev = "3d825aedb42793246c306a81fe67c5b187948983" }
|
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
||||||
hive_pubsub = { git = "https://gitlab.insrt.uk/insert/hive", rev = "a89826df2b30166220e68a6ed01a58b751456604", features = ["mongo"] }
|
hive_pubsub = { git = "https://gitlab.insrt.uk/insert/hive", rev = "a89826df2b30166220e68a6ed01a58b751456604", features = ["mongo"] }
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use crate::database::*;
|
|||||||
use crate::util::result::{Error, Result};
|
use crate::util::result::{Error, Result};
|
||||||
|
|
||||||
use mongodb::bson::{doc, from_document};
|
use mongodb::bson::{doc, from_document};
|
||||||
use rocket::http::RawStr;
|
|
||||||
use rocket::request::FromParam;
|
use rocket::request::FromParam;
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
@@ -127,9 +126,9 @@ impl User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'r> FromParam<'r> for Ref {
|
impl<'r> FromParam<'r> for Ref {
|
||||||
type Error = &'r RawStr;
|
type Error = &'r str;
|
||||||
|
|
||||||
fn from_param(param: &'r RawStr) -> Result<Self, Self::Error> {
|
fn from_param(param: &'r str) -> Result<Self, Self::Error> {
|
||||||
if let Ok(result) = Ref::from(param.to_string()) {
|
if let Ok(result) = Ref::from(param.to_string()) {
|
||||||
if result.validate().is_ok() {
|
if result.validate().is_ok() {
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ use crate::database::*;
|
|||||||
use mongodb::bson::{doc, from_document};
|
use mongodb::bson::{doc, from_document};
|
||||||
use rauth::auth::Session;
|
use rauth::auth::Session;
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
use rocket::outcome::try_outcome;
|
|
||||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||||
|
|
||||||
#[rocket::async_trait]
|
#[rocket::async_trait]
|
||||||
impl<'a, 'r> FromRequest<'a, 'r> for User {
|
impl<'r> FromRequest<'r> for User {
|
||||||
type Error = rauth::util::Error;
|
type Error = rauth::util::Error;
|
||||||
|
|
||||||
async fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
|
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
||||||
let session: Session = try_outcome!(request.guard::<Session>().await);
|
let session: Session = request.guard::<Session>().await.unwrap();
|
||||||
|
|
||||||
if let Ok(result) = get_collection("users")
|
if let Ok(result) = get_collection("users")
|
||||||
.find_one(
|
.find_one(
|
||||||
|
|||||||
16
src/main.rs
16
src/main.rs
@@ -4,6 +4,8 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rocket;
|
extern crate rocket;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
extern crate serde_json;
|
||||||
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate impl_ops;
|
extern crate impl_ops;
|
||||||
@@ -27,11 +29,10 @@ use rauth::{
|
|||||||
options::{Template, Templates},
|
options::{Template, Templates},
|
||||||
};
|
};
|
||||||
use rocket_cors::AllowedOrigins;
|
use rocket_cors::AllowedOrigins;
|
||||||
use rocket_prometheus::PrometheusMetrics;
|
|
||||||
use rocket::catchers;
|
use rocket::catchers;
|
||||||
use util::variables::{
|
use util::variables::{
|
||||||
APP_URL, HCAPTCHA_KEY, INVITE_ONLY, PUBLIC_URL, SMTP_FROM, SMTP_HOST, SMTP_PASSWORD,
|
APP_URL, HCAPTCHA_KEY, INVITE_ONLY, PUBLIC_URL, SMTP_FROM, SMTP_HOST, SMTP_PASSWORD,
|
||||||
SMTP_USERNAME, USE_EMAIL, USE_HCAPTCHA, USE_PROMETHEUS,
|
SMTP_USERNAME, USE_EMAIL, USE_HCAPTCHA,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
@@ -122,16 +123,7 @@ Reset your password here: {{url}}",
|
|||||||
}
|
}
|
||||||
|
|
||||||
let auth = Auth::new(database::get_collection("accounts"), options);
|
let auth = Auth::new(database::get_collection("accounts"), options);
|
||||||
|
let rocket = rocket::build();
|
||||||
let mut rocket = rocket::ignite();
|
|
||||||
|
|
||||||
if *USE_PROMETHEUS {
|
|
||||||
info!("Enabled Prometheus metrics!");
|
|
||||||
let prometheus = PrometheusMetrics::new();
|
|
||||||
rocket = rocket
|
|
||||||
.attach(prometheus.clone())
|
|
||||||
.mount("/metrics", prometheus);
|
|
||||||
}
|
|
||||||
|
|
||||||
routes::mount(rocket)
|
routes::mount(rocket)
|
||||||
.mount("/", rocket_cors::catch_all_options_routes())
|
.mount("/", rocket_cors::catch_all_options_routes())
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ pub async fn req(user: User, target: Ref, msg: Ref, edit: Json<Data>) -> Result<
|
|||||||
}
|
}
|
||||||
|
|
||||||
let obj = update.as_object_mut().unwrap();
|
let obj = update.as_object_mut().unwrap();
|
||||||
obj.insert("embeds".to_string(), json!(new_embeds).0);
|
obj.insert("embeds".to_string(), json!(new_embeds));
|
||||||
set.insert("embeds", new_embeds);
|
set.insert("embeds", new_embeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use mongodb::{
|
|||||||
bson::{doc, from_document},
|
bson::{doc, from_document},
|
||||||
options::FindOptions,
|
options::FindOptions,
|
||||||
};
|
};
|
||||||
use rocket::form::Form;
|
|
||||||
use rocket::serde::json::Value;
|
use rocket::serde::json::Value;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
@@ -37,7 +36,7 @@ pub struct Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/<target>/messages?<options..>")]
|
#[get("/<target>/messages?<options..>")]
|
||||||
pub async fn req(user: User, target: Ref, options: Form<Options>) -> Result<Value> {
|
pub async fn req(user: User, target: Ref, options: Options) -> Result<Value> {
|
||||||
options
|
options
|
||||||
.validate()
|
.validate()
|
||||||
.map_err(|error| Error::FailedValidation { error })?;
|
.map_err(|error| Error::FailedValidation { error })?;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pub use rocket::response::Redirect;
|
pub use rocket::response::Redirect;
|
||||||
pub use rocket::http::Status;
|
pub use rocket::http::Status;
|
||||||
use rocket::{Phase, Rocket};
|
use rocket::{Build, Rocket};
|
||||||
|
|
||||||
mod channels;
|
mod channels;
|
||||||
mod invites;
|
mod invites;
|
||||||
@@ -11,9 +11,9 @@ mod servers;
|
|||||||
mod sync;
|
mod sync;
|
||||||
mod users;
|
mod users;
|
||||||
|
|
||||||
pub fn mount<T: Phase>(rocket: Rocket<T>) -> Rocket<T> {
|
pub fn mount(rocket: Rocket<Build>) -> Rocket<Build> {
|
||||||
rocket
|
rocket
|
||||||
.mount("/", routes![root::root])
|
.mount("/", routes![root::root, root::ping])
|
||||||
.mount("/onboard", onboard::routes())
|
.mount("/onboard", onboard::routes())
|
||||||
.mount("/users", users::routes())
|
.mount("/users", users::routes())
|
||||||
.mount("/channels", channels::routes())
|
.mount("/channels", channels::routes())
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::util::{ratelimit::RateLimitGuard, variables::{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
use mongodb::bson::doc;
|
use mongodb::bson::doc;
|
||||||
use rocket::serde::json::Value;
|
use rocket::{http::Status, serde::json::Value};
|
||||||
use rocket_governor::RocketGovernor;
|
use rocket_governor::RocketGovernor;
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
@@ -37,3 +37,8 @@ pub async fn root(_limitguard: RocketGovernor<'_, RateLimitGuard>) -> Value {
|
|||||||
"vapid": *VAPID_PUBLIC_KEY
|
"vapid": *VAPID_PUBLIC_KEY
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/ping")]
|
||||||
|
pub async fn ping(_limitguard: RocketGovernor<'_, RateLimitGuard>) -> Status {
|
||||||
|
Status::Ok
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ use crate::util::result::{Error, Result};
|
|||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use mongodb::bson::{doc, to_bson};
|
use mongodb::bson::{doc, to_bson};
|
||||||
use mongodb::options::UpdateOptions;
|
use mongodb::options::UpdateOptions;
|
||||||
use rocket::form::Form;
|
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::json;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
type Data = HashMap<String, String>;
|
type Data = HashMap<String, String>;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, FromForm)]
|
#[derive(FromForm, Serialize, Deserialize)]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
timestamp: Option<i64>,
|
timestamp: Option<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/settings/set?<options..>", data = "<data>")]
|
#[post("/settings/set?<options..>", data = "<data>")]
|
||||||
pub async fn req(user: User, data: Json<Data>, options: Form<Options>) -> Result<()> {
|
pub async fn req(user: User, data: Json<Data>, options: Options) -> Result<()> {
|
||||||
let data = data.into_inner();
|
let data = data.into_inner();
|
||||||
let current_time = Utc::now().timestamp_millis();
|
let current_time = Utc::now().timestamp_millis();
|
||||||
let timestamp = if let Some(timestamp) = options.timestamp {
|
let timestamp = if let Some(timestamp) = options.timestamp {
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
use rocket_governor::{Method, Quota, RocketGovernable, RocketGovernor};
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use rocket_governor::{Method, Quota, RocketGovernable};
|
||||||
|
|
||||||
pub struct RateLimitGuard;
|
pub struct RateLimitGuard;
|
||||||
|
|
||||||
impl<'r> RocketGovernable<'r> for RateLimitGuard {
|
impl<'r> RocketGovernable<'r> for RateLimitGuard {
|
||||||
fn quota(_method: Method, _route_name: &str) -> Quota {
|
fn quota(_method: Method, _route_name: &str) -> Quota {
|
||||||
|
dbg!(_method, _route_name);
|
||||||
Quota::per_second(Self::nonzero(1u32))
|
Quota::per_second(Self::nonzero(1u32))
|
||||||
|
.allow_burst(Self::nonzero(10u32))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ lazy_static! {
|
|||||||
|v| v == *"1"
|
|v| v == *"1"
|
||||||
);
|
);
|
||||||
pub static ref USE_HCAPTCHA: bool = env::var("REVOLT_HCAPTCHA_KEY").is_ok();
|
pub static ref USE_HCAPTCHA: bool = env::var("REVOLT_HCAPTCHA_KEY").is_ok();
|
||||||
pub static ref USE_PROMETHEUS: bool = env::var("REVOLT_ENABLE_PROMETHEUS").map_or(false, |v| v == "1");
|
|
||||||
pub static ref USE_AUTUMN: bool = env::var("AUTUMN_PUBLIC_URL").is_ok();
|
pub static ref USE_AUTUMN: bool = env::var("AUTUMN_PUBLIC_URL").is_ok();
|
||||||
pub static ref USE_JANUARY: bool = env::var("JANUARY_PUBLIC_URL").is_ok();
|
pub static ref USE_JANUARY: bool = env::var("JANUARY_PUBLIC_URL").is_ok();
|
||||||
pub static ref USE_VOSO: bool = env::var("VOSO_PUBLIC_URL").is_ok() && env::var("VOSO_MANAGE_TOKEN").is_ok();
|
pub static ref USE_VOSO: bool = env::var("VOSO_PUBLIC_URL").is_ok() && env::var("VOSO_MANAGE_TOKEN").is_ok();
|
||||||
|
|||||||
Reference in New Issue
Block a user