From 1c273e1fc0194bb0f7473400eb1c4d13200a15ec Mon Sep 17 00:00:00 2001 From: shiroyashik Date: Tue, 10 Jun 2025 00:54:51 +0300 Subject: [PATCH] :) --- .gitignore | 6 + Cargo.lock | 3648 +++++++++++++++++ Cargo.toml | 35 + LICENSE.txt | 674 +++ README.md | 17 + booruconfig_default.toml | 164 + client/Dockerfile | 5 + client/nginx.conf.docker | 101 + config.inc.php | 182 + docker-compose_templ.yaml | 39 + migration/Cargo.toml | 22 + migration/README.md | 41 + migration/src/lib.rs | 20 + migration/src/m20240225_224934_create_user.rs | 68 + migration/src/m20240227_020126_create_post.rs | 82 + .../src/m20240309_230808_create_snapshot.rs | 65 + .../src/m20240309_230819_create_user_token.rs | 71 + migration/src/main.rs | 6 + src/api/data.rs | 63 + src/api/info.rs | 226 + src/api/mod.rs | 6 + src/api/post/mod.rs | 4 + src/api/post/model.rs | 143 + src/api/post/post.rs | 115 + src/api/test.rs | 30 + src/api/user.rs | 134 + src/api/usertoken.rs | 131 + src/auth-dw.rs | 92 + src/auth.rs | 106 + src/config.rs | 251 ++ src/data.rs | 99 + src/db/errors.rs | 32 + src/db/mod.rs | 3 + src/db/repository.rs | 280 ++ src/db/schemas/mod.rs | 9 + src/db/schemas/post.rs | 45 + src/db/schemas/prelude.rs | 6 + src/db/schemas/prelude_model.rs | 4 + src/db/schemas/snapshot.rs | 38 + src/db/schemas/user.rs | 51 + src/db/schemas/user_token.rs | 39 + src/error.rs | 64 + src/func/mod.rs | 1 + src/func/post.rs | 26 + src/main.rs | 306 ++ tests/service_tests.rs | 39 + 46 files changed, 7589 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 booruconfig_default.toml create mode 100644 client/Dockerfile create mode 100644 client/nginx.conf.docker create mode 100644 config.inc.php create mode 100644 docker-compose_templ.yaml create mode 100644 migration/Cargo.toml create mode 100644 migration/README.md create mode 100644 migration/src/lib.rs create mode 100644 migration/src/m20240225_224934_create_user.rs create mode 100644 migration/src/m20240227_020126_create_post.rs create mode 100644 migration/src/m20240309_230808_create_snapshot.rs create mode 100644 migration/src/m20240309_230819_create_user_token.rs create mode 100644 migration/src/main.rs create mode 100644 src/api/data.rs create mode 100644 src/api/info.rs create mode 100644 src/api/mod.rs create mode 100644 src/api/post/mod.rs create mode 100644 src/api/post/model.rs create mode 100644 src/api/post/post.rs create mode 100644 src/api/test.rs create mode 100644 src/api/user.rs create mode 100644 src/api/usertoken.rs create mode 100644 src/auth-dw.rs create mode 100644 src/auth.rs create mode 100644 src/config.rs create mode 100644 src/data.rs create mode 100644 src/db/errors.rs create mode 100644 src/db/mod.rs create mode 100644 src/db/repository.rs create mode 100644 src/db/schemas/mod.rs create mode 100644 src/db/schemas/post.rs create mode 100644 src/db/schemas/prelude.rs create mode 100644 src/db/schemas/prelude_model.rs create mode 100644 src/db/schemas/snapshot.rs create mode 100644 src/db/schemas/user.rs create mode 100644 src/db/schemas/user_token.rs create mode 100644 src/error.rs create mode 100644 src/func/mod.rs create mode 100644 src/func/post.rs create mode 100644 src/main.rs create mode 100644 tests/service_tests.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f79220 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/target +/data +/.vscode +docker-compose.yaml +booruconfig.toml +.env \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d224961 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3648 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" + +[[package]] +name = "argon2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" +dependencies = [ + "base64ct", + "blake2", + "cpufeatures", + "password-hash", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "async-attributes" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +dependencies = [ + "concurrent-queue", + "event-listener 5.2.0", + "event-listener-strategy 0.5.0", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +dependencies = [ + "async-lock 3.3.0", + "async-task", + "concurrent-queue", + "fastrand 2.0.1", + "futures-lite 2.2.0", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.2.0", + "async-executor", + "async-io 2.3.1", + "async-lock 3.3.0", + "blocking", + "futures-lite 2.2.0", + "once_cell", + "tokio", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65" +dependencies = [ + "async-lock 3.3.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.2.0", + "parking", + "polling 3.5.0", + "rustix 0.38.31", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +dependencies = [ + "event-listener 4.0.3", + "event-listener-strategy 0.4.0", + "pin-project-lite", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-attributes", + "async-channel 1.9.0", + "async-global-executor", + "async-io 1.13.0", + "async-lock 2.8.0", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite 1.13.0", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "async-task" +version = "4.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" + +[[package]] +name = "async-trait" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "atomic-write-file" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8204db279bf648d64fe845bd8840f78b39c8132ed4d6a4194c3b10d4b4cfb0b" +dependencies = [ + "nix", + "rand", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "multer", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper 1.0.0", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axumbooru" +version = "0.1.0" +dependencies = [ + "anyhow", + "argon2", + "axum", + "chrono", + "dashmap", + "data-encoding", + "dotenvy", + "env_logger", + "hmac", + "log", + "md-5", + "mime_guess2", + "ring", + "sea-orm", + "serde", + "serde_json", + "sha1", + "thiserror", + "tokio", + "toml", + "tower-http", + "uuid", +] + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bigdecimal" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +dependencies = [ + "serde", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel 2.2.0", + "async-lock 3.3.0", + "async-task", + "fastrand 2.0.1", + "futures-io", + "futures-lite 2.2.0", + "piper", + "tracing", +] + +[[package]] +name = "borsh" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.52", + "syn_derive", +] + +[[package]] +name = "bumpalo" +version = "3.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" + +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + +[[package]] +name = "chrono" +version = "0.4.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.52.4", +] + +[[package]] +name = "clap" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "concurrent-queue" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.3", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +dependencies = [ + "serde", +] + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.3", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +dependencies = [ + "event-listener 5.2.0", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.8", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", +] + +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown 0.14.3", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe" + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2 0.5.6", + "tokio", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "2.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", +] + +[[package]] +name = "inherent" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0122b7114117e64a63ac49f752a5ca4624d534c7b1c7de796ac196381cd2d947" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libsqlite3-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +dependencies = [ + "value-bag", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "migration" +version = "0.1.0" +dependencies = [ + "async-std", + "sea-orm-migration", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mime_guess2" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a3333bb1609500601edc766a39b4c1772874a4ce26022f4d866854dc020c41" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "multer" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15d522be0a9c3e46fd2632e272d178f56387bdb5c9fbb3a36c649062e9b5219" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "log", + "memchr", + "mime", + "spin 0.9.8", + "version_check", +] + +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "ordered-float" +version = "3.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ouroboros" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2ba07320d39dfea882faa70554b4bd342a5f273ed59ba7c1c6b4c840492c954" +dependencies = [ + "aliasable", + "ouroboros_macro", + "static_assertions", +] + +[[package]] +name = "ouroboros_macro" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec4c6225c69b4ca778c0aea097321a64c421cf4577b331c61b229267edabb6f8" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.31", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.6", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rkyv" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rust_decimal" +version = "1.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39449a79f45e8da28c57c341891b69a183044b29518bb8f86dbac9df60bb7df" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys 0.4.13", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.21.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +dependencies = [ + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sea-bae" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd3534a9978d0aa7edd2808dc1f8f31c4d0ecd31ddf71d997b3c98e9f3c9114" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "sea-orm" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8814e37dc25de54398ee62228323657520b7f29713b8e238649385dbe473ee0" +dependencies = [ + "async-stream", + "async-trait", + "bigdecimal", + "chrono", + "futures", + "log", + "ouroboros", + "rust_decimal", + "sea-orm-macros", + "sea-query", + "sea-query-binder", + "serde", + "serde_json", + "sqlx", + "strum", + "thiserror", + "time", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "sea-orm-cli" +version = "0.12.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465ea2308d4716837e9af4a2cff8e14c28135867a580bb93e9e03d408a3a6afb" +dependencies = [ + "chrono", + "clap", + "dotenvy", + "glob", + "regex", + "sea-schema", + "tracing", + "tracing-subscriber", + "url", +] + +[[package]] +name = "sea-orm-macros" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e115c6b078e013aa963cc2d38c196c2c40b05f03d0ac872fe06b6e0d5265603" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "sea-bae", + "syn 2.0.52", + "unicode-ident", +] + +[[package]] +name = "sea-orm-migration" +version = "0.12.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac734b6e5610c2764056cc8495fbc293cd1c8ebe084fdfb74c3b0cdaaff9bb92" +dependencies = [ + "async-trait", + "clap", + "dotenvy", + "futures", + "sea-orm", + "sea-orm-cli", + "sea-schema", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "sea-query" +version = "0.30.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4166a1e072292d46dc91f31617c2a1cdaf55a8be4b5c9f4bf2ba248e3ac4999b" +dependencies = [ + "bigdecimal", + "chrono", + "derivative", + "inherent", + "ordered-float", + "rust_decimal", + "sea-query-derive", + "serde_json", + "time", + "uuid", +] + +[[package]] +name = "sea-query-binder" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36bbb68df92e820e4d5aeb17b4acd5cc8b5d18b2c36a4dd6f4626aabfa7ab1b9" +dependencies = [ + "bigdecimal", + "chrono", + "rust_decimal", + "sea-query", + "serde_json", + "sqlx", + "time", + "uuid", +] + +[[package]] +name = "sea-query-derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a82fcb49253abcb45cdcb2adf92956060ec0928635eb21b4f7a6d8f25ab0bc" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.52", + "thiserror", +] + +[[package]] +name = "sea-schema" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d148608012d25222442d1ebbfafd1228dbc5221baf4ec35596494e27a2394e" +dependencies = [ + "futures", + "sea-query", + "sea-schema-derive", +] + +[[package]] +name = "sea-schema-derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f686050f76bffc4f635cda8aea6df5548666b830b52387e8bc7de11056d11e" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "serde_json" +version = "1.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd154a240de39fdebcf5775d2675c204d7c13cf39a4c697be6493c8e734337c" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" +dependencies = [ + "itertools", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba03c279da73694ef99763320dea58b51095dfe87d001b1d4b5fe78ba8763cf" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" +dependencies = [ + "ahash 0.8.11", + "atoi", + "bigdecimal", + "byteorder", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener 2.5.3", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rust_decimal", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "time", + "tokio", + "tokio-stream", + "tracing", + "url", + "uuid", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89961c00dc4d7dffb7aee214964b065072bff69e36ddb9e2c107541f75e4f2a5" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" +dependencies = [ + "atomic-write-file", + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" +dependencies = [ + "atoi", + "base64", + "bigdecimal", + "bitflags 2.4.2", + "byteorder", + "bytes", + "chrono", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "rust_decimal", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" +dependencies = [ + "atoi", + "base64", + "bigdecimal", + "bitflags 2.4.2", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "num-bigint", + "once_cell", + "rand", + "rust_decimal", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490" +dependencies = [ + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "time", + "tracing", + "url", + "urlencoding", + "uuid", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "stringprep" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" +dependencies = [ + "finl_unicode", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384595c11a4e2969895cad5a8c4029115f5ab956a9e5ef4de79d11a426e5f20c" + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand 2.0.1", + "rustix 0.38.31", + "windows-sys 0.52.0", +] + +[[package]] +name = "thiserror" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.5.6", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.9", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.5", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +dependencies = [ + "bitflags 2.4.2", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "http-range-header", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "once_cell", + "regex", + "sharded-slab", + "thread_local", + "tracing", + "tracing-core", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", + "rand", + "serde", +] + +[[package]] +name = "value-bag" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126e423afe2dd9ac52142e7e9d5ce4135d7e13776c529d27fd6bc49f19e3280b" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.52", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + +[[package]] +name = "whoami" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fec781d48b41f8163426ed18e8fc2864c12937df9ce54c88ede7bd47270893e" +dependencies = [ + "redox_syscall", + "wasite", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e9213d0 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "axumbooru" +authors = ["Shiroyashik "] +license = "GPL-3.0-or-later" +version = "0.1.0" +edition = "2021" +publish = false + +[workspace] +members = ["migration"] + +[dependencies] +dotenvy = "0.15.7" +uuid = { version = "1.8.0", features = ["v4", "fast-rng"] } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +tokio = { version = "1.37.0", features = ["full"] } +axum = { version = "0.7.5", features = ["json", "query", "tracing", "multipart"] } +toml = "0.8.12" +tower-http = { version = "0.5.2", features = ["fs", "trace"] } +chrono = { version = "0.4.37", features = ["serde"] } +sea-orm = { version = "0.12.15", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros", "with-chrono", "with-uuid", "debug-print"] } +hmac = "0.12.1" +md-5 = "0.10.6" +mime_guess2 = "2.0.5" +thiserror = "1.0.58" +argon2 = "0.5.3" +sha1 = "0.10.6" +log = "0.4.21" +env_logger = "0.11.3" +anyhow = "1.0.82" +# Currently doesn't using it +ring = "0.17.8" +dashmap = "5.5.3" # and it +data-encoding = "2.5.0" diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..86ffbee --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +## Axumbooru +**Проект не завершен и находится в активной разработке!** + +Выполнить для подготовки окружения к разработке +```bash +echo -e "DATABASE_URL=postgres://axumbooru:axumbooru@localhost/axumbooru\nRUST_LOG=debug" > .env +cp booruconfig_default.toml booruconfig.toml +cp docker-compose_templ.yaml docker-compose.yaml +# Запускает Postgresql на 5432, +# szurubooru/client на 80 и phpPgAdmin на 8080 +docker compose up -d +cargo install sea-orm-cli +# Не забудь добавить ~/.cargo/bin в PATH +sea migrate +# Собирает и запускает Axumbooru +cargo run +``` diff --git a/booruconfig_default.toml b/booruconfig_default.toml new file mode 100644 index 0000000..5b8e09f --- /dev/null +++ b/booruconfig_default.toml @@ -0,0 +1,164 @@ +name = "axumbooru" +# Следующая часть конфига повторяет Szurubooru +# и используется для примера, поэтому некоторые +# аргументы могут не использоваться в коде +# и не дойти до релиза. +# P.S. Также некоторые ключи которые я посчитал +# ненужными или изыботочными опущены. + + +listen = "127.0.0.1:6667" + +# full url to the homepage of this szurubooru site, with no trailing slash +domain = "" # example = http://example.com +# used to salt the users' password hashes and generate filenames for static content +secret = "change" + +# Delete thumbnails and source files on post delete +# Original functionality is no, to mitigate the impacts of admins going +# on unchecked post purges. +delete_source_files = false + +contact_email = "admin@mail.example" # Meant for manual password reset procedures + +enable_safety = true + +tag_name_regex = '^\S+$' +tag_category_name_regex = '^[^\s%+#/]+$' + +pool_name_regex = '^\S+$' +pool_category_name_regex = '^[^\s%+#/]+$' + +# don't make these more restrictive unless you want to annoy people; if you do +# customize them, make sure to update the instructions in the registration form +# template as well. +password_regex = '^.{5,}$' +user_name_regex = '^[a-zA-Z0-9_-]{1,32}$' + +# allow posts to be uploaded even if some image processing errors occur +allow_broken_uploads = false + +# webhooks to call when events occur (such as post/tag/user/etc. changes) +# the listed urls will be called with a HTTP POST request with a payload +# containing a snapshot resource as JSON. See doc/API.md for details +# webhooks = [ + # "https://api.example.com/webhooks/", ' +# ] + +default_rank = "regular" + +[privileges] +"users:create:self" = "anonymous" # Registration permission +"users:create:any" = "administrator" +"users:list" = "regular" +"users:view" = "regular" +"users:edit:any:name" = "moderator" +"users:edit:any:pass" = "moderator" +"users:edit:any:email" = "moderator" +"users:edit:any:avatar" = "moderator" +"users:edit:any:rank" = "moderator" +"users:edit:self:name" = "regular" +"users:edit:self:pass" = "regular" +"users:edit:self:email" = "regular" +"users:edit:self:avatar" = "regular" +"users:edit:self:rank" = "moderator" # one can't promote themselves or anyone to upper rank than their own. +"users:delete:any" = "administrator" +"users:delete:self" = "regular" + +"userTokens:list:any" = "administrator" +"userTokens:list:self" = "regular" +"userTokens:create:any" = "administrator" +"userTokens:create:self" = "regular" +"userTokens:edit:any" = "administrator" +"userTokens:edit:self" = "regular" +"userTokens:delete:any" = "administrator" +"userTokens:delete:self" = "regular" + +"posts:create:anonymous" = "regular" +"posts:create:identified" = "regular" +"posts:list" = "anonymous" +"posts:reverseSearch" = "regular" +"posts:view" = "anonymous" +"posts:view:featured" = "anonymous" +"posts:edit:content" = "power" +"posts:edit:flags" = "regular" +"posts:edit:notes" = "regular" +"posts:edit:relations" = "regular" +"posts:edit:safety" = "power" +"posts:edit:source" = "regular" +"posts:edit:tags" = "regular" +"posts:edit:thumbnail" = "power" +"posts:feature" = "moderator" +"posts:delete" = "moderator" +"posts:score" = "regular" +"posts:merge" = "moderator" +"posts:favorite" = "regular" +"posts:bulk-edit:tags" = "power" +"posts:bulk-edit:safety" = "power" +"posts:bulk-edit:delete" = "power" + +"tags:create" = "regular" +"tags:edit:names" = "power" +"tags:edit:category" = "power" +"tags:edit:description" = "power" +"tags:edit:implications" = "power" +"tags:edit:suggestions" = "power" +"tags:list" = "regular" +"tags:view" = "anonymous" +"tags:merge" = "moderator" +"tags:delete" = "moderator" + +"tagCategories:create" = "moderator" +"tagCategories:edit:name" = "moderator" +"tagCategories:edit:color" = "moderator" +"tagCategories:edit:order" = "moderator" +"tagCategories:list" = "anonymous" +"tagCategories:view" = "anonymous" +"tagCategories:delete" = "moderator" +"tagCategories:setDefault" = "moderator" + +"pools:create" = "regular" +"pools:edit:names" = "power" +"pools:edit:category" = "power" +"pools:edit:description" = "power" +"pools:edit:posts" = "power" +"pools:list" = "regular" +"pools:view" = "anonymous" +"pools:merge" = "moderator" +"pools:delete" = "moderator" + +"poolCategories:create" = "moderator" +"poolCategories:edit:name" = "moderator" +"poolCategories:edit:color" = "moderator" +"poolCategories:list" = "anonymous" +"poolCategories:view" = "anonymous" +"poolCategories:delete" = "moderator" +"poolCategories:setDefault" = "moderator" + +"comments:create" = "regular" +"comments:delete:any" = "moderator" +"comments:delete:own" = "regular" +"comments:edit:any" = "moderator" +"comments:edit:own" = "regular" +"comments:list" = "regular" +"comments:view" = "regular" +"comments:score" = "regular" + +"snapshots:list" = "power" + +"uploads:create" = "regular" +"uploads:useDownloader" = "power" + +[thumbnails] +avatar_width = 300 +avatar_height = 300 +post_width = 300 +post_height = 300 + +[smtp] +enabled = false +host = "smtp.mail.example" +port = 25 +user = "booru" +pass = "booru" +from = "booru@mail.example" diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..fbe187e --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,5 @@ +FROM szurubooru/client:2.5 +COPY nginx.conf.docker /etc/nginx/nginx.conf + +CMD ["/docker-start.sh"] +VOLUME ["/data"] \ No newline at end of file diff --git a/client/nginx.conf.docker b/client/nginx.conf.docker new file mode 100644 index 0000000..9afba22 --- /dev/null +++ b/client/nginx.conf.docker @@ -0,0 +1,101 @@ +worker_processes 1; +user nginx; + +error_log /dev/stderr warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr -> $request [$status] - ' + 'referer: $http_referer $http_x_forwarded_for'; + access_log /dev/stdout main; + + server_tokens off; + keepalive_timeout 65; + + upstream backend { + server __BACKEND__; + } + + server { + listen 80 default_server; + + location ~ ^/api$ { + return 302 /api/; + } + + location ~ ^/api/(.*)$ { + tcp_nodelay on; + + add_header 'Access-Control-Allow-Origin' '*'; + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Methods' + 'GET, POST, PUT, DELETE, OPTIONS'; + add_header 'Access-Control-Allow-Headers' + 'Authorization, Content-Type'; + return 200; + } + + client_max_body_size 1073741824; + + gzip on; + gzip_comp_level 3; + gzip_min_length 20; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain application/json; + + if ($request_uri ~* "/api/(.*)") { + proxy_pass http://backend/$1; + } + + error_page 500 502 503 504 @badproxy; + } + + location /data/ { + rewrite ^/data/(.*) /$1 break; + root /data; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + + error_page 403 @unauthorized; + error_page 404 @notfound; + } + + location / { + root /var/www; + try_files $uri /index.htm; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + + gzip_static on; + gzip_proxied expired no-cache no-store private auth; + } + + location @unauthorized { + return 403 "Unauthorized"; + default_type text/plain; + } + + location @notfound { + return 404 "Not Found"; + default_type text/plain; + } + + location @badproxy { + return 502 "Failed to connect to szurubooru REST API"; + default_type text/plain; + } + } +} + +daemon off; \ No newline at end of file diff --git a/config.inc.php b/config.inc.php new file mode 100644 index 0000000..e839e0c --- /dev/null +++ b/config.inc.php @@ -0,0 +1,182 @@ + + diff --git a/docker-compose_templ.yaml b/docker-compose_templ.yaml new file mode 100644 index 0000000..7529095 --- /dev/null +++ b/docker-compose_templ.yaml @@ -0,0 +1,39 @@ +services: + phppgadmin: + container_name: phppgadmin + restart: unless-stopped + image: ngosang/phppgadmin:7.14.6-mod-1 + volumes: + - ./config.inc.php:/var/www/app/conf/config.inc.php:ro + ports: + - 8080:80 + + frontend: + # Based on szurubooru/client:2.5 + build: ./client + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + # Timezone + TZ: 'Europe/Moscow' + # Backend "hostname:port" + BACKEND_HOST: 'host.docker.internal:6667' + BASE_URL: + volumes: + - ./data:/data:ro + ports: + - 80:80 + + postgresql: + image: postgres:11-alpine + restart: unless-stopped + environment: + POSTGRES_USER: axumbooru + POSTGRES_PASSWORD: axumbooru + ports: + - 5432:5432 + volumes: + - db-data:/var/lib/postgresql/data + +volumes: + db-data: diff --git a/migration/Cargo.toml b/migration/Cargo.toml new file mode 100644 index 0000000..2cd1bb7 --- /dev/null +++ b/migration/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "migration" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +name = "migration" +path = "src/lib.rs" + +[dependencies] +async-std = { version = "1", features = ["attributes", "tokio1"] } + +[dependencies.sea-orm-migration] +version = "0.12.14" +features = [ + # Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI. + # View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime. + # e.g. + "runtime-tokio-rustls", # `ASYNC_RUNTIME` feature + "sqlx-postgres", # `DATABASE_DRIVER` feature +] diff --git a/migration/README.md b/migration/README.md new file mode 100644 index 0000000..3b438d8 --- /dev/null +++ b/migration/README.md @@ -0,0 +1,41 @@ +# Running Migrator CLI + +- Generate a new migration file + ```sh + cargo run -- generate MIGRATION_NAME + ``` +- Apply all pending migrations + ```sh + cargo run + ``` + ```sh + cargo run -- up + ``` +- Apply first 10 pending migrations + ```sh + cargo run -- up -n 10 + ``` +- Rollback last applied migrations + ```sh + cargo run -- down + ``` +- Rollback last 10 applied migrations + ```sh + cargo run -- down -n 10 + ``` +- Drop all tables from the database, then reapply all migrations + ```sh + cargo run -- fresh + ``` +- Rollback all applied migrations, then reapply all migrations + ```sh + cargo run -- refresh + ``` +- Rollback all applied migrations + ```sh + cargo run -- reset + ``` +- Check the status of all migrations + ```sh + cargo run -- status + ``` diff --git a/migration/src/lib.rs b/migration/src/lib.rs new file mode 100644 index 0000000..6861f0b --- /dev/null +++ b/migration/src/lib.rs @@ -0,0 +1,20 @@ +pub use sea_orm_migration::prelude::*; + +mod m20240225_224934_create_user; +mod m20240227_020126_create_post; +mod m20240309_230819_create_user_token; +mod m20240309_230808_create_snapshot; + +pub struct Migrator; + +#[async_trait::async_trait] +impl MigratorTrait for Migrator { + fn migrations() -> Vec> { + vec![ + Box::new(m20240225_224934_create_user::Migration), + Box::new(m20240227_020126_create_post::Migration), + Box::new(m20240309_230808_create_snapshot::Migration), + Box::new(m20240309_230819_create_user_token::Migration), + ] + } +} diff --git a/migration/src/m20240225_224934_create_user.rs b/migration/src/m20240225_224934_create_user.rs new file mode 100644 index 0000000..0f6b9c7 --- /dev/null +++ b/migration/src/m20240225_224934_create_user.rs @@ -0,0 +1,68 @@ +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .create_table( + Table::create() + .table(User::Table) + .if_not_exists() + .col( + ColumnDef::new(User::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col( + ColumnDef::new(User::Name) + .string_len(50) + .not_null() + .unique_key(), + ) + .col(ColumnDef::new(User::PasswordHash).string_len(128).not_null()) + .col(ColumnDef::new(User::PasswordSalt).string_len(32)) + .col(ColumnDef::new(User::Email).string_len(64)) + .col(ColumnDef::new(User::Rank).string_len(32).not_null()) + .col(ColumnDef::new(User::CreationTime).timestamp().not_null()) + .col(ColumnDef::new(User::LastLoginTime).timestamp()) + .col(ColumnDef::new(User::AvatarStyle).string_len(32).not_null()) + .col(ColumnDef::new(User::Version).integer().not_null()) + .col(ColumnDef::new(User::PasswordRevision).small_integer().not_null()) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_table(Table::drop().table(User::Table).to_owned()) + .await + } +} + +#[derive(DeriveIden)] +pub(super) enum User { + Table, + Id, + Name, + #[sea_orm(iden = "password_hash")] + PasswordHash, + #[sea_orm(iden = "password_salt")] + PasswordSalt, + Email, + Rank, + #[sea_orm(iden = "creation_time")] + CreationTime, + #[sea_orm(iden = "last_login_time")] + LastLoginTime, + #[sea_orm(iden = "avatar_style")] + AvatarStyle, + Version, + #[sea_orm(iden = "password_revision")] + PasswordRevision, +} diff --git a/migration/src/m20240227_020126_create_post.rs b/migration/src/m20240227_020126_create_post.rs new file mode 100644 index 0000000..23cb8c5 --- /dev/null +++ b/migration/src/m20240227_020126_create_post.rs @@ -0,0 +1,82 @@ +use sea_orm_migration::prelude::*; + +use crate::m20240225_224934_create_user::User; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .create_table( + Table::create() + .table(Post::Table) + .if_not_exists() + .col( + ColumnDef::new(Post::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Post::UserId).integer()) + .col(ColumnDef::new(Post::CreationTime).timestamp().not_null()) + .col(ColumnDef::new(Post::LastEditTime).timestamp()) + .col(ColumnDef::new(Post::Safety).string_len(32).not_null()) + .col(ColumnDef::new(Post::Type).string_len(32).not_null()) + .col(ColumnDef::new(Post::Checksum).string_len(64).not_null()) + .col(ColumnDef::new(Post::Source).string_len(2048)) + .col(ColumnDef::new(Post::FileSize).big_integer()) + .col(ColumnDef::new(Post::ImageWidth).integer()) + .col(ColumnDef::new(Post::ImageHeight).integer()) + .col(ColumnDef::new(Post::MimeType).string_len(32).not_null()) + .col(ColumnDef::new(Post::Version).integer().not_null()) + .col(ColumnDef::new(Post::Flags).string_len(32)) + .col(ColumnDef::new(Post::ChecksumMD5).string_len(32)) + .foreign_key( + ForeignKey::create() + .name("FK_posts_userid") + .from(Post::Table, Post::UserId) + .to(User::Table, User::Id) + .on_delete(ForeignKeyAction::SetNull), + ) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_table(Table::drop().table(Post::Table).to_owned()) + .await + } +} + +#[derive(DeriveIden)] +enum Post { + Table, + Id, + #[sea_orm(iden = "user_id")] + UserId, + #[sea_orm(iden = "creation_time")] + CreationTime, + #[sea_orm(iden = "last_edit_time")] + LastEditTime, + Safety, + Type, + Checksum, + Source, + #[sea_orm(iden = "file_size")] + FileSize, + #[sea_orm(iden = "image_width")] + ImageWidth, + #[sea_orm(iden = "image_height")] + ImageHeight, + #[sea_orm(iden = "mime-type")] + MimeType, + Version, + Flags, + #[sea_orm(iden = "checksum_md5")] + ChecksumMD5, +} diff --git a/migration/src/m20240309_230808_create_snapshot.rs b/migration/src/m20240309_230808_create_snapshot.rs new file mode 100644 index 0000000..afb5a4d --- /dev/null +++ b/migration/src/m20240309_230808_create_snapshot.rs @@ -0,0 +1,65 @@ +use sea_orm_migration::prelude::*; + +use crate::m20240225_224934_create_user::User; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .create_table( + Table::create() + .table(Snapshot::Table) + .if_not_exists() + .col( + ColumnDef::new(Snapshot::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Snapshot::CreationTime).timestamp().not_null()) + .col(ColumnDef::new(Snapshot::ResourceType).string_len(32).not_null()) + .col(ColumnDef::new(Snapshot::Operation).string_len(16).not_null()) + .col(ColumnDef::new(Snapshot::UserId).integer()) + .col(ColumnDef::new(Snapshot::Data).binary()) + .col(ColumnDef::new(Snapshot::ResourceName).string_len(128).not_null()) + .col(ColumnDef::new(Snapshot::ResourcePkey).integer().not_null()) + .foreign_key( + ForeignKey::create() + .name("FK_snapshot_userid") + .from(Snapshot::Table, Snapshot::UserId) + .to(User::Table, User::Id) + .on_delete(ForeignKeyAction::SetNull), + ) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_table(Table::drop().table(Snapshot::Table).to_owned()) + .await + } +} + +#[derive(DeriveIden)] +enum Snapshot { + Table, + Id, + #[sea_orm(iden = "creation_time")] + CreationTime, + #[sea_orm(iden = "resource_type")] + ResourceType, + Operation, + #[sea_orm(iden = "user_id")] + UserId, + Data, + #[sea_orm(iden = "resource_name")] + ResourceName, + #[sea_orm(iden = "resource_pkey")] + ResourcePkey, +} diff --git a/migration/src/m20240309_230819_create_user_token.rs b/migration/src/m20240309_230819_create_user_token.rs new file mode 100644 index 0000000..40c5695 --- /dev/null +++ b/migration/src/m20240309_230819_create_user_token.rs @@ -0,0 +1,71 @@ +use sea_orm_migration::prelude::*; + +use crate::m20240225_224934_create_user::User; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + + manager + .create_table( + Table::create() + .table(UserToken::Table) + .if_not_exists() + .col( + ColumnDef::new(UserToken::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(UserToken::UserId).integer().not_null()) + .col(ColumnDef::new(UserToken::Token).string_len(36).not_null()) + .col(ColumnDef::new(UserToken::Note).string_len(128)) + .col(ColumnDef::new(UserToken::Enabled).boolean().not_null()) + .col(ColumnDef::new(UserToken::ExpirationTime).timestamp()) + .col(ColumnDef::new(UserToken::CreationTime).timestamp().not_null()) + .col(ColumnDef::new(UserToken::LastEditTime).timestamp()) + .col(ColumnDef::new(UserToken::LastUsageTime).timestamp()) + .col(ColumnDef::new(UserToken::Version).integer().not_null()) + .foreign_key( + ForeignKey::create() + .name("FK_user_token_userid") + .from(UserToken::Table, UserToken::UserId) + .to(User::Table, User::Id) + .on_delete(ForeignKeyAction::Cascade), + ) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + + manager + .drop_table(Table::drop().table(UserToken::Table).to_owned()) + .await + } +} + +#[derive(DeriveIden)] +enum UserToken { + Table, + Id, + #[sea_orm(iden = "user_id")] + UserId, + Token, + Note, + Enabled, + #[sea_orm(iden = "expiration_time")] + ExpirationTime, + #[sea_orm(iden = "creation_time")] + CreationTime, + #[sea_orm(iden = "last_edit_time")] + LastEditTime, + #[sea_orm(iden = "last_usage_time")] + LastUsageTime, + Version, +} diff --git a/migration/src/main.rs b/migration/src/main.rs new file mode 100644 index 0000000..c6b6e48 --- /dev/null +++ b/migration/src/main.rs @@ -0,0 +1,6 @@ +use sea_orm_migration::prelude::*; + +#[async_std::main] +async fn main() { + cli::run_cli(migration::Migrator).await; +} diff --git a/src/api/data.rs b/src/api/data.rs new file mode 100644 index 0000000..18fd10c --- /dev/null +++ b/src/api/data.rs @@ -0,0 +1,63 @@ +use axum::{extract::{Multipart, State}, routing::get_service, Json, Router}; +use serde::Serialize; +use tower_http::services::ServeDir; +use log::{debug, info}; +use std::{fs, sync::Arc}; + +use crate::{data::DATA, error::{ApiError, ApiResult}, AppState}; + +pub fn data_static() -> Router { + Router::new().nest_service("/", get_service(ServeDir::new(DATA))) +} + +pub fn get_folder_size(path: &str) -> Result { + // Получение списка элементов в папке + let entries = fs::read_dir(path)?; + // Инициализация переменной для хранения размера папки + let mut total_size: u64 = 0; + // Итерация по элементам папки + for entry in entries { + // Получение метаданных элемента + let metadata = entry?.metadata()?; + // Если элемент является файлом, добавляем его размер к общему размеру + if metadata.is_file() { + total_size += metadata.len(); + } + } + debug!("Data dir size: {total_size}"); + // Возвращение общего размера папки + Ok(total_size) +} + +#[derive(Serialize)] +pub struct UploadResponse { + pub token: String, +} + +fn to_upload_error(_: anyhow::Error) -> ApiError { + ApiError::Uploads +} + +pub async fn upload(State(state): State>, mut multipart: Multipart) -> ApiResult> { + let mut token: Option = None; + while let Some(field) = multipart.next_field().await.unwrap() { + let name = field.name().unwrap().to_string(); + // debug!("Multipart: {:?} {:?} {:?} {:?}", field.content_type(), field.file_name(), field.name(), field.headers()); + if name == "content".to_string() { + let filename = field.file_name().unwrap().to_owned(); + let content_type = field.content_type().unwrap().to_owned(); + let (_, extension) = filename.split_once('.').expect("Damaged file"); + let data = field.bytes().await.unwrap(); + token = Some(state.uploads.lock().expect("Uploads mutex was poisoned!").add(extension, &content_type, data).map_err(to_upload_error)?); + } + } + match token { + Some(token) => { + info!("Responding token: {token}"); + return Ok(Json(UploadResponse { token })) + }, + None => { + panic!("DOESN'T HAVE CONTENT!") + }, + } +} \ No newline at end of file diff --git a/src/api/info.rs b/src/api/info.rs new file mode 100644 index 0000000..9f100b3 --- /dev/null +++ b/src/api/info.rs @@ -0,0 +1,226 @@ +use crate::{ + config::Privileges, + AppState, Config, UserRank, +}; +use axum::{extract::State, Json}; +use chrono::prelude::*; +use serde::{Deserialize, Serialize}; +use std::sync::Arc; +use log::debug; + +#[derive(Serialize, Deserialize)] +pub struct InfoAnswer { + #[serde(rename = "postCount")] + post_count: u64, + #[serde(rename = "diskUsage")] + disk_usage: u64, + #[serde(rename = "serverTime")] + server_time: chrono::NaiveDateTime, + #[serde(rename = "config")] + config: FrontendConfig, + #[serde(rename = "featuredPost")] + featured_post: Option<()>, // Temporarily removed + #[serde(rename = "featuringUser")] + featuring_user: Option<()>, // Temporarily removed + #[serde(rename = "featuringTime")] + featuring_time: Option, +} + +#[derive(Serialize, Deserialize)] +pub struct FrontendConfig { + #[serde(rename = "name")] + name: String, + #[serde(rename = "userNameRegex")] + user_name_regex: String, + #[serde(rename = "passwordRegex")] + password_regex: String, + #[serde(rename = "tagNameRegex")] + tag_name_regex: String, + #[serde(rename = "tagCategoryNameRegex")] + tag_category_name_regex: String, + #[serde(rename = "defaultUserRank")] + default_user_rank: UserRank, + #[serde(rename = "enableSafety")] + enable_safety: bool, + #[serde(rename = "contactEmail")] + contact_email: String, + #[serde(rename = "canSendMails")] + can_send_mails: bool, + #[serde(rename = "privileges")] + privileges: Privileges, +} + +impl FrontendConfig { + pub async fn from_config(config: Config) -> Self { + Self { + name: config.name, + user_name_regex: config.user_name_regex, + password_regex: config.password_regex, + tag_name_regex: config.tag_name_regex, + tag_category_name_regex: config.tag_category_name_regex, + default_user_rank: config.default_rank, + enable_safety: config.enable_safety, + contact_email: config.contact_email, + can_send_mails: config.smtp.enabled, + privileges: config.privileges, + } + } +} + +// #[derive(Serialize, Deserialize)] +// pub struct FeaturedPost { +// #[serde(rename = "id")] +// id: i64, +// #[serde(rename = "version")] +// version: i64, +// #[serde(rename = "creationTime")] +// creation_time: chrono::NaiveDateTime, +// #[serde(rename = "lastEditTime")] +// last_edit_time: Option, +// #[serde(rename = "safety")] +// safety: String, +// #[serde(rename = "source")] +// source: Option, +// #[serde(rename = "type")] +// featured_post_type: String, +// #[serde(rename = "mimeType")] +// mime_type: String, +// #[serde(rename = "checksum")] +// checksum: String, +// #[serde(rename = "checksumMD5")] +// checksum_md5: String, +// #[serde(rename = "fileSize")] +// file_size: i64, +// #[serde(rename = "canvasWidth")] +// canvas_width: i64, +// #[serde(rename = "canvasHeight")] +// canvas_height: i64, +// #[serde(rename = "contentUrl")] +// content_url: String, +// #[serde(rename = "thumbnailUrl")] +// thumbnail_url: String, +// #[serde(rename = "flags")] +// flags: Vec, +// #[serde(rename = "tags")] +// tags: Vec, +// #[serde(rename = "relations")] +// relations: Vec>, +// #[serde(rename = "user")] +// user: User, +// #[serde(rename = "score")] +// score: i64, +// #[serde(rename = "ownScore")] +// own_score: i64, +// #[serde(rename = "ownFavorite")] +// own_favorite: bool, +// #[serde(rename = "tagCount")] +// tag_count: i64, +// #[serde(rename = "favoriteCount")] +// favorite_count: i64, +// #[serde(rename = "commentCount")] +// comment_count: i64, +// #[serde(rename = "noteCount")] +// note_count: i64, +// #[serde(rename = "relationCount")] +// relation_count: i64, +// #[serde(rename = "featureCount")] +// feature_count: i64, +// #[serde(rename = "lastFeatureTime")] +// last_feature_time: Option, +// #[serde(rename = "favoritedBy")] +// favorited_by: Vec>, +// #[serde(rename = "hasCustomThumbnail")] +// has_custom_thumbnail: bool, +// #[serde(rename = "notes")] +// notes: Vec>, +// #[serde(rename = "comments")] +// comments: Vec, +// #[serde(rename = "pools")] +// pools: Vec>, +// } + +// #[derive(Serialize, Deserialize)] +// pub struct Comment { +// #[serde(rename = "id")] +// id: i64, +// #[serde(rename = "user")] +// user: User, +// #[serde(rename = "postId")] +// post_id: i64, +// #[serde(rename = "version")] +// version: i64, +// #[serde(rename = "text")] +// text: String, +// #[serde(rename = "creationTime")] +// creation_time: chrono::NaiveDateTime, +// #[serde(rename = "lastEditTime")] +// last_edit_time: Option, +// #[serde(rename = "score")] +// score: i64, +// #[serde(rename = "ownScore")] +// own_score: i64, +// } + +// #[derive(Serialize, Deserialize)] +// pub struct User { +// #[serde(rename = "name")] +// name: String, +// #[serde(rename = "avatarUrl")] +// avatar_url: String, +// } + +// #[derive(Serialize, Deserialize)] +// pub struct Tag { +// #[serde(rename = "names")] +// names: Vec, +// #[serde(rename = "category")] +// category: String, +// #[serde(rename = "usages")] +// usages: i64, +// } + +// #[derive(Serialize, Deserialize)] +// pub struct FeaturingUser { +// #[serde(rename = "name")] +// name: String, +// #[serde(rename = "creationTime")] +// creation_time: chrono::NaiveDateTime, +// #[serde(rename = "lastLoginTime")] +// last_login_time: Option, +// #[serde(rename = "version")] +// version: i64, +// #[serde(rename = "rank")] +// rank: UserRank, +// #[serde(rename = "avatarStyle")] +// avatar_style: String, +// #[serde(rename = "avatarUrl")] +// avatar_url: String, +// #[serde(rename = "commentCount")] +// comment_count: i64, +// #[serde(rename = "uploadedPostCount")] +// uploaded_post_count: i64, +// #[serde(rename = "favoritePostCount")] +// favorite_post_count: i64, +// #[serde(rename = "likedPostCount")] +// liked_post_count: bool, +// #[serde(rename = "dislikedPostCount")] +// disliked_post_count: bool, +// #[serde(rename = "email")] +// email: bool, +// } + +pub async fn server_info(State(state): State>) -> Json { + debug!("called"); + + let info = InfoAnswer { + post_count: state.db.get_posts_count().await.unwrap(), + disk_usage: crate::api::data::get_folder_size("./data").unwrap(), + server_time: Local::now().naive_local(), + config: FrontendConfig::from_config(state.config.clone()).await, + featured_post: None, + featuring_user: None, + featuring_time: None, + }; + + Json(info) +} diff --git a/src/api/mod.rs b/src/api/mod.rs new file mode 100644 index 0000000..e908402 --- /dev/null +++ b/src/api/mod.rs @@ -0,0 +1,6 @@ +pub mod data; +pub mod info; +pub mod post; +pub mod test; +pub mod user; +pub mod usertoken; diff --git a/src/api/post/mod.rs b/src/api/post/mod.rs new file mode 100644 index 0000000..d4dd7b4 --- /dev/null +++ b/src/api/post/mod.rs @@ -0,0 +1,4 @@ +pub mod post; +pub use post::*; + +pub mod model; \ No newline at end of file diff --git a/src/api/post/model.rs b/src/api/post/model.rs new file mode 100644 index 0000000..12f681c --- /dev/null +++ b/src/api/post/model.rs @@ -0,0 +1,143 @@ +use serde::{Deserialize, Serialize}; +use chrono::NaiveDateTime; + +#[derive(Serialize, Deserialize)] +pub struct ListOfPostsAnswer { + pub query: String, + pub offset: u64, + pub limit: u64, + pub total: u64, + pub results: Vec, +} + +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct MiniPost { + pub id: i32, + pub thumbnail_url: String, + pub r#type: String, + pub safety: String, + pub score: i32, + pub favorite_count: i32, + pub comment_count: i32, + pub tags: Vec<()>, // Vec + pub version: i32, +} + +impl MiniPost { + pub fn from_model( + model: &crate::db::schemas::post::Model, + thumbnail_url: String, + score: i32, + favorite_count: i32, + comment_count: i32, + tags: Vec<()> // TODO: Vec + ) -> Self { + Self { + id: model.id, + thumbnail_url, + r#type: model.r#type.clone(), + safety: model.safety.clone(), + score, + favorite_count, + comment_count, + tags, + version: model.version, + } + } +} + +#[derive(Serialize, Deserialize)] +pub struct PostAnswer { + pub id: i32, + pub version: i32, + #[serde(rename = "creationTime")] + pub creation_time: NaiveDateTime, + #[serde(rename = "lastEditTime")] + pub last_edit_time: Option, + pub safety: String, + pub source: Option, + #[serde(rename = "type")] + pub type_field: String, + #[serde(rename = "mimeType")] + pub mime_type: String, + pub checksum: String, + #[serde(rename = "checksumMD5")] + pub checksum_md5: Option, + #[serde(rename = "fileSize")] + pub file_size: Option, + #[serde(rename = "canvasWidth")] + pub canvas_width: Option, + #[serde(rename = "canvasHeight")] + pub canvas_height: Option, + #[serde(rename = "contentUrl")] + pub content_url: String, + #[serde(rename = "thumbnailUrl")] + pub thumbnail_url: String, + pub flags: Vec, + pub tags: Vec<()>, // Vec + pub relations: Vec<()>, + pub user: Option, + pub score: i64, + #[serde(rename = "ownScore")] + pub own_score: i64, + #[serde(rename = "ownFavorite")] + pub own_favorite: bool, + #[serde(rename = "tagCount")] + pub tag_count: i64, + #[serde(rename = "favoriteCount")] + pub favorite_count: i64, + #[serde(rename = "commentCount")] + pub comment_count: i64, + #[serde(rename = "noteCount")] + pub note_count: i64, + #[serde(rename = "relationCount")] + pub relation_count: i64, + #[serde(rename = "featureCount")] + pub feature_count: i64, + #[serde(rename = "lastFeatureTime")] + pub last_feature_time: Option<()>, + #[serde(rename = "favoritedBy")] + pub favorited_by: Vec<()>, + #[serde(rename = "hasCustomThumbnail")] + pub has_custom_thumbnail: bool, + pub notes: Vec<()>, + pub comments: Vec<()>, + pub pools: Vec<()>, +} + + +// #[derive(Serialize, Deserialize)] +// pub struct Tag { +// pub names: Vec, +// pub category: String, +// pub usages: i64, +// } + +#[derive(Serialize, Deserialize)] +pub struct User { + pub name: String, + #[serde(rename = "avatarUrl")] + pub avatar_url: String, +} + +#[derive(Debug, Deserialize)] +pub struct PostsParams { + pub query: String, + pub offset: Option, + pub limit: u64, + pub fields: String, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ReverseSearchQuery { + pub content_token: String, +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ReverseSearchAnswer { + pub exact_post: Option, + pub similar_posts: Vec<()>, +} \ No newline at end of file diff --git a/src/api/post/post.rs b/src/api/post/post.rs new file mode 100644 index 0000000..bf236dd --- /dev/null +++ b/src/api/post/post.rs @@ -0,0 +1,115 @@ +use std::sync::Arc; +use axum::{ + extract::{Path, Query, State}, + Json, +}; +use log::debug; + +use crate::{ + error::{ApiError, ApiResult}, AppState, func::post::* +}; +use super::model::*; + +pub async fn list_of_posts( + Query(params): Query, + State(state): State>, +) -> ApiResult> { + debug!("Post listing params: {params:?}"); + // let fields_mas = get_fields_from_string(params.fields.clone()); + // debug!("{:?}", &fields_mas); + // oki + + let total = state.db.get_posts_count().await?; + let offset = { + match params.offset { + None => 0, + Some(i) => i, + } + }; + + let (results_raw, _) = state.db.get_posts_in_page(offset, params.limit).await?; + // PostQuery::find_posts_in_page_with_filter(&state.db, offset, fields_mas, params.limit).await.unwrap(); + debug!("{results_raw:?}"); + let mut results: Vec = Vec::new(); + for model in results_raw.iter() { + results.push(MiniPost::from_model(model, "data/avatarka.jpg".to_string(), 0, 0, 0, Vec::new())) + } // TODO: заглушки :( + + let posts = ListOfPostsAnswer { + query: params.fields, + offset, + limit: params.limit, + total, + results, + }; + + Ok(Json(posts)) + // end +} + +pub async fn get_post_by_id( + Path(id): Path, + State(state): State>, +) -> ApiResult> { + let raw_post = state.db.get_post_by_id(id).await?; + + let mut flags: Vec = Vec::new(); + if raw_post.flags.is_some() { + for part in raw_post.flags.unwrap().split(",") { + flags.push(part.to_string()); + } + } + + let post = PostAnswer { + id: raw_post.id, + version: raw_post.version, + creation_time: raw_post.creation_time, + last_edit_time: raw_post.last_edit_time, + safety: raw_post.safety, + source: raw_post.source, + type_field: raw_post.r#type, + mime_type: raw_post.mime_type.clone(), + checksum: raw_post.checksum, + checksum_md5: raw_post.checksum_md5, + file_size: raw_post.file_size, + canvas_width: raw_post.image_width, + canvas_height: raw_post.image_height, + content_url: get_post_content_path(raw_post.id, get_post_security_hash(id, &state.config.secret), &raw_post.mime_type), + thumbnail_url: get_post_thumbnail_path(raw_post.id, get_post_security_hash(id, &state.config.secret)), + flags, // TODO: Дальше чисто заглушки + tags: Vec::new(), + relations: Vec::new(), + user: None, + score: 0, + own_score: 0, + own_favorite: false, + tag_count: 0, + favorite_count: 0, + comment_count: 0, + note_count: 0, + relation_count: 0, + feature_count: 0, + last_feature_time: None, + favorited_by: Vec::new(), + has_custom_thumbnail: false, + notes: Vec::new(), + comments: Vec::new(), + pools: Vec::new(), + }; + + Ok(Json(post)) +} + +pub async fn reverse_post_search( + State(state): State>, + Json(content_path): Json +) -> ApiResult> { + // TODO: Пока что здесь просто заглушка + if !state.uploads.lock().expect("Uploads mutex was poisoned!").is_existing(&content_path.content_token) { + return Err(ApiError::Uploads); + }; + Ok(Json(ReverseSearchAnswer { + exact_post: None, + similar_posts: Vec::new(), + })) +} \ No newline at end of file diff --git a/src/api/test.rs b/src/api/test.rs new file mode 100644 index 0000000..adeeaed --- /dev/null +++ b/src/api/test.rs @@ -0,0 +1,30 @@ +use std::sync::Arc; + +use crate::{error::*, AppState, RequireAuth}; +use axum::{extract::State, Json}; +use serde_json::{json, Value}; +use log::debug; + +pub async fn test( + auth: RequireAuth, + State(state): State>, +) -> ApiResult> { + // TODO: Может в будущем это будет диагностикой + + let state = state.uploads.lock().expect("Uploads poisoned").vec(); + let body = Json(json!({"auth": format!("{auth:?}"), "uploads": format!("{:?}", state)})); + + debug!("{body:?}"); + return Ok(body); + +} + +pub async fn newtest( +) -> ApiResult> { + return Err(ApiError::Test(TestError::ItsJustForTest)); +} + +pub async fn newtest2( +) -> ApiResult> { + return Err(ApiError::Test(TestError::SecondEntry)); +} \ No newline at end of file diff --git a/src/api/user.rs b/src/api/user.rs new file mode 100644 index 0000000..7136a5e --- /dev/null +++ b/src/api/user.rs @@ -0,0 +1,134 @@ +use std::str::FromStr; +use std::sync::Arc; + +use axum::extract::{Path, Query, State, Json}; +use chrono::{Local, NaiveDateTime}; +use serde::{Serialize, Deserialize}; +use log::debug; +use sea_orm::Set; + +use crate::{ + db::schemas::user, error::ApiResult, AppState, AvatarStyle, UserRank +}; + +#[derive(Serialize, Deserialize)] +pub struct UserHttpAnswer { + pub name: String, + #[serde(rename = "creationTime")] + pub creation_time: NaiveDateTime, + #[serde(rename = "lastLoginTime")] + pub last_login_time: Option, + pub version: i32, + pub rank: UserRank, + #[serde(rename = "avatarStyle")] + pub avatar_style: AvatarStyle, + #[serde(rename = "avatarUrl")] + pub avatar_url: String, + #[serde(rename = "commentCount")] + pub comment_count: i32, + #[serde(rename = "uploadedPostCount")] + pub uploaded_post_count: i32, + #[serde(rename = "favoritePostCount")] + pub favorite_post_count: i32, + #[serde(rename = "likedPostCount")] + pub liked_post_count: i32, + #[serde(rename = "dislikedPostCount")] + pub disliked_post_count: i32, + pub email: Option, +} + +// TODO! Rework all structs to use 'rename_all = "camelCase"' +#[derive(Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct MicroUser { + pub name: String, + pub avatar_url: String, +} + +#[derive(Debug, Deserialize)] +pub struct UserHttpQuery { + #[serde(rename = "bump-login")] + pub bump_login: bool, +} + +impl Default for UserHttpQuery { + fn default() -> Self { + Self { bump_login: false } + } +} + +pub async fn get_user( + Path(user): Path, + params: Option>, + State(state): State>, +) -> ApiResult> { + + let mut raw_user = state.db.get_user_by_name(&user).await?; + + // Update last login time if needed P.S. Лишние операции... так то это всё true false нахуй не надо! + let Query(params) = params.unwrap_or_default(); + if params.bump_login == true { + raw_user = state.db.update_last_login_time(&raw_user.name).await? + } + + Ok(Json(UserHttpAnswer { + name: user, + creation_time: raw_user.creation_time, + last_login_time: raw_user.last_login_time, + version: raw_user.version, + rank: UserRank::from_str(&raw_user.rank).unwrap(), + avatar_style: AvatarStyle::from_str(&raw_user.avatar_style).unwrap(), + avatar_url: "data/avatarka.jpg".to_string(), // TODO! Hardcoded shit! + comment_count: 0, // TODO! + uploaded_post_count: 0, // TODO! + favorite_post_count: 0, // TODO! + liked_post_count: 0, // TODO! + disliked_post_count: 0, // TODO! + email: raw_user.email, + })) +} + +#[derive(Deserialize, Debug)] +pub struct CreateUserHttpQuery { + pub name: String, + pub password: String, + pub email: Option, + pub rank: Option, + #[serde(rename = "avatarStyle")] + pub avatar_style: Option, +} + +pub async fn create_user( + State(state): State>, + Json(params): Json, // ЭТА ЕБУЧАЯ ХУЙНЯ ДОЛЖНА БЫТЬ ПОСЛЕДНЕЙ, НАВОДИСЬ НА JSON И ПРОЧИТАЙ ПОСЛЕДНЮЮ СТРОКУ СПРАВКИ +) -> ApiResult> { + debug!("Trying to create new user with credentials: {params:?}"); + let form_data = user::ActiveModel { + name: Set(params.name.clone()), // TODO! + password_hash: Set("aaa".to_string()), // Переделать под Default + password_salt: Set(Some("aaa".to_string())), // За пример взять UserToken + email: Set(params.email.clone()), + rank: Set(UserRank::Administrator.to_string()), + creation_time: Set(Local::now().naive_local().to_owned()), + avatar_style: Set(AvatarStyle::Gravatar.to_string()), + ..Default::default() + }; + let created_user = state.db.create_user(form_data).await?; + + let raw_user = state.db.get_user_by_id(created_user.id.unwrap() as u64).await?; + Ok(Json(UserHttpAnswer { + name: raw_user.name, + creation_time: raw_user.creation_time, + last_login_time: raw_user.last_login_time, + version: raw_user.version, + rank: UserRank::from_str(&raw_user.rank).unwrap(), + avatar_style: AvatarStyle::from_str(&raw_user.avatar_style).unwrap(), + avatar_url: "data/avatarka.jpg".to_string(), // TODO! Hardcoded shit! + comment_count: 0, // TODO! + uploaded_post_count: 0, // TODO! + favorite_post_count: 0, // TODO! + liked_post_count: 0, // TODO! + disliked_post_count: 0, // TODO! + email: raw_user.email, + })) +} \ No newline at end of file diff --git a/src/api/usertoken.rs b/src/api/usertoken.rs new file mode 100644 index 0000000..4de8e45 --- /dev/null +++ b/src/api/usertoken.rs @@ -0,0 +1,131 @@ +use std::sync::Arc; + +use axum::{extract::{Path, State}, Json}; +use chrono::{DateTime, Local, Months, NaiveDateTime}; +use sea_orm::Set; +use serde::{Deserialize, Serialize}; +use log::debug; +use uuid::Uuid; + +use crate::{ + db::schemas::user_token, error::{ApiError, ApiResult}, AppState +}; + +use super::user::MicroUser; + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct UserTokenHttpResponse { + pub user: MicroUser, + pub token: String, + pub note: Option, + pub enabled: bool, + pub expiration_time: Option, + pub creation_time: NaiveDateTime, + pub last_edit_time: Option, + pub last_usage_time: Option, + pub version: i32, +} + +#[derive(Deserialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct CreateUserTokenHttpQuery { + pub enabled: Option, + pub note: Option, + pub expiration_time: Option>, +} + +// Внимание! Строчки дальше отвечают за состояния по умолчанию при создании токена +// проблема в том что при логине на фронтенде "expiration_time" не указывается +// и будет браться от сюда. TODO: Брать значение offset'a из конфига, а не хардкод! +impl Default for CreateUserTokenHttpQuery { + fn default() -> Self { + Self { + enabled: Some(true), + note: Some("Undefined due creation".to_string()), + expiration_time: Some(Local::now().checked_add_months(Months::new(12)).unwrap()) + } + } +} + +pub async fn create_usertoken( // POST + Path(user): Path, + State(state): State>, + Json(params): Json, // ЭТА ЕБУЧАЯ ХУЙНЯ ДОЛЖНА БЫТЬ ПОСЛЕДНЕЙ, НАВОДИСЬ НА JSON И ПРОЧИТАЙ ПОСЛЕДНЮЮ СТРОКУ СПРАВКИ +) -> ApiResult> { + debug!("Trying to create new user-token for '{user}' with params: {params:?}"); + let user = state.db.get_user_by_name(&user).await?; + let form_data = user_token::ActiveModel { + user_id: Set(user.id), + token: Set(Uuid::new_v4().to_string()), + // Ооо! Пресвятой колхоз! + note: Set(Some(params.note.unwrap_or(CreateUserTokenHttpQuery::default().note.unwrap()))), + enabled: Set(params.enabled.unwrap_or(CreateUserTokenHttpQuery::default().enabled.unwrap())), + // Ооо! Пресвятой колхоз со временем! + expiration_time: Set(Some(params.expiration_time.unwrap_or(CreateUserTokenHttpQuery::default().expiration_time.unwrap()).naive_utc())), + ..Default::default() + }; + debug!("{form_data:?}"); + state.db.create_user_token(form_data.clone()).await?; + let raw_token = state.db.get_user_token(&form_data.token.unwrap()).await?; + Ok(Json(UserTokenHttpResponse { + user: MicroUser { name: user.name, avatar_url: "data/avatarka.jpg".to_string() }, // FIXME: hardcoded + token: raw_token.token, + note: raw_token.note, + enabled: raw_token.enabled, + expiration_time: raw_token.expiration_time, + creation_time: raw_token.creation_time, + last_edit_time: raw_token.last_edit_time, + last_usage_time: raw_token.last_usage_time, + version: raw_token.version, + })) +} + +pub async fn delete_usertoken( + Path((user, token)): Path<(String, String)>, + State(state): State>, +) -> ApiResult<&'static str> { + if state.db.get_user_by_name(&user).await?.id == state.db.get_user_token(&token).await?.user_id { + state.db.delete_user_token(&token).await?; + debug!("Token {token} deleted!") + } else { + return Err(ApiError::DeleteToken(crate::db::errors::DeleteUserTokenError::TokenUserIdDontMatch)); + } + // Output + Ok("{}") +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ListUserTokensHttpResponse { + pub results: Vec, +} + +pub async fn list_usertokens( // GET + Path(user): Path, + State(state): State>, +) -> ApiResult> { + let user = state.db.get_user_by_name(&user).await?; + let raw_tokens = state.db.get_user_tokens_by_user_id(user.id as u64).await?; + let miniuser = MicroUser { + name: user.name, + avatar_url: "data/avatarka.jpg".to_string(), // FIXME: hardcoded + }; + let mut prepared_tokens: Vec = Vec::new(); + for model in raw_tokens.iter() { + prepared_tokens.push(UserTokenHttpResponse { + user: miniuser.clone(), + token: model.token.to_owned(), + note: model.note.to_owned(), + enabled: model.enabled, + expiration_time: model.expiration_time, + creation_time: model.creation_time, + last_edit_time: model.last_edit_time, + last_usage_time: model.last_usage_time, + version: model.version, + }) + } + Ok(Json(ListUserTokensHttpResponse { + results: prepared_tokens, + })) +} \ No newline at end of file diff --git a/src/auth-dw.rs b/src/auth-dw.rs new file mode 100644 index 0000000..8420709 --- /dev/null +++ b/src/auth-dw.rs @@ -0,0 +1,92 @@ +use axum::async_trait; +use password_auth::verify_password; +use sea_orm::DatabaseConnection; +use serde::{Serialize, Deserialize}; +use axum_login::{self, AuthUser, AuthnBackend, UserId}; +use tokio::task; + +// +// FOR DELETE! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! +// + +#[derive(Clone, Serialize, Deserialize)] +pub struct User { + id: i32, + pub name: String, + password: String, +} + +impl std::fmt::Debug for User { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("User") + .field("id", &self.id) + .field("username", &self.name) + .field("password", &"[redacted]") + .finish() + } +} + +impl AuthUser for User { + type Id = i32; + + fn id(&self) -> Self::Id { + self.id + } + + fn session_auth_hash(&self) -> &[u8] { + self.password.as_bytes() + } +} + +pub struct Credentials { + pub username: String, + pub password: String, + pub next: Option, +} + +#[derive(Debug, Clone)] +pub struct Backend { + db: DatabaseConnection, +} + +impl Backend { + pub fn new(db: DatabaseConnection) -> Self { + Self { db } + } +} + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + Database(#[from] sea_orm::DbErr), + + #[error(transparent)] + TaskJoin(#[from] task::JoinError), +} + +#[async_trait] +impl AuthnBackend for Backend { + type User = User; + type Credentials = Credentials; + type Error = Error; + + async fn authenticate( + &self, + creds: Self::Credentials + ) -> Result, Self::Error> { + let raw_user = service::UserQuery::find_user_credentials_by_name(&self.db, &creds.username).await?.unwrap(); + let user = Some(Self::User { id: raw_user.id, name: raw_user.name, password: raw_user.password_hash }); + task::spawn_blocking(|| { + // We're using password-based authentication--this works by comparing our form + // input with an argon2 password hash. + Ok(user.filter(|user| verify_password(creds.password, &user.password).is_ok())) + }) + .await? + } + + async fn get_user(&self, user_id: &UserId) -> Result, Self::Error> { + let raw_user = service::UserQuery::find_user_credentials_by_id(&self.db, *user_id).await?.unwrap(); + let user = Some(Self::User { id: raw_user.id, name: raw_user.name, password: raw_user.password_hash }); + Ok(user) + } +} \ No newline at end of file diff --git a/src/auth.rs b/src/auth.rs new file mode 100644 index 0000000..4b413d0 --- /dev/null +++ b/src/auth.rs @@ -0,0 +1,106 @@ +use axum::{ + extract::FromRequestParts, + http::{header, StatusCode, request::Parts}, + async_trait, +}; +use log::debug; +use data_encoding::BASE64; + +#[derive(PartialEq, Debug)] +pub enum RequireAuth { + Basic { + name: String, + password: String, + }, + Token { + name: String, + token: String, + }, + None, +} + +impl Default for RequireAuth { + fn default() -> Self { + Self::None + } +} + +impl RequireAuth { + pub fn is_some(&self) -> bool { + !matches!(*self, RequireAuth::None) + } + pub fn is_none(&self) -> bool { + matches!(*self, RequireAuth::None) + } +} + +// pub struct User { +// pub id: i32, +// pub name: String, +// pub rank: UserRank, +// } + +#[async_trait] +impl FromRequestParts for RequireAuth +where + S: Send + Sync, +{ + type Rejection = StatusCode; + + async fn from_request_parts(parts: &mut Parts, _: &S) -> Result { + let auth_header = parts + .headers + .get(header::AUTHORIZATION) + .and_then(|value| value.to_str().ok()); + // let auth_cookie; TODO: Узнать на счёт использования кукесов для авторизации + debug!("!AUTH {auth_header:?}"); + + if auth_header.is_none() { + debug!("Don't have Auth: {auth_header:?}"); + return Ok(Self::default()) + } + let (metod, auth) = match auth_header.unwrap().split_once(' ') { + Some((metod, auth)) => (metod, auth), + None => ("", auth_header.unwrap()), // В метод ничего, а в ауз то что было в голове. + }; + + match metod { + "Basic" => { + let auth = String::from_utf8(BASE64.decode(auth.as_bytes()).unwrap()).unwrap(); + let (name, password) = auth.split_once(':').unwrap(); + debug!("!BASIC {name} {password}"); + Ok(Self::Basic {name: name.to_string(), password: password.to_string()}) + } + "Token" => { + let auth = String::from_utf8(BASE64.decode(auth.as_bytes()).unwrap()).unwrap(); + let (name, token) = auth.split_once(':').unwrap(); + debug!("!TOKEN {name} {token}"); + Ok(Self::Token { name: name.to_string(), token: token.to_string() }) + } + _ => { // Попадём сюда в случае если метод пустой, когда там неверные данные например, или если что-то другое. + // Boom! + debug!("Something other in auth: {auth}"); + Ok(Self::default()) + } + } + + // debug!("Auth: {auth_header:?}"); + // Ok(Self::default()) + } +} + +#[cfg(test)] +mod tests { + use crate::RequireAuth; + + #[test] + fn is_some() { + let x = RequireAuth::Basic { name: "".to_string(), password: "".to_string() }; + assert_eq!(x.is_some(), true) + } + #[test] + fn is_none() { + let x = RequireAuth::None; + assert_eq!(x.is_none(), true) + } +} \ No newline at end of file diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..ac27a7d --- /dev/null +++ b/src/config.rs @@ -0,0 +1,251 @@ +use std::{io::Read, path::PathBuf}; + +use serde::{Deserialize, Serialize}; + +use crate::UserRank; + +#[derive(Deserialize, Clone, Debug)] +pub struct Config { + pub name: String, + pub domain: String, + pub listen: String, + pub secret: String, + pub delete_source_files: bool, + pub contact_email: String, + pub enable_safety: bool, + pub tag_name_regex: String, + pub tag_category_name_regex: String, + pub pool_name_regex: String, + pub pool_category_name_regex: String, + pub password_regex: String, + pub user_name_regex: String, + pub allow_broken_uploads: bool, + pub webhooks: Option>, + pub default_rank: UserRank, + pub thumbnails: Thumbnails, + pub smtp: Smtp, + pub privileges: Privileges, +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct Thumbnails { + pub avatar_width: u64, + pub avatar_height: u64, + pub post_width: u64, + pub post_height: u64, +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct Smtp { + pub enabled: bool, + pub host: String, + pub port: u16, + pub user: String, + pub pass: String, + pub from: String, +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct Privileges { + #[serde(rename = "users:create:self")] + pub users_create_self: UserRank, + #[serde(rename = "users:create:any")] + pub users_create_any: UserRank, + #[serde(rename = "users:list")] + pub users_list: UserRank, + #[serde(rename = "users:view")] + pub users_view: UserRank, + #[serde(rename = "users:edit:any:name")] + pub users_edit_any_name: UserRank, + #[serde(rename = "users:edit:any:pass")] + pub users_edit_any_pass: UserRank, + #[serde(rename = "users:edit:any:email")] + pub users_edit_any_email: UserRank, + #[serde(rename = "users:edit:any:avatar")] + pub users_edit_any_avatar: UserRank, + #[serde(rename = "users:edit:any:rank")] + pub users_edit_any_rank: UserRank, + #[serde(rename = "users:edit:self:name")] + pub users_edit_self_name: UserRank, + #[serde(rename = "users:edit:self:pass")] + pub users_edit_self_pass: UserRank, + #[serde(rename = "users:edit:self:email")] + pub users_edit_self_email: UserRank, + #[serde(rename = "users:edit:self:avatar")] + pub users_edit_self_avatar: UserRank, + #[serde(rename = "users:edit:self:rank")] + pub users_edit_self_rank: UserRank, + #[serde(rename = "users:delete:any")] + pub users_delete_any: UserRank, + #[serde(rename = "users:delete:self")] + pub users_delete_self: UserRank, + #[serde(rename = "userTokens:list:any")] + pub user_tokens_list_any: UserRank, + #[serde(rename = "userTokens:list:self")] + pub user_tokens_list_self: UserRank, + #[serde(rename = "userTokens:create:any")] + pub user_tokens_create_any: UserRank, + #[serde(rename = "userTokens:create:self")] + pub user_tokens_create_self: UserRank, + #[serde(rename = "userTokens:edit:any")] + pub user_tokens_edit_any: UserRank, + #[serde(rename = "userTokens:edit:self")] + pub user_tokens_edit_self: UserRank, + #[serde(rename = "userTokens:delete:any")] + pub user_tokens_delete_any: UserRank, + #[serde(rename = "userTokens:delete:self")] + pub user_tokens_delete_self: UserRank, + #[serde(rename = "posts:create:anonymous")] + pub posts_create_anonymous: UserRank, + #[serde(rename = "posts:create:identified")] + pub posts_create_identified: UserRank, + #[serde(rename = "posts:list")] + pub posts_list: UserRank, + #[serde(rename = "posts:reverseSearch")] + pub posts_reverse_search: UserRank, + #[serde(rename = "posts:view")] + pub posts_view: UserRank, + #[serde(rename = "posts:view:featured")] + pub posts_view_featured: UserRank, + #[serde(rename = "posts:edit:content")] + pub posts_edit_content: UserRank, + #[serde(rename = "posts:edit:flags")] + pub posts_edit_flags: UserRank, + #[serde(rename = "posts:edit:notes")] + pub posts_edit_notes: UserRank, + #[serde(rename = "posts:edit:relations")] + pub posts_edit_relations: UserRank, + #[serde(rename = "posts:edit:safety")] + pub posts_edit_safety: UserRank, + #[serde(rename = "posts:edit:source")] + pub posts_edit_source: UserRank, + #[serde(rename = "posts:edit:tags")] + pub posts_edit_tags: UserRank, + #[serde(rename = "posts:edit:thumbnail")] + pub posts_edit_thumbnail: UserRank, + #[serde(rename = "posts:feature")] + pub posts_feature: UserRank, + #[serde(rename = "posts:delete")] + pub posts_delete: UserRank, + #[serde(rename = "posts:score")] + pub posts_score: UserRank, + #[serde(rename = "posts:merge")] + pub posts_merge: UserRank, + #[serde(rename = "posts:favorite")] + pub posts_favorite: UserRank, + #[serde(rename = "posts:bulk-edit:tags")] + pub posts_bulk_edit_tags: UserRank, + #[serde(rename = "posts:bulk-edit:safety")] + pub posts_bulk_edit_safety: UserRank, + #[serde(rename = "posts:bulk-edit:delete")] + pub posts_bulk_edit_delete: UserRank, + #[serde(rename = "tags:create")] + pub tags_create: UserRank, + #[serde(rename = "tags:edit:names")] + pub tags_edit_names: UserRank, + #[serde(rename = "tags:edit:category")] + pub tags_edit_category: UserRank, + #[serde(rename = "tags:edit:description")] + pub tags_edit_description: UserRank, + #[serde(rename = "tags:edit:implications")] + pub tags_edit_implications: UserRank, + #[serde(rename = "tags:edit:suggestions")] + pub tags_edit_suggestions: UserRank, + #[serde(rename = "tags:list")] + pub tags_list: UserRank, + #[serde(rename = "tags:view")] + pub tags_view: UserRank, + #[serde(rename = "tags:merge")] + pub tags_merge: UserRank, + #[serde(rename = "tags:delete")] + pub tags_delete: UserRank, + #[serde(rename = "tagCategories:create")] + pub tag_categories_create: UserRank, + #[serde(rename = "tagCategories:edit:name")] + pub tag_categories_edit_name: UserRank, + #[serde(rename = "tagCategories:edit:color")] + pub tag_categories_edit_color: UserRank, + #[serde(rename = "tagCategories:edit:order")] + pub tag_categories_edit_order: UserRank, + #[serde(rename = "tagCategories:list")] + pub tag_categories_list: UserRank, + #[serde(rename = "tagCategories:view")] + pub tag_categories_view: UserRank, + #[serde(rename = "tagCategories:delete")] + pub tag_categories_delete: UserRank, + #[serde(rename = "tagCategories:setDefault")] + pub tag_categories_set_default: UserRank, + #[serde(rename = "pools:create")] + pub pools_create: UserRank, + #[serde(rename = "pools:edit:names")] + pub pools_edit_names: UserRank, + #[serde(rename = "pools:edit:category")] + pub pools_edit_category: UserRank, + #[serde(rename = "pools:edit:description")] + pub pools_edit_description: UserRank, + #[serde(rename = "pools:edit:posts")] + pub pools_edit_posts: UserRank, + #[serde(rename = "pools:list")] + pub pools_list: UserRank, + #[serde(rename = "pools:view")] + pub pools_view: UserRank, + #[serde(rename = "pools:merge")] + pub pools_merge: UserRank, + #[serde(rename = "pools:delete")] + pub pools_delete: UserRank, + #[serde(rename = "poolCategories:create")] + pub pool_categories_create: UserRank, + #[serde(rename = "poolCategories:edit:name")] + pub pool_categories_edit_name: UserRank, + #[serde(rename = "poolCategories:edit:color")] + pub pool_categories_edit_color: UserRank, + #[serde(rename = "poolCategories:list")] + pub pool_categories_list: UserRank, + #[serde(rename = "poolCategories:view")] + pub pool_categories_view: UserRank, + #[serde(rename = "poolCategories:delete")] + pub pool_categories_delete: UserRank, + #[serde(rename = "poolCategories:setDefault")] + pub pool_categories_set_default: UserRank, + #[serde(rename = "comments:create")] + pub comments_create: UserRank, + #[serde(rename = "comments:delete:any")] + pub comments_delete_any: UserRank, + #[serde(rename = "comments:delete:own")] + pub comments_delete_own: UserRank, + #[serde(rename = "comments:edit:any")] + pub comments_edit_any: UserRank, + #[serde(rename = "comments:edit:own")] + pub comments_edit_own: UserRank, + #[serde(rename = "comments:list")] + pub comments_list: UserRank, + #[serde(rename = "comments:view")] + pub comments_view: UserRank, + #[serde(rename = "comments:score")] + pub comments_score: UserRank, + #[serde(rename = "snapshots:list")] + pub snapshots_list: UserRank, + #[serde(rename = "uploads:create")] + pub uploads_create: UserRank, + #[serde(rename = "uploads:useDownloader")] + pub uploads_use_downloader: UserRank, +} + +impl Config { + pub fn parse(path: PathBuf) -> Self { + let mut file = std::fs::File::open(path).expect("Access denied or file doesn't exists!"); + let mut data = String::new(); + file.read_to_string(&mut data).unwrap(); + + toml::from_str(&data).unwrap() + } +} + +// #[allow(dead_code)] +// impl Default for Config { +// fn default() -> Self { +// Self { +// name: "axumbooru".to_string(), +// } +// } +// } diff --git a/src/data.rs b/src/data.rs new file mode 100644 index 0000000..5b3dc18 --- /dev/null +++ b/src/data.rs @@ -0,0 +1,99 @@ +use std::{fmt::Write as _, fs, path::Path}; +use anyhow::{anyhow, Ok, Result}; +use axum::body::Bytes; +use dashmap::DashMap; +use log::{debug, info, warn}; +use ring::digest; + +#[derive(Debug)] +pub struct Data(DashMap); + +pub const DATA: &str = "./data"; +pub const AVATARS: &str = "./data/avatars"; +pub const POSTS: &str = "./data/posts"; +pub const TEMP: &str = "./data/temporary-uploads"; +pub const THUMBNAILS: &str = "./data/generated-thumbnails"; + +#[derive(Debug, Clone)] +pub struct Upload { + pub filename: String, + pub content_type: String, +} + +impl Data { + pub fn new() -> Self { + Self::default() + } + // Working with data dir + fn check_and_repair_directory(path: &str) -> Result<()> { + if !Path::new(path).is_dir() { + warn!("{} not found", path); + fs::create_dir(path)?; + info!("{} created!", path); + } + Ok(()) + } + pub fn repair_data() -> Result<()> { + debug!("Data Storage repair started!"); + Data::check_and_repair_directory(DATA)?; + Data::check_and_repair_directory(AVATARS)?; + Data::check_and_repair_directory(POSTS)?; + Data::check_and_repair_directory(TEMP)?; + Data::check_and_repair_directory(THUMBNAILS)?; + debug!("Data Storage repair complete!"); + Ok(()) + } + pub fn flush_temporary_uploads() -> Result<()> { + debug!("Flush started!"); + for file in fs::read_dir("./data/temporary-uploads")? { + let file = file?; + debug!("Removing {:?}", &file.file_name()); + fs::remove_file(file.path())?; + } + debug!("Flushing complete!"); + Ok(()) + } + // Implementing Self + pub fn vec(&self) -> Vec<(String, Upload)> { + self.0.clone().into_iter().collect() + } + pub fn get_and_remove(&self, token: &str) -> Option { + Some(self.0.remove(token)?.to_owned().1) + } + pub fn is_existing(&self, token: &str) -> bool { + self.0.contains_key(token) + } + pub fn add(&self, extension: &str, content_type: &str, raw: Bytes) -> Result { + let binding = digest::digest(&digest::SHA1_FOR_LEGACY_USE_ONLY, &raw); + let hash = binding.as_ref(); + // let hash = String::from_utf8(hash.to_vec())?; + let mut token = String::new(); + for byte in hash { + write!(token, "{:02x}", byte).unwrap(); + } + if self.is_existing(&token) { + return Err(anyhow!("{token} is existing!")); + }; + let filename = format!("{}.{}", token, extension); + fs::write(format!("./data/temporary-uploads/{filename}"), raw)?; + self.0.insert(token.clone(), Upload { filename, content_type: content_type.to_owned() }); + Ok(token) + } +} + +impl Default for Data { + fn default() -> Self { + Self(DashMap::new()) + } +} + +/* + +Работа с временными файлами + - Очистить директорию + - Получить список в виде Vec + - Проверить существование + - Добавить новый файл в список и вернуть контент токен + - Получить по токену структуру Uploads + +*/ \ No newline at end of file diff --git a/src/db/errors.rs b/src/db/errors.rs new file mode 100644 index 0000000..88a9a6a --- /dev/null +++ b/src/db/errors.rs @@ -0,0 +1,32 @@ +#[derive(thiserror::Error, Debug)] +#[error("Something went wrong.")] +pub struct DatabaseError { + #[from] + source: anyhow::Error, +} + +#[derive(thiserror::Error, Debug)] +pub enum GetUserError { + #[error("There is no user with {name:?} as name.")] + UserNotFound { + name: String, + #[source] + source: DatabaseError + }, + #[error("Something went wrong.")] + DatabaseError(#[from] DatabaseError), +} + +#[derive(thiserror::Error, Debug)] +pub enum DeleteUserTokenError { + #[error("There is no user_token with {token:?} as token.")] + TokenNotFound { + token: String, + #[source] + source: DatabaseError + }, + #[error("Token user_id and user doesn't match!")] + TokenUserIdDontMatch, + #[error("Something went wrong.")] + DatabaseError(#[from] DatabaseError), +} \ No newline at end of file diff --git a/src/db/mod.rs b/src/db/mod.rs new file mode 100644 index 0000000..dfbf257 --- /dev/null +++ b/src/db/mod.rs @@ -0,0 +1,3 @@ +pub mod schemas; +pub mod repository; +pub mod errors; \ No newline at end of file diff --git a/src/db/repository.rs b/src/db/repository.rs new file mode 100644 index 0000000..71a9240 --- /dev/null +++ b/src/db/repository.rs @@ -0,0 +1,280 @@ +use sea_orm::*; +use chrono::Local; + +use crate::db::schemas::{ + prelude::*, + user, user_token, post, snapshot, +}; +use super::errors::*; + +pub fn to_db_error(e: sea_orm::DbErr) -> DatabaseError { + DatabaseError::from(anyhow::Error::from(e)) +} + +#[derive(Debug, Clone)] +pub struct Repository(DatabaseConnection); + +impl Repository { + // Creating Structure + pub async fn create(url: String) -> anyhow::Result { + let pool = Database::connect(url).await?; + Ok(Repository(pool)) + } + pub fn with_connection(pool: DatabaseConnection) -> Repository { + Repository(pool) + } + + pub fn pool(&self) -> DatabaseConnection { + self.0.clone() + } + // User + pub async fn get_users_count(&self) -> Result { + User::find().count(&self.0).await.map_err(to_db_error) + } + pub async fn get_users_in_page(&self, page: u64, per_page: u64) -> Result<(Vec, u64), DatabaseError> { + // Setup paginator + let paginator = User::find() + .order_by_asc(user::Column::Id) + .paginate(&self.0, per_page); + let num_pages = paginator.num_pages().await.map_err(to_db_error)?; + // Fetch paginator users + paginator.fetch_page(page - 1).await.map_err(to_db_error).map(|p| (p, num_pages)) + } + pub async fn get_user_by_id(&self, id: u64) -> Result { + Ok(User::find_by_id(id as i32).one(&self.0).await.map_err(to_db_error)?.ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("User not found"))})?) + } + pub async fn get_user_by_name(&self, name: &str) -> Result { + let user = User::find() + .filter(user::Column::Name.contains(name)) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("User not found"))})?; + Ok(user) + } + pub async fn create_user(&self, user: user::ActiveModel) -> Result { + user::ActiveModel { + creation_time: Set(Local::now().naive_local().to_owned()), + version: Set(1), + password_revision: Set(3), + ..user + } + .save(&self.0) + .await.map_err(to_db_error) + } + pub async fn update_user(&self, id: u64, user: user::ActiveModel) -> Result { + let current_user: user::ActiveModel = User::find_by_id(id as i32) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("User not found"))}) + .map(Into::into)?; + let user = user.try_into_model().expect("Can't into model"); + user::ActiveModel { + id: current_user.id, + name: current_user.name, + password_hash: Set(user.password_hash.to_owned()), + password_salt: Set(user.password_salt.to_owned()), + email: Set(user.email.to_owned()), + rank: Set(user.rank.to_owned()), + creation_time: current_user.creation_time, + last_login_time: current_user.last_login_time, + avatar_style: Set(user.avatar_style.to_owned()), + version: Set(user.version.to_owned()), + password_revision: Set(user.password_revision.to_owned()), + } + .update(&self.0) + .await.map_err(to_db_error) + } + pub async fn delete_user(&self, id: u64) -> Result<(), DatabaseError> { + let user: user::ActiveModel = User::find_by_id(id as i32) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("User not found"))}) + .map(Into::into)?; + + user.delete(&self.0).await.map_err(to_db_error)?; + Ok(()) + } + pub async fn update_last_login_time(&self, name: &str) -> Result { + let mut current_user: user::ActiveModel = User::find() + .filter(user::Column::Name.contains(name)) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("User not found"))}) + .map(Into::into)?; + current_user.last_login_time = Set(Some(Local::now().naive_local().to_owned())); + current_user.update(&self.0).await.map_err(to_db_error) + } + // Post + pub async fn get_posts_count(&self) -> Result { + Post::find().count(&self.0).await.map_err(to_db_error) + } + pub async fn get_posts_in_page(&self, page: u64, per_page: u64) -> Result<(Vec, u64), DatabaseError> { + // Setup paginator + let paginator = Post::find() + .order_by_asc(post::Column::Id) + .paginate(&self.0, per_page); + let num_pages = paginator.num_pages().await.map_err(to_db_error)?; + // Fetch paginator posts + paginator.fetch_page(page).await.map_err(to_db_error).map(|p| (p, num_pages)) + } + pub async fn get_post_by_id(&self, id: u64) -> Result { + Ok(Post::find_by_id(id as i32).one(&self.0).await.map_err(to_db_error)?.ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("Post not found"))})?) + } + pub async fn create_post(&self, post: post::ActiveModel) -> Result { + post::ActiveModel { + creation_time: Set(Local::now().naive_local().to_owned()), + ..post + } + .save(&self.0) + .await.map_err(to_db_error) + } + pub async fn update_post(&self, id: u64, post: post::ActiveModel) -> Result { + let posts: post::ActiveModel = Post::find_by_id(id as i32) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("Post not found"))}) + .map(Into::into)?; + let post = post.try_into_model().expect("Can't into model"); + post::ActiveModel { + id: posts.id, + user_id: posts.user_id, + creation_time: posts.creation_time, + last_edit_time: Set(Some(Local::now().naive_local().to_owned())), + safety: Set(post.safety.to_owned()), + r#type: Set(post.r#type.to_owned()), + checksum: Set(post.checksum.to_owned()), + source: posts.source, + file_size: posts.file_size, + image_width: posts.image_width, + image_height: posts.image_height, + mime_type: Set(post.mime_type.to_owned()), + version: Set(post.version.to_owned()), + flags: posts.flags, + checksum_md5: posts.checksum_md5, + } + .update(&self.0) + .await.map_err(to_db_error) + } + pub async fn delete_post(&self, id: u64) -> Result<(), DatabaseError> { + let post: post::ActiveModel = Post::find_by_id(id as i32) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("Post not found"))}) + .map(Into::into)?; + post.delete(&self.0).await.map_err(to_db_error)?; + Ok(()) + } + // User Token + pub async fn get_user_tokens_count(&self) -> Result { + UserToken::find().count(&self.0).await.map_err(to_db_error) + } + pub async fn get_user_tokens_in_page(&self, page: u64, per_page: u64) -> Result<(Vec, u64), DatabaseError> { + // Setup paginator + let paginator = UserToken::find() + .order_by_asc(user_token::Column::Id) + .paginate(&self.0, per_page); + let num_pages = paginator.num_pages().await.map_err(to_db_error)?; + // Fetch paginator tokens + paginator.fetch_page(page).await.map_err(to_db_error).map(|p| (p, num_pages)) + } + pub async fn get_user_tokens_by_user_id(&self, user_id: u64) -> Result, DatabaseError> { + UserToken::find() + .filter(user_token::Column::UserId.eq(user_id)) + .order_by_asc(user_token::Column::Id) + .all(&self.0) + .await.map_err(to_db_error) + } + pub async fn get_user_token_by_id(&self, id: u64) -> Result { + Ok(UserToken::find_by_id(id as i32).one(&self.0).await.map_err(to_db_error)?.ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("UserToken not found"))})?) + } + pub async fn get_user_token(&self, token: &str) -> Result { + Ok(UserToken::find().filter(user_token::Column::Token.contains(token)).one(&self.0).await.map_err(to_db_error)?.ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("UserToken not found"))})?) + } + pub async fn create_user_token(&self, user_token: user_token::ActiveModel) -> Result { + user_token::ActiveModel { + creation_time: Set(Local::now().naive_local().to_owned()), + last_edit_time: Set(None), + last_usage_time: Set(None), + version: Set(1), + ..user_token + } + .save(&self.0) + .await.map_err(to_db_error) + } + pub async fn update_user_token(&self, id: u64, user_token: user_token::ActiveModel) -> Result { + let current_user_token: user_token::ActiveModel = UserToken::find_by_id(id as i32) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("UserToken not found"))}) + .map(Into::into)?; + let user_token = user_token.try_into_model().expect("Can't into model"); + user_token::ActiveModel { + id: current_user_token.id, + user_id: current_user_token.user_id, + token: current_user_token.token, + note: Set(user_token.note.to_owned()), // Can be updated + enabled: Set(user_token.enabled.to_owned()), // Can be updated + expiration_time: Set(user_token.expiration_time.to_owned()), // Can be updated + creation_time: current_user_token.creation_time, + last_edit_time: Set(Some(Local::now().naive_local().to_owned())), + last_usage_time: current_user_token.last_usage_time, + version: Set(user_token.version.to_owned()), // Can be updated + } + .update(&self.0) + .await.map_err(to_db_error) + } + pub async fn delete_user_token(&self, token: &str) -> Result<(), DeleteUserTokenError> { + let user_token: user_token::ActiveModel = UserToken::find() + .filter(user_token::Column::Token.contains(token)) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("UserToken not found"))}) + .map(Into::into)?; + + user_token.delete(&self.0).await.map_err(to_db_error)?; + Ok(()) + } + pub async fn update_last_token_usage_time(&self, name: &str) -> Result { + let mut user_token: user_token::ActiveModel = UserToken::find() + .filter(user_token::Column::Token.contains(name)) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("UserToken not found"))}) + .map(Into::into)?; + + user_token.last_usage_time = Set(Some(Local::now().naive_local().to_owned())); + + user_token.update(&self.0).await.map_err(to_db_error) + } + // Snapshot + pub async fn get_snapshots_count(&self) -> Result { + Snapshot::find().count(&self.0).await.map_err(to_db_error) + } + pub async fn get_snapshots_in_page(&self, page: u64, per_page: u64) -> Result<(Vec, u64), DatabaseError> { + // Setup paginator + let paginator = Snapshot::find() + .order_by_asc(snapshot::Column::Id) + .paginate(&self.0, per_page); + let num_pages = paginator.num_pages().await.map_err(to_db_error)?; + // Fetch paginator users + paginator.fetch_page(page - 1).await.map_err(to_db_error).map(|p| (p, num_pages)) + } + pub async fn create_snapshot(&self, snapshot: snapshot::ActiveModel) -> Result { + snapshot::ActiveModel { + creation_time: Set(Local::now().naive_local().to_owned()), + ..snapshot + } + .save(&self.0) + .await.map_err(to_db_error) + } + pub async fn delete_snapshot(&self, id: u64) -> Result<(), DatabaseError> { + let snapshot: snapshot::ActiveModel = Snapshot::find_by_id(id as i32) + .one(&self.0) + .await.map_err(to_db_error)? + .ok_or_else(|| {DatabaseError::from(anyhow::anyhow!("Snapshot not found"))}) + .map(Into::into)?; + + snapshot.delete(&self.0).await.map_err(to_db_error)?; + Ok(()) + } +} \ No newline at end of file diff --git a/src/db/schemas/mod.rs b/src/db/schemas/mod.rs new file mode 100644 index 0000000..a9909c3 --- /dev/null +++ b/src/db/schemas/mod.rs @@ -0,0 +1,9 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14 + +pub mod prelude; +pub mod prelude_model; + +pub mod post; +pub mod snapshot; +pub mod user; +pub mod user_token; diff --git a/src/db/schemas/post.rs b/src/db/schemas/post.rs new file mode 100644 index 0000000..b9e3d08 --- /dev/null +++ b/src/db/schemas/post.rs @@ -0,0 +1,45 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "post")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub user_id: Option, + pub creation_time: DateTime, + pub last_edit_time: Option, + pub safety: String, + pub r#type: String, + pub checksum: String, + pub source: Option, + pub file_size: Option, + pub image_width: Option, + pub image_height: Option, + #[sea_orm(column_name = "mime-type")] + pub mime_type: String, + pub version: i32, + pub flags: Option, + pub checksum_md5: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::user::Entity", + from = "Column::UserId", + to = "super::user::Column::Id", + on_update = "NoAction", + on_delete = "SetNull" + )] + User, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::User.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/db/schemas/prelude.rs b/src/db/schemas/prelude.rs new file mode 100644 index 0000000..5894a61 --- /dev/null +++ b/src/db/schemas/prelude.rs @@ -0,0 +1,6 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14 + +pub use super::post::Entity as Post; +pub use super::snapshot::Entity as Snapshot; +pub use super::user::Entity as User; +pub use super::user_token::Entity as UserToken; diff --git a/src/db/schemas/prelude_model.rs b/src/db/schemas/prelude_model.rs new file mode 100644 index 0000000..2dfd54a --- /dev/null +++ b/src/db/schemas/prelude_model.rs @@ -0,0 +1,4 @@ +pub use super::post::Model as Post; +pub use super::snapshot::Model as Snapshot; +pub use super::user::Model as User; +pub use super::user_token::Model as UserToken; \ No newline at end of file diff --git a/src/db/schemas/snapshot.rs b/src/db/schemas/snapshot.rs new file mode 100644 index 0000000..45c6d7d --- /dev/null +++ b/src/db/schemas/snapshot.rs @@ -0,0 +1,38 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "snapshot")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub creation_time: DateTime, + pub resource_type: String, + pub operation: String, + pub user_id: Option, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] + pub data: Option>, + pub resource_name: String, + pub resource_pkey: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::user::Entity", + from = "Column::UserId", + to = "super::user::Column::Id", + on_update = "NoAction", + on_delete = "SetNull" + )] + User, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::User.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/db/schemas/user.rs b/src/db/schemas/user.rs new file mode 100644 index 0000000..4e3ca34 --- /dev/null +++ b/src/db/schemas/user.rs @@ -0,0 +1,51 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "user")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, + pub password_hash: String, + pub password_salt: Option, + pub email: Option, + pub rank: String, + pub creation_time: DateTime, + pub last_login_time: Option, + pub avatar_style: String, + pub version: i32, + pub password_revision: i16, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::post::Entity")] + Post, + #[sea_orm(has_many = "super::snapshot::Entity")] + Snapshot, + #[sea_orm(has_many = "super::user_token::Entity")] + UserToken, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Post.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Snapshot.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::UserToken.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/db/schemas/user_token.rs b/src/db/schemas/user_token.rs new file mode 100644 index 0000000..c64a47b --- /dev/null +++ b/src/db/schemas/user_token.rs @@ -0,0 +1,39 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "user_token")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub user_id: i32, + pub token: String, + pub note: Option, + pub enabled: bool, + pub expiration_time: Option, + pub creation_time: DateTime, + pub last_edit_time: Option, + pub last_usage_time: Option, + pub version: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::user::Entity", + from = "Column::UserId", + to = "super::user::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + User, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::User.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..6065105 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,64 @@ +use axum::{http::StatusCode, response::{IntoResponse, Response}}; +use log::error; +use serde_json::json; + +use crate::db::errors::{DatabaseError, DeleteUserTokenError, GetUserError}; + +pub type ApiResult = Result; + +#[derive(thiserror::Error, Debug)] +pub enum ApiError { + #[error(transparent)] + Test(#[from] TestError), + #[error(transparent)] + Database(#[from] DatabaseError), + #[error(transparent)] + GetUser(#[from] GetUserError), + #[error(transparent)] + DeleteToken(#[from] DeleteUserTokenError), + #[error("Something went wrong!")] + Uploads, +} + +#[derive(thiserror::Error, Debug)] +pub enum TestError { + #[error("Its Just For Test")] + ItsJustForTest, // TODO: Это только на время разработки + #[error("Second error what can be")] + SecondEntry, // TODO: И это в том числе! +} + +impl IntoResponse for ApiError { + fn into_response(self) -> Response { + error!("Error on request: {self}"); + let description = self.to_string(); + match self { + ApiError::Test(TestError::ItsJustForTest) => internal_server_error("InternalError", "ItsJustForTest", &description), + ApiError::Test(TestError::SecondEntry) => internal_server_error("InternalError", "SecondEntry", &description), + ApiError::Database(_) => internal_server_error("InternalError", &description, &description), + ApiError::GetUser(_) => internal_server_error("InternalError", &description, &description), + ApiError::DeleteToken(DeleteUserTokenError::DatabaseError(_)) => internal_server_error("InternalError", &description, &description), + ApiError::DeleteToken(DeleteUserTokenError::TokenNotFound { .. }) => internal_server_error("InternalError", &description, &description), + ApiError::DeleteToken(DeleteUserTokenError::TokenUserIdDontMatch) => method_not_allowed(), + ApiError::Uploads => method_not_allowed(), + } + } +} + +fn internal_server_error(name: &str, title: &str, description: &str) -> Response { + ( + StatusCode::INTERNAL_SERVER_ERROR, + [("Content-Type", "application/json")], + json!({ + "name": name, + "title": title, + "description": description, + }).to_string(), + ).into_response() +} + +fn method_not_allowed() -> Response { + ( + StatusCode::METHOD_NOT_ALLOWED, + ).into_response() +} \ No newline at end of file diff --git a/src/func/mod.rs b/src/func/mod.rs new file mode 100644 index 0000000..f66bdac --- /dev/null +++ b/src/func/mod.rs @@ -0,0 +1 @@ +pub mod post; \ No newline at end of file diff --git a/src/func/post.rs b/src/func/post.rs new file mode 100644 index 0000000..b48de3b --- /dev/null +++ b/src/func/post.rs @@ -0,0 +1,26 @@ +use std::fmt::Display; +use md5::Md5; +use hmac::{Hmac, Mac}; + +type HmacMd5 = Hmac; + +pub fn get_post_security_hash(id: T, key: &str) -> String { + use std::fmt::Write; + let mut mac = HmacMd5::new_from_slice(key.as_bytes()).expect("Something wrong with HMAC key!"); + mac.update(id.to_string().as_bytes()); + let code = &mac.finalize().into_bytes()[0 .. 8]; // wtf how this work but im need 16 chars, and 8 getting 16 chars + let mut result = String::new(); + for byte in code { + write!(result, "{:02x}", byte).unwrap(); + } + result +} + +pub fn get_post_content_path(id: T, hash: String, mime: &str) -> String { + let extension = mime_guess2::get_mime_extensions_str(mime).expect("Unknown mime type!")[0]; + format!("data/posts/{id}_{hash}.{extension}").to_string() +} + +pub fn get_post_thumbnail_path(id: T, hash: String) -> String { + format!("data/generated-thumbnails/{id}_{hash}.jpg").to_string() +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..0c2dbc6 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,306 @@ +use axum::{ + extract::DefaultBodyLimit, middleware::from_extractor, routing::{delete, get, post}, Router +}; +use dotenvy::dotenv; +use serde::{Deserialize, Serialize}; +use tower_http::trace::TraceLayer; +use std::{path::PathBuf, str::FromStr, sync::{Arc, Mutex}}; +use log::{debug, error, info, trace}; + +// Configuration +pub mod config; +pub use config::Config; + +// API +pub mod api; + +// Functions +pub mod func; + +// Error +pub mod error; + +// Authentication +pub mod auth; +pub use auth::RequireAuth; + +// Database +pub mod db; +use db::repository::Repository; + +// Image Storage +pub mod data; +use data::Data; + +#[derive(Debug)] +pub struct AppState { + db: Repository, + config: Config, + uploads: Mutex, +} + +#[tokio::main] +async fn main() { + dotenv().ok(); + env_logger::init(); + + std::panic::set_hook(Box::new(|x| { + error!("{x}") + })); + + debug!("Current dir: {:?}", std::env::current_dir()); + + let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); + + Data::repair_data().unwrap(); + Data::flush_temporary_uploads().unwrap(); + + // set up connection pool + // let mut opt = ConnectOptions::new(db_url); + // opt.sqlx_logging(true) + // .sqlx_logging_level(log::LevelFilter::Trace); + + // let state = Arc::new(AppState { + // db: Database::connect(opt) + // .await + // .expect("Database connection error!"), + // config: Config::parse(PathBuf::from_str("booruconfig.toml").unwrap()), + // uploads: Mutex::new(HashMap::new()), + // }); + let state = Arc::new(AppState { + db: Repository::create(db_url) + .await + .expect("Database connection error!"), + config: Config::parse(PathBuf::from_str("booruconfig.toml").unwrap()), + uploads: Mutex::new(Data::new()), + }); + + let listen = state.config.listen.clone(); + + debug!("State ready!"); + trace!("Data:\n{:?}", state); + + let app = Router::new() + .route("/test", get(api::test::test)) + .route("/test1", get(api::test::newtest)) + .route("/test2", get(api::test::newtest2)) + // TODO: Удалить мусор выше + .route("/posts/", get(api::post::list_of_posts)) + .route("/posts/reverse-search", post(api::post::reverse_post_search)) + .route("/post/:id", get(api::post::get_post_by_id)) + .route("/user/:user", get(api::user::get_user)) + .route("/user-tokens/:user", get(api::usertoken::list_usertokens)) + .route("/user-token/:user", post(api::usertoken::create_usertoken)) + .route("/user-token/:user/:token", delete(api::usertoken::delete_usertoken)) + .route("/users", post(api::user::create_user)) + .route("/uploads", post(api::data::upload).layer(DefaultBodyLimit::max(1073741824))) // 1 GB + // TODO: Брать значение на максимально возможный для загрузки файл из конфига + .route_layer(from_extractor::()) // Auth, functions lower doesn't require it. + .route("/info", get(api::info::server_info)) + .fallback_service(api::data::data_static()) + .with_state(state) + .layer(TraceLayer::new_for_http()); + + let listener = tokio::net::TcpListener::bind(listen) + .await + .unwrap(); + info!("Listening on {}", listener.local_addr().unwrap()); + axum::serve(listener, app) + .with_graceful_shutdown(shutdown_signal()) + .await + .unwrap(); + info!("Serve stopped. Closing..."); +} + +// async fn handler() -> Result<(), AppError> { +// try_thing()?; +// Ok(()) +// } +// fn try_thing() -> Result<(), anyhow::Error> { +// anyhow::bail!("epic fail!") +// } + +async fn shutdown_signal() { + let ctrl_c = async { + tokio::signal::ctrl_c() + .await + .expect("failed to install Ctrl+C handler"); + }; + #[cfg(unix)] + let terminate = async { + tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()) + .expect("failed to install signal handler") + .recv() + .await; + }; + #[cfg(not(unix))] + let terminate = std::future::pending::<()>(); + tokio::select! { + () = ctrl_c => {}, + () = terminate => {}, + } + info!("Terminate signal received"); +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub enum UserRank { + #[serde(rename = "administrator")] + Administrator, + #[serde(rename = "moderator")] + Moderator, + #[serde(rename = "power")] + Power, + #[serde(rename = "regular")] + Regular, + #[serde(rename = "restricted")] + Restricted, + #[serde(rename = "anonymous")] + Anonymous, + #[serde(rename = "nobody")] + Nobody, +} + +impl FromStr for UserRank { + fn from_str(str: &str) -> std::result::Result { + match str { + "administrator" => Ok(Self::Administrator), + "moderator" => Ok(Self::Moderator), + "power" => Ok(Self::Power), + "regular" => Ok(Self::Regular), + "restricted" => Ok(Self::Restricted), + "anonymous" => Ok(Self::Anonymous), + "nobody" => Ok(Self::Nobody), + _ => Err(()), + } + } + + type Err = (); +} + +impl ToString for UserRank { + fn to_string(&self) -> String { + match self { + UserRank::Administrator => String::from("administrator"), + UserRank::Moderator => String::from("moderator"), + UserRank::Power => String::from("power"), + UserRank::Regular => String::from("regular"), + UserRank::Restricted => String::from("restricted"), + UserRank::Anonymous => String::from("anonymous"), + UserRank::Nobody => String::from("nobody"), + } + } +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub enum AvatarStyle { + #[serde(rename = "gravatar")] + Gravatar, + #[serde(rename = "manual")] + Manual, +} + +impl FromStr for AvatarStyle { + fn from_str(str: &str) -> std::result::Result { + match str { + "gravatar" => Ok(Self::Gravatar), + "manual" => Ok(Self::Manual), + _ => Err(()), + } + } + + type Err = (); +} + +impl ToString for AvatarStyle { + fn to_string(&self) -> String { + match self { + AvatarStyle::Gravatar => String::from("gravatar"), + AvatarStyle::Manual => String::from("manual"), + } + } +} + +// #[allow(dead_code)] +// #[derive(Serialize, Debug, thiserror::Error)] +// enum ApiErrorTypes { +// MissingRequiredFileError, +// MissingRequiredParameterError, +// InvalidParameterError, +// IntegrityError, +// SearchError, +// AuthError, +// PostNotFoundError, +// PostAlreadyFeaturedError, +// PostAlreadyUploadedError, +// InvalidPostIdError, +// InvalidPostSafetyError, +// InvalidPostSourceError, +// InvalidPostContentError, +// InvalidPostRelationError, +// InvalidPostNoteError, +// InvalidPostFlagError, +// InvalidFavoriteTargetError, +// InvalidCommentIdError, +// CommentNotFoundError, +// EmptyCommentTextError, +// InvalidScoreTargetError, +// InvalidScoreValueError, +// TagCategoryNotFoundError, +// TagCategoryAlreadyExistsError, +// TagCategoryIsInUseError, +// InvalidTagCategoryNameError, +// InvalidTagCategoryColorError, +// TagNotFoundError, +// TagAlreadyExistsError, +// TagIsInUseError, +// InvalidTagNameError, +// InvalidTagRelationError, +// InvalidTagCategoryError, +// InvalidTagDescriptionError, +// UserNotFoundError, +// UserAlreadyExistsError, +// InvalidUserNameError, +// InvalidEmailError, +// InvalidPasswordError, +// InvalidRankError, +// InvalidAvatarError, +// ProcessingError, +// ValidationError, +// } +// +// #[derive(Serialize)] +// struct ApiErrorResponse { +// name: String, +// title: String, +// description: String, +// } +// +// // Make our own error that wraps `anyhow::Error`. +// struct AppError(anyhow::Error); +// +// // Tell axum how to convert `AppError` into a response. +// impl IntoResponse for AppError { +// fn into_response(self) -> Response { +// ( +// StatusCode::INTERNAL_SERVER_ERROR, +// [("Content-Type", "application/json")], +// serde_json::to_string_pretty(&ApiErrorResponse { +// name: "ValidationError".to_string(), +// title: self.0.to_string(), +// description: "Error".to_string(), +// }) +// .unwrap(), +// ).into_response() +// } +// } +// +// // This enables using `?` on functions that return `Result<_, anyhow::Error>` to turn them into +// // `Result<_, AppError>`. That way you don't need to do that manually. +// impl From for AppError +// where +// E: Into, +// { +// fn from(err: E) -> Self { +// Self(err.into()) +// } +// } diff --git a/tests/service_tests.rs b/tests/service_tests.rs new file mode 100644 index 0000000..0f20468 --- /dev/null +++ b/tests/service_tests.rs @@ -0,0 +1,39 @@ +// use dotenvy::dotenv; +// use sea_orm::{ConnectOptions, Database}; +// use service::PostQuery; + + + +// #[tokio::test] +// async fn query_with_filter() { +// dotenv().ok(); +// // tracing_subscriber::fmt::init(); + +// let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); +// let opt = ConnectOptions::new(db_url); +// let db = Database::connect(opt).await.expect("Database connection error!"); + +// let fields_mas = [true, false, false, false, true, true, false, false, false, false, false, false, true, false, false]; + +// let (results_raw, _) = PostQuery::find_posts_in_page_with_filter(&db, 0, fields_mas, 42) +// .await +// .unwrap(); + +// println!("{results_raw:?}") +// } + +// #[tokio::test] +// async fn query_without_filter() { +// dotenv().ok(); +// // tracing_subscriber::fmt::init(); + +// let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); +// let opt = ConnectOptions::new(db_url); +// let db = Database::connect(opt).await.expect("Database connection error!"); + +// let (results_raw, _) = PostQuery::find_posts_in_page(&db, 0, 42) +// .await +// .unwrap(); + +// println!("{results_raw:?}") +// } \ No newline at end of file