diff options
author | cel 🌸 <cel@blos.sm> | 2023-06-20 14:54:05 +0100 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2023-06-20 14:54:05 +0100 |
commit | fefea214d392c306d1b9c54baa9a5762d702e12c (patch) | |
tree | e802dbf8b1ed8b8f324639b0c93bfd3907dd9d0f | |
parent | 4e24495b159df0dbc4f503843c08ccd452af616a (diff) | |
download | blossom-fefea214d392c306d1b9c54baa9a5762d702e12c.tar.gz blossom-fefea214d392c306d1b9c54baa9a5762d702e12c.tar.bz2 blossom-fefea214d392c306d1b9c54baa9a5762d702e12c.zip |
remove database
Diffstat (limited to '')
-rw-r--r-- | Cargo.lock | 463 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Rocket.toml | 4 | ||||
-rw-r--r-- | db/blossom.sqlite | bin | 4096 -> 0 bytes | |||
-rw-r--r-- | db/blossom.sqlite-shm | bin | 32768 -> 0 bytes | |||
-rw-r--r-- | db/blossom.sqlite-wal | bin | 86552 -> 0 bytes | |||
-rw-r--r-- | migrations/20230218162011_blossom.sql | 2 | ||||
-rw-r--r-- | src/main.rs | 62 | ||||
-rw-r--r-- | src/scrobbles.rs | 6 |
9 files changed, 33 insertions, 508 deletions
@@ -44,17 +44,6 @@ dependencies = [ ] [[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] name = "aho-corasick" version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -106,15 +95,6 @@ dependencies = [ ] [[package]] -name = "atoi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5" -dependencies = [ - "num-traits", -] - -[[package]] name = "atomic" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -157,12 +137,6 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" @@ -217,12 +191,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" [[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -378,21 +346,6 @@ dependencies = [ ] [[package]] -name = "crc" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49fc9a695bca7f35f5f4c15cddc84415f66a74ea78eef08e90c5024f2b540e23" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" - -[[package]] name = "crc32fast" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -402,25 +355,6 @@ dependencies = [ ] [[package]] -name = "crossbeam-queue" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] name = "crypto-common" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -562,19 +496,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - -[[package]] name = "either" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" -dependencies = [ - "serde", -] [[package]] name = "encoding_rs" @@ -604,12 +529,6 @@ dependencies = [ ] [[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] name = "fastrand" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -655,18 +574,6 @@ dependencies = [ ] [[package]] -name = "flume" -version = "0.10.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" -dependencies = [ - "futures-core", - "futures-sink", - "pin-project", - "spin 0.9.5", -] - -[[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -774,17 +681,6 @@ dependencies = [ ] [[package]] -name = "futures-intrusive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" -dependencies = [ - "futures-core", - "lock_api", - "parking_lot 0.11.2", -] - -[[package]] name = "futures-io" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -926,38 +822,11 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] -name = "hashlink" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" -dependencies = [ - "hashbrown 0.11.2", -] - -[[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.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -976,12 +845,6 @@ dependencies = [ ] [[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.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1134,7 +997,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown 0.12.3", + "hashbrown", "serde", ] @@ -1208,15 +1071,6 @@ dependencies = [ ] [[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] name = "itoa" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1260,17 +1114,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] -name = "libsqlite3-sys" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" -dependencies = [ - "cc", - "pkg-config", - "vcpkg", -] - -[[package]] name = "link-cplusplus" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1404,12 +1247,6 @@ dependencies = [ ] [[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.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1487,7 +1324,7 @@ dependencies = [ "log", "memchr", "mime", - "spin 0.9.5", + "spin", "tokio", "tokio-util", "version_check", @@ -1523,16 +1360,6 @@ dependencies = [ ] [[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 = "normpath" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1663,37 +1490,12 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - -[[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 0.9.7", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall", - "smallvec", - "winapi 0.3.9", + "parking_lot_core", ] [[package]] @@ -1731,12 +1533,6 @@ dependencies = [ ] [[package]] -name = "paste" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" - -[[package]] name = "pear" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1867,26 +1663,6 @@ dependencies = [ ] [[package]] -name = "pin-project" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] name = "pin-project-lite" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2099,21 +1875,6 @@ dependencies = [ ] [[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted", - "web-sys", - "winapi 0.3.9", -] - -[[package]] name = "rocket" version = "0.5.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2133,7 +1894,7 @@ dependencies = [ "memchr", "multer", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "rand", "ref-cast", @@ -2169,28 +1930,6 @@ dependencies = [ ] [[package]] -name = "rocket_db_pools" -version = "0.1.0-rc.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc154f4f4985a136e2d59c336474a56da02103993f5e637e3a5424971ee4eff" -dependencies = [ - "rocket", - "rocket_db_pools_codegen", - "sqlx", - "version_check", -] - -[[package]] -name = "rocket_db_pools_codegen" -version = "0.1.0-rc.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa8f9b37bb1d4827aa5cca400d74e91d30f4352713cb65d6e7427bafe21336c" -dependencies = [ - "devise", - "quote", -] - -[[package]] name = "rocket_dyn_templates" version = "0.1.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2231,19 +1970,6 @@ dependencies = [ ] [[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.1", - "log", - "ring", - "sct", - "webpki", -] - -[[package]] name = "rustversion" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2292,16 +2018,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] name = "security-framework" version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2440,10 +2156,8 @@ dependencies = [ "mastodon-async", "reqwest", "rocket", - "rocket_db_pools", "rocket_dyn_templates", "serde", - "sqlx", "tokio", ] @@ -2498,118 +2212,9 @@ dependencies = [ [[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.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" -dependencies = [ - "lock_api", -] - -[[package]] -name = "sqlformat" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b7922be017ee70900be125523f38bdd644f4f06a1b16e8fa5a8ee8c34bffd4" -dependencies = [ - "itertools", - "nom", - "unicode_categories", -] - -[[package]] -name = "sqlx" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551873805652ba0d912fec5bbb0f8b4cdd96baf8e2ebf5970e5671092966019b" -dependencies = [ - "sqlx-core", - "sqlx-macros", -] - -[[package]] -name = "sqlx-core" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48c61941ccf5ddcada342cd59e3e5173b007c509e1e8e990dafc830294d9dc5" -dependencies = [ - "ahash", - "atoi", - "bitflags", - "byteorder", - "bytes", - "crc", - "crossbeam-queue", - "either", - "event-listener", - "flume", - "futures-channel", - "futures-core", - "futures-executor", - "futures-intrusive", - "futures-util", - "hashlink", - "hex", - "indexmap", - "itoa", - "libc", - "libsqlite3-sys", - "log", - "memchr", - "once_cell", - "paste", - "percent-encoding", - "rustls", - "serde", - "sha2", - "smallvec", - "sqlformat", - "sqlx-rt", - "stringprep", - "thiserror", - "tokio-stream", - "url", - "webpki", - "webpki-roots", -] - -[[package]] -name = "sqlx-macros" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0fba2b0cae21fc00fe6046f8baa4c7fcb49e379f0f592b04696607f69ed2e1" -dependencies = [ - "dotenv", - "either", - "heck", - "hex", - "once_cell", - "proc-macro2", - "quote", - "serde", - "serde_json", - "sha2", - "sqlx-core", - "sqlx-rt", - "syn", - "url", -] - -[[package]] -name = "sqlx-rt" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4db708cd3e459078f85f39f96a00960bd841f66ee2a669e90bf36907f5a79aae" -dependencies = [ - "once_cell", - "tokio", - "tokio-rustls", -] [[package]] name = "stable-pattern" @@ -2636,16 +2241,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "stringprep" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] name = "subtle" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2817,7 +2412,7 @@ dependencies = [ "memchr", "mio 0.8.6", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -2847,17 +2442,6 @@ dependencies = [ ] [[package]] -name = "tokio-rustls" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" -dependencies = [ - "rustls", - "tokio", - "webpki", -] - -[[package]] name = "tokio-stream" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3077,12 +2661,6 @@ dependencies = [ ] [[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] name = "unicode-width" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3095,12 +2673,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] -name = "unicode_categories" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" - -[[package]] name = "universal-hash" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3111,12 +2683,6 @@ dependencies = [ ] [[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] name = "url" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3291,25 +2857,6 @@ dependencies = [ ] [[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" -dependencies = [ - "webpki", -] - -[[package]] name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -7,8 +7,8 @@ edition = "2021" [dependencies] rocket = { version = "0.5.0-rc.2", features = ["json"] } -sqlx = { version = "0.5", default-features = false, features = ["macros", "offline", "migrate"] } -rocket_db_pools = { version = "0.1.0-rc.2", features = ["sqlx_sqlite"] } +# sqlx = { version = "0.5", default-features = false, features = ["macros", "offline", "migrate"] } +# rocket_db_pools = { version = "0.1.0-rc.2", features = ["sqlx_sqlite"] } reqwest = { version = "0.11", features = ["json"] } mastodon-async = "1.1" tokio = { version = "1", features = ["full"] } diff --git a/Rocket.toml b/Rocket.toml index 7686464..637a20b 100644 --- a/Rocket.toml +++ b/Rocket.toml @@ -1,2 +1,2 @@ -[default.databases.blossom] -url = "db/blossom.sqlite" +#[default.databases.blossom] +#url = "db/blossom.sqlite" diff --git a/db/blossom.sqlite b/db/blossom.sqlite Binary files differdeleted file mode 100644 index 3d1e885..0000000 --- a/db/blossom.sqlite +++ /dev/null diff --git a/db/blossom.sqlite-shm b/db/blossom.sqlite-shm Binary files differdeleted file mode 100644 index a276541..0000000 --- a/db/blossom.sqlite-shm +++ /dev/null diff --git a/db/blossom.sqlite-wal b/db/blossom.sqlite-wal Binary files differdeleted file mode 100644 index 9b36685..0000000 --- a/db/blossom.sqlite-wal +++ /dev/null diff --git a/migrations/20230218162011_blossom.sql b/migrations/20230218162011_blossom.sql index c8ed09d..d8c28a3 100644 --- a/migrations/20230218162011_blossom.sql +++ b/migrations/20230218162011_blossom.sql @@ -41,7 +41,7 @@ insert into text_formats (name) values ('plaintext'), ('markdown'), ('html'); create table notes ( post_id integer not null, - text_format varchar(16) not null default ('plaintext'); + text_format varchar(16) not null default ('plaintext'), text_content text, foreign key (post_id) references posts(id), foreign key (text_format) references text_formats(name) diff --git a/src/main.rs b/src/main.rs index 833a7ae..ab65f8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,41 +1,18 @@ -use rocket::fairing::{self, AdHoc}; -use rocket::fs::{relative, FileServer}; -use rocket::http::Status; -use rocket::State; -use rocket::{Build, Request, Rocket}; -use rocket_db_pools::sqlx; -use rocket_db_pools::Database; -use rocket_dyn_templates::{context, Template}; -use std::borrow::Cow; - +mod error; mod posts; mod scrobbles; mod skweets; -#[derive(Database)] -#[database("blossom")] -struct Blossom(sqlx::SqlitePool); +use std::borrow::Cow; -async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result { - match Blossom::fetch(&rocket) { - Some(db) => match sqlx::migrate!().run(&**db).await { - Ok(_) => Ok(rocket), - Err(e) => { - error!("failed to init blossom database: {}", e); - Err(rocket) - } - }, - None => Err(rocket), - } -} +use rocket::fs::{relative, FileServer}; +use rocket::http::Status; +use rocket::{Request, State}; +use rocket_dyn_templates::{context, Template}; -fn stage() -> AdHoc { - AdHoc::on_ignite("blossom database stage", |rocket| async { - rocket - .attach(Blossom::init()) - .attach(AdHoc::try_on_ignite("database migrations", run_migrations)) - }) -} +use error::BlossomError; + +type Result<T> = std::result::Result<T, BlossomError>; struct Clients { listenbrainz: listenbrainz::raw::Client, @@ -46,13 +23,20 @@ struct Clients { extern crate rocket; #[get("/")] -async fn home(clients: &State<Clients>) -> Result<Template, BlossomError> { +async fn home(clients: &State<Clients>) -> Result<Template> { + let (listenbrainz, skweets) = tokio::join!( + scrobbles::get_now_playing(&clients.listenbrainz), + skweets::get_recents(&clients.skinnyverse) + ); + let listenbrainz = listenbrainz.unwrap_or_default(); + let skweets = skweets.unwrap_or_default(); Ok(Template::render( "home", context! { is_live: false, - listenbrainz: scrobbles::get_now_playing(&clients.listenbrainz).await.unwrap_or_default(), - skweets: skweets::get_recents(&clients.skinnyverse).await.unwrap_or_default() }, + listenbrainz, + skweets, + }, )) } @@ -62,7 +46,7 @@ async fn contact() -> Template { } #[get("/plants")] -async fn plants() -> Result<Template, BlossomError> { +async fn plants() -> Result<Template> { Err(BlossomError::Unimplemented(Status::NotImplemented)) } @@ -86,12 +70,11 @@ fn catcher(status: Status, req: &Request) -> Template { } #[tokio::main] -async fn main() -> Result<(), rocket::Error> { +async fn main() -> std::result::Result<(), rocket::Error> { let mut skinny_data = mastodon_async::Data::default(); skinny_data.base = Cow::from("https://skinnyver.se"); let _rocket = rocket::build() - .attach(stage()) .manage(Clients { listenbrainz: listenbrainz::raw::Client::new(), skinnyverse: mastodon_async::Mastodon::from(skinny_data), @@ -107,6 +90,3 @@ async fn main() -> Result<(), rocket::Error> { Ok(()) } - -mod error; -use error::BlossomError; diff --git a/src/scrobbles.rs b/src/scrobbles.rs index a6d4a54..d4f6d31 100644 --- a/src/scrobbles.rs +++ b/src/scrobbles.rs @@ -1,11 +1,9 @@ use listenbrainz::raw::response::UserPlayingNowResponse; use serde::{Deserialize, Serialize}; -use crate::error::BlossomError; +use crate::Result; -pub async fn get_now_playing( - client: &listenbrainz::raw::Client, -) -> Result<NowPlayingData, BlossomError> { +pub async fn get_now_playing(client: &listenbrainz::raw::Client) -> Result<NowPlayingData> { let playingnow = client.user_playing_now("celblossom")?; Ok(NowPlayingData::new(playingnow)) } |