diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 9f20994..0e20476 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -114,12 +114,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - [[package]] name = "autocfg" version = "1.0.1" @@ -273,15 +267,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7477065d45a8fe57167bf3cf8bcd3729b54cfcb81cca49bda2d038ea89ae82ca" -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "cloudabi" version = "0.1.0" @@ -428,7 +413,6 @@ dependencies = [ "diesel_derives", "libsqlite3-sys", "r2d2", - "uuid", ] [[package]] @@ -811,7 +795,7 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ - "autocfg 1.0.1", + "autocfg", "hashbrown", ] @@ -865,12 +849,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "kankyo" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325a11231fa70c1d1b562655db757cefb6022876d62f173831f35bd670ae0c40" - [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1001,7 +979,6 @@ dependencies = [ "diesel", "futures-io", "hex", - "kankyo", "log 0.4.11", "mime 0.3.16", "paseto", @@ -1022,7 +999,6 @@ dependencies = [ "twapi-ureq", "ureq", "url 2.1.1", - "uuid", ] [[package]] @@ -1127,7 +1103,7 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-traits", ] @@ -1137,7 +1113,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -1188,7 +1164,7 @@ version = "0.9.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" dependencies = [ - "autocfg 1.0.1", + "autocfg", "cc", "libc", "pkg-config", @@ -1219,7 +1195,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" dependencies = [ "cfg-if", - "cloudabi 0.1.0", + "cloudabi", "instant", "libc", "redox_syscall", @@ -1427,25 +1403,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.7.3" @@ -1454,19 +1411,9 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha 0.2.2", + "rand_chacha", "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", + "rand_hc", ] [[package]] @@ -1503,15 +1450,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -1521,59 +1459,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi 0.0.3", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rdrand" version = "0.4.0" @@ -1689,7 +1574,6 @@ dependencies = [ "serde", "serde_json", "time 0.1.44", - "uuid", ] [[package]] @@ -2416,16 +2300,6 @@ dependencies = [ "percent-encoding 2.1.0", ] -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", - "serde", -] - [[package]] name = "vcpkg" version = "0.2.10" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index c3bc252..73df98c 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -11,7 +11,6 @@ chrono = { version = "0.4", features = ["serde"] } color-eyre = "0.5" futures-io = "0.3" hex = "0.4" -kankyo = "0.3" log = "0.4" mime = "0.3.0" paseto = { version = "1.0", features = ["easy_tokens", "v2"] } @@ -30,17 +29,16 @@ tracing-log = "0.1" tracing-subscriber = "0.2" twapi-ureq = "0.1.5" ureq = { version = "1", features = ["json", "charset"] } -uuid = { version = "0.7", features = ["serde", "v4"] } url = "2" [dependencies.diesel] version = "1" -features = ["sqlite", "r2d2", "uuidv07", "chrono"] +features = ["sqlite", "r2d2", "chrono"] [dependencies.rocket_contrib] version = "0.4" default-features = false -features = ["json", "diesel_sqlite_pool", "uuid", "helmet"] +features = ["json", "diesel_sqlite_pool", "helmet", "serve"] [profile.release] lto = true \ No newline at end of file diff --git a/backend/src/api/mod.rs b/backend/src/api/mod.rs index 15520c7..fa9b84e 100644 --- a/backend/src/api/mod.rs +++ b/backend/src/api/mod.rs @@ -87,6 +87,9 @@ pub enum Error { #[error("invalid webmention: {0}")] InvalidWebMention(String), + + #[error("can't switch to the same fronter")] + SameFronter, } pub type Result = std::result::Result; @@ -96,7 +99,7 @@ impl<'a> Responder<'a> for Error { error!("{}", self); match self { Error::NotFound => Err(Status::NotFound), - Error::InvalidWebMention(_) => Err(Status::BadRequest), + Error::InvalidWebMention(_) | Error::SameFronter => Err(Status::BadRequest), _ => Err(Status::InternalServerError), } } diff --git a/backend/src/api/switch.rs b/backend/src/api/switch.rs index 68f990a..2702e6e 100644 --- a/backend/src/api/switch.rs +++ b/backend/src/api/switch.rs @@ -131,6 +131,10 @@ pub fn switch( .pop() .ok_or_else(|| Error::NotFound)?; + if member.cmene == to.cmene { + return Err(Error::SameFronter); + } + let now = Utc::now().naive_utc(); let switch = models::NewSwitch { diff --git a/backend/src/bin/import_blogposts.rs b/backend/src/bin/import_blogposts.rs index 16d7319..2545079 100644 --- a/backend/src/bin/import_blogposts.rs +++ b/backend/src/bin/import_blogposts.rs @@ -8,7 +8,6 @@ use std::env; use mi::{api::posse::*, *}; fn main() -> Result<()> { - let _ = kankyo::init(); color_eyre::install()?; tracing_subscriber::fmt::init(); diff --git a/backend/src/bin/import_rethink_switches.rs b/backend/src/bin/import_rethink_switches.rs index a6f8cd8..e14afa6 100644 --- a/backend/src/bin/import_rethink_switches.rs +++ b/backend/src/bin/import_rethink_switches.rs @@ -28,7 +28,6 @@ struct RethinkRow { } fn main() -> Result<()> { - let _ = kankyo::init(); color_eyre::install()?; tracing_subscriber::fmt::init(); diff --git a/backend/src/main.rs b/backend/src/main.rs index f4e9cf3..04025fc 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -33,7 +33,6 @@ Be well, Creator."# } fn main() -> Result<()> { - let _ = kankyo::init(); color_eyre::install()?; tracing_subscriber::fmt::init();