diff --git a/.gitignore b/.gitignore index ea8c4bf..06a9e2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/apb/target diff --git a/Cargo.toml b/Cargo.toml index 535b5a3..5f27c11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,6 @@ +[workspace] +members = ["apb"] + [package] name = "upub" version = "0.1.0" @@ -10,7 +13,7 @@ axum = "0.7.3" chrono = { version = "0.4.31", features = ["serde"] } clap = { version = "4.5.3", features = ["derive"] } paste = "1.0.14" -reqwest = { version = "0.11.26", features = ["json"] } +reqwest = { version = "0.12", features = ["json"] } sea-orm = { version = "0.12.14", features = ["macros", "sqlx-sqlite", "runtime-tokio-rustls"] } sea-orm-migration = "0.12.15" serde = { version = "1.0.193", features = ["derive"] } @@ -21,6 +24,7 @@ tracing = "0.1.40" tracing-subscriber = "0.3.18" uuid = { version = "1.8.0", features = ["v4"] } jrd = "0.1" +apb = { path = "apb", features = ["dict", "fetch", "orm"] } # nodeinfo = "0.0.2" # the version on crates.io doesn't re-export necessary types to build the struct!!! nodeinfo = { git = "https://codeberg.org/thefederationinfo/nodeinfo-rs", rev = "e865094804" } rand = "0.8.5" diff --git a/apb/Cargo.lock b/apb/Cargo.lock new file mode 100644 index 0000000..d4199b7 --- /dev/null +++ b/apb/Cargo.lock @@ -0,0 +1,2747 @@ +# 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 = "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 = "apb" +version = "0.1.0" +dependencies = [ + "chrono", + "paste", + "reqwest", + "sea-orm", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[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.53", +] + +[[package]] +name = "async-trait" +version = "0.1.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.53", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +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.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +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 = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "borsh" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0901fc8eb0aca4c83be0106d6f2db17d86a08dfc2c25f0e84464bf381158add6" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51670c3aa053938b0ee3bd67c3817e471e626151131b934038e83c5bf8de48f5" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.53", + "syn_derive", +] + +[[package]] +name = "bumpalo" +version = "3.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" + +[[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.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" + +[[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.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.52.4", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[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 = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +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.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[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 = "fastrand" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" + +[[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 = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[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-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 = "h2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[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 = "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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[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", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +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.53", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[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 = "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.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" + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[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 = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[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 = "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 = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.53", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[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.53", +] + +[[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 = "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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.53", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[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 = "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", +] + +[[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.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +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 = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "reqwest" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[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.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" +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.38.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[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.53", +] + +[[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-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.53", + "unicode-ident", +] + +[[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", + "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 = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "security-framework" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[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.53", +] + +[[package]] +name = "serde_json" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +dependencies = [ + "itoa", + "ryu", + "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 = "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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" +dependencies = [ + "ahash 0.8.11", + "atoi", + "bigdecimal", + "byteorder", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rust_decimal", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "time", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" +dependencies = [ + "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", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ed31390216d20e538e447a7a9b959e06ed9fc51c37b514b46eb758016ecd418" +dependencies = [ + "atoi", + "base64", + "bigdecimal", + "bitflags 2.5.0", + "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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e" +dependencies = [ + "atoi", + "base64", + "bigdecimal", + "bitflags 2.5.0", + "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", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b244ef0a8414da0bed4bb1910426e890b19e5e9bccc27ada6b797d05c55ae0aa" +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 = "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.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +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.53", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[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", + "rustix", + "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.53", +] + +[[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", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "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", + "tracing", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[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", +] + +[[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-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.53", +] + +[[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 = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[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 = "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 = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "serde", +] + +[[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 = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[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.53", + "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.53", + "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 = "whoami" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +dependencies = [ + "redox_syscall", + "wasite", +] + +[[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 = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[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.53", +] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/apb/Cargo.toml b/apb/Cargo.toml new file mode 100644 index 0000000..9c6b202 --- /dev/null +++ b/apb/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "apb" +version = "0.1.0" +edition = "2021" + +[lib] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +chrono = { version = "0.4", features = ["serde"] } +thiserror = "1.0" +serde_json = { version = "1.0", optional = true } +reqwest = { version = "0.12", features = ["json"], optional = true } +paste = "1.0.14" +sea-orm = { version = "0.12", optional = true } +tracing = "0.1.40" + +[features] +default = ["fetch", "dict", "orm"] +fetch = ["dep:reqwest"] +dict = ["dep:serde_json"] +orm = ["dep:sea-orm"] diff --git a/src/activitystream/README.md b/apb/src/README.md similarity index 100% rename from src/activitystream/README.md rename to apb/src/README.md diff --git a/apb/src/base.rs b/apb/src/base.rs new file mode 100644 index 0000000..5037003 --- /dev/null +++ b/apb/src/base.rs @@ -0,0 +1,41 @@ +use crate::{getter, setter, strenum, LinkType, ObjectType}; + +strenum! { + pub enum BaseType { + ; + Object(ObjectType), + Link(LinkType) + }; +} + +pub trait Base { + fn id(&self) -> Option<&str> { None } + fn base_type(&self) -> Option { None } +} + + +pub trait BaseMut { + fn set_id(self, val: Option<&str>) -> Self; + fn set_base_type(self, val: Option) -> Self; +} + + +impl Base for String { + fn id(&self) -> Option<&str> { + Some(self) + } + + fn base_type(&self) -> Option { + Some(BaseType::Link(LinkType::Link)) + } +} + +impl Base for serde_json::Value { + getter! { id -> &str } + getter! { base_type -> type BaseType } +} + +impl BaseMut for serde_json::Value { + setter! { id -> &str } + setter! { base_type -> type BaseType } +} diff --git a/src/activitystream/key.rs b/apb/src/key.rs similarity index 100% rename from src/activitystream/key.rs rename to apb/src/key.rs diff --git a/apb/src/lib.rs b/apb/src/lib.rs new file mode 100644 index 0000000..211c8c4 --- /dev/null +++ b/apb/src/lib.rs @@ -0,0 +1,36 @@ +mod macros; + +mod node; +pub use node::Node; + +mod link; +pub use link::{Link, LinkMut, LinkType}; + +pub mod key; +pub use key::{PublicKey, PublicKeyMut}; + +mod base; +pub use base::{Base, BaseMut, BaseType}; + +mod object; +pub use object::{ + Object, ObjectMut, ObjectType, + activity::{ + Activity, ActivityMut, ActivityType, + accept::{Accept, AcceptMut, AcceptType}, + ignore::{Ignore, IgnoreMut, IgnoreType}, + intransitive::{IntransitiveActivity, IntransitiveActivityMut, IntransitiveActivityType}, + offer::{Offer, OfferMut, OfferType}, + reject::{Reject, RejectMut, RejectType}, + }, + actor::{Actor, ActorMut, ActorType}, + collection::{ + Collection, CollectionMut, CollectionType, + page::{CollectionPage, CollectionPageMut} + }, + document::{Document, DocumentMut, DocumentType}, + place::{Place, PlaceMut}, + // profile::Profile, + relationship::{Relationship, RelationshipMut}, + tombstone::{Tombstone, TombstoneMut}, +}; diff --git a/src/activitystream/link.rs b/apb/src/link.rs similarity index 100% rename from src/activitystream/link.rs rename to apb/src/link.rs diff --git a/src/activitystream/macros.rs b/apb/src/macros.rs similarity index 85% rename from src/activitystream/macros.rs rename to apb/src/macros.rs index e0c800f..071a5b2 100644 --- a/src/activitystream/macros.rs +++ b/apb/src/macros.rs @@ -37,7 +37,7 @@ macro_rules! strenum { } impl TryFrom<&str> for $enum_name { - type Error = $crate::activitystream::macros::TypeValueError; + type Error = $crate::macros::TypeValueError; fn try_from(value:&str) -> Result { match value { @@ -48,7 +48,7 @@ macro_rules! strenum { return Ok(Self::$deep(x)); } )* - Err($crate::activitystream::macros::TypeValueError) + Err($crate::macros::TypeValueError) }, } } @@ -171,19 +171,19 @@ macro_rules! getter { }; ($name:ident -> node $t:ty) => { - fn $name(&self) -> $crate::activitystream::Node<$t> { + fn $name(&self) -> $crate::Node<$t> { match self.get(stringify!($name)) { - Some(x) => $crate::activitystream::Node::from(x.clone()), - None => $crate::activitystream::Node::Empty, + Some(x) => $crate::Node::from(x.clone()), + None => $crate::Node::Empty, } } }; ($name:ident::$rename:ident -> node $t:ty) => { - fn $name(&self) -> $crate::activitystream::Node<$t> { + fn $name(&self) -> $crate::Node<$t> { match self.get(stringify!($rename)) { - Some(x) => $crate::activitystream::Node::from(x.clone()), - None => $crate::activitystream::Node::Empty, + Some(x) => $crate::Node::from(x.clone()), + None => $crate::Node::Empty, } } }; @@ -194,7 +194,7 @@ macro_rules! setter { ($name:ident -> bool) => { paste::item! { fn [< set_$name >](mut self, val: Option) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, stringify!($name), val.map(|x| serde_json::Value::Bool(x)) ); self @@ -205,7 +205,7 @@ macro_rules! setter { ($name:ident -> &str) => { paste::item! { fn [< set_$name >](mut self, val: Option<&str>) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, stringify!($name), val.map(|x| serde_json::Value::String(x.to_string())) ); self @@ -216,7 +216,7 @@ macro_rules! setter { ($name:ident::$rename:ident -> &str) => { paste::item! { fn [< set_$name >](mut self, val: Option<&str>) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, stringify!($rename), val.map(|x| serde_json::Value::String(x.to_string())) ); self @@ -227,7 +227,7 @@ macro_rules! setter { ($name:ident -> u64) => { paste::item! { fn [< set_$name >](mut self, val: Option) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, stringify!($name), val.map(|x| serde_json::Value::Number(serde_json::Number::from(x))) ); self @@ -238,7 +238,7 @@ macro_rules! setter { ($name:ident::$rename:ident -> u64) => { paste::item! { fn [< set_$name >](mut self, val: Option) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, stringify!($rename), val.map(|x| serde_json::Value::Number(serde_json::Number::from(x))) ); self @@ -249,7 +249,7 @@ macro_rules! setter { ($name:ident -> chrono::DateTime) => { paste::item! { fn [< set_$name >](mut self, val: Option>) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, stringify!($name), val.map(|x| serde_json::Value::String(x.to_rfc3339())) ); self @@ -260,7 +260,7 @@ macro_rules! setter { ($name:ident::$rename:ident -> chrono::DateTime) => { paste::item! { fn [< set_$name >](mut self, val: Option>) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, stringify!($rename), val.map(|x| serde_json::Value::String(x.to_rfc3339())) ); self @@ -270,8 +270,8 @@ macro_rules! setter { ($name:ident -> node $t:ty ) => { paste::item! { - fn [< set_$name >](mut self, val: $crate::activitystream::Node<$t>) -> Self { - $crate::activitystream::macros::set_maybe_node( + fn [< set_$name >](mut self, val: $crate::Node<$t>) -> Self { + $crate::macros::set_maybe_node( &mut self, stringify!($name), val ); self @@ -281,8 +281,8 @@ macro_rules! setter { ($name:ident::$rename:ident -> node $t:ty ) => { paste::item! { - fn [< set_$name >](mut self, val: $crate::activitystream::Node<$t>) -> Self { - $crate::activitystream::macros::set_maybe_node( + fn [< set_$name >](mut self, val: $crate::Node<$t>) -> Self { + $crate::macros::set_maybe_node( &mut self, stringify!($rename), val ); self @@ -293,7 +293,7 @@ macro_rules! setter { ($name:ident -> type $t:ty ) => { paste::item! { fn [< set_$name >](mut self, val: Option<$t>) -> Self { - $crate::activitystream::macros::set_maybe_value( + $crate::macros::set_maybe_value( &mut self, "type", val.map(|x| serde_json::Value::String(x.as_ref().to_string())) ); self @@ -302,11 +302,11 @@ macro_rules! setter { }; } -pub fn set_maybe_node(obj: &mut serde_json::Value, key: &str, node: super::Node) { +pub fn set_maybe_node(obj: &mut serde_json::Value, key: &str, node: super::Node) { match node { super::Node::Object(x) => { set_maybe_value( - obj, key, Some(x.underlying_json_object()), + obj, key, Some(*x), ); }, super::Node::Link(l) => { @@ -316,7 +316,7 @@ pub fn set_maybe_node(obj: &mut serde_json::Value, key: &str, n }, super::Node::Array(_) => { set_maybe_value( - obj, key, Some(serde_json::Value::Array(node.flat())), + obj, key, Some(serde_json::Value::Array(node.into_iter().collect())), ); }, super::Node::Empty => { @@ -357,7 +357,7 @@ impl InsertValue for serde_json::Map { Node::Array(ref _arr) => { self.insert( k.to_string(), - serde_json::Value::Array(node.flat()), + serde_json::Value::Array(node.into_iter().collect()), ); }, Node::Link(l) => { diff --git a/apb/src/node.rs b/apb/src/node.rs new file mode 100644 index 0000000..7fd59a0 --- /dev/null +++ b/apb/src/node.rs @@ -0,0 +1,167 @@ +pub enum Node { + Array(Vec), // TODO would be cool to make it Box<[T]> so that Node is just a ptr + Object(Box), + Link(Box), + Empty, +} + +impl From> for Node { + fn from(value: Option) -> Self { + match value { + Some(x) => Node::Object(Box::new(x)), + None => Node::Empty, + } + } +} + +impl Iterator for Node { + type Item = T; + + fn next(&mut self) -> Option { + let x = match self { + Self::Empty => return None, + Self::Link(_) => return None, + Self::Array(arr) => return arr.pop(), // TODO weird that we iter in reverse + Self::Object(x) => *x.clone(), // TODO needed because next() on object can't get value without owning + }; + *self = Self::Empty; + Some(x) + } +} + +impl Node { + pub fn get(&self) -> Option<&T> { + match self { + Node::Empty | Node::Link(_) => None, + Node::Object(x) => Some(x), + Node::Array(v) => v.last(), // TODO so it's coherent with next(), still weird tho! + } + } + + pub fn extract(self) -> Option { + match self { + Node::Empty | Node::Link(_) => None, + Node::Object(x) => Some(*x), + Node::Array(mut v) => v.pop(), // TODO so it's coherent with next(), still weird tho! + } + } + + pub fn is_empty(&self) -> bool { + matches!(self, Node::Empty) + } + + pub fn is_link(&self) -> bool { + matches!(self, Node::Link(_)) + } + + pub fn is_object(&self) -> bool { + matches!(self, Node::Object(_)) + } + + pub fn is_array(&self) -> bool { + matches!(self, Node::Array(_)) + } + + pub fn len(&self) -> usize { + match self { + Node::Empty => 0, + Node::Link(_) => 1, + Node::Object(_) => 1, + Node::Array(v) => v.len(), + } + } + + pub fn id(&self) -> Option { + match self { + Node::Empty | Node::Array(_) => None, + Node::Link(uri) => Some(uri.href().to_string()), + Node::Object(obj) => obj.id().map(|x| x.to_string()), + } + } +} + +#[cfg(feature = "dict")] +impl Node { + pub fn link(uri: String) -> Self { + Node::Link(Box::new(uri)) + } + + pub fn links(uris: Vec) -> Self { + Node::Array( + uris + .into_iter() + .map(serde_json::Value::String) + .collect() + ) + } + + pub fn maybe_link(uri: Option) -> Self { + match uri { + Some(uri) => Node::Link(Box::new(uri)), + None => Node::Empty, + } + } + + pub fn object(x: serde_json::Value) -> Self { + Node::Object(Box::new(x)) + } + + pub fn maybe_object(x: Option) -> Self { + match x { + Some(x) => Node::Object(Box::new(x)), + None => Node::Empty, + } + } + + pub fn array(values: Vec) -> Self { + Node::Array(values) + } + + #[cfg(feature = "fetch")] + pub async fn fetch(&mut self) -> reqwest::Result<&mut Self> { + if let Node::Link(link) = self { + *self = reqwest::Client::new() + .get(link.href()) + .header("Accept", "application/json") + .send() + .await? + .json::() + .await? + .into(); + } + Ok(self) + } +} + +#[cfg(feature = "dict")] +impl From> for Node { + fn from(value: Option<&str>) -> Self { + match value { + Some(x) => Node::Link(Box::new(x.to_string())), + None => Node::Empty, + } + } +} + +#[cfg(feature = "dict")] +impl From<&str> for Node { + fn from(value: &str) -> Self { + Node::Link(Box::new(value.to_string())) + } +} + +#[cfg(feature = "dict")] +impl From for Node { + fn from(value: serde_json::Value) -> Self { + match value { + serde_json::Value::String(uri) => Node::Link(Box::new(uri)), + serde_json::Value::Array(arr) => Node::Array(arr), + serde_json::Value::Object(_) => match value.get("href") { + None => Node::Object(Box::new(value)), + Some(_) => Node::Link(Box::new(value)), + }, + _ => Node::Empty, + } + } +} + diff --git a/src/activitystream/object/activity/accept.rs b/apb/src/object/activity/accept.rs similarity index 100% rename from src/activitystream/object/activity/accept.rs rename to apb/src/object/activity/accept.rs diff --git a/src/activitystream/object/activity/ignore.rs b/apb/src/object/activity/ignore.rs similarity index 100% rename from src/activitystream/object/activity/ignore.rs rename to apb/src/object/activity/ignore.rs diff --git a/src/activitystream/object/activity/intransitive.rs b/apb/src/object/activity/intransitive.rs similarity index 100% rename from src/activitystream/object/activity/intransitive.rs rename to apb/src/object/activity/intransitive.rs diff --git a/apb/src/object/activity/mod.rs b/apb/src/object/activity/mod.rs new file mode 100644 index 0000000..d0a7b60 --- /dev/null +++ b/apb/src/object/activity/mod.rs @@ -0,0 +1,81 @@ +pub mod accept; +pub mod ignore; +pub mod intransitive; +pub mod offer; +pub mod reject; + +use crate::{Node, object::{Object, ObjectMut}, getter, setter, strenum}; +use accept::AcceptType; +use reject::RejectType; +use offer::OfferType; +use intransitive::IntransitiveActivityType; +use ignore::IgnoreType; + +strenum! { + pub enum ActivityType { + Activity, + Add, + Announce, + Create, + Delete, + Dislike, + Flag, + Follow, + Join, + Leave, + Like, + Listen, + Move, + Read, + Remove, + Undo, + Update, + View; + + IntransitiveActivity(IntransitiveActivityType), + Accept(AcceptType), + Ignore(IgnoreType), + Offer(OfferType), + Reject(RejectType) + }; +} + +pub trait Activity : Object { + fn activity_type(&self) -> Option { None } + fn actor(&self) -> Node { Node::Empty } + fn object(&self) -> Node { Node::Empty } + fn target(&self) -> Node { Node::Empty } + fn result(&self) -> Node { Node::Empty } + fn origin(&self) -> Node { Node::Empty } + fn instrument(&self) -> Node { Node::Empty } +} + +pub trait ActivityMut : ObjectMut { + fn set_activity_type(self, val: Option) -> Self; + fn set_actor(self, val: Node) -> Self; + fn set_object(self, val: Node) -> Self; + fn set_target(self, val: Node) -> Self; + fn set_result(self, val: Node) -> Self; + fn set_origin(self, val: Node) -> Self; + fn set_instrument(self, val: Node) -> Self; +} + +impl Activity for serde_json::Value { + getter! { activity_type -> type ActivityType } + getter! { actor -> node Self::Actor } + getter! { object -> node ::Object } + getter! { target -> node ::Object } + getter! { result -> node ::Object } + getter! { origin -> node ::Object } + getter! { instrument -> node ::Object } +} + +impl ActivityMut for serde_json::Value { + setter! { activity_type -> type ActivityType } + setter! { actor -> node Self::Actor } + setter! { object -> node ::Object } + setter! { target -> node ::Object } + setter! { result -> node ::Object } + setter! { origin -> node ::Object } + setter! { instrument -> node ::Object } +} diff --git a/src/activitystream/object/activity/offer.rs b/apb/src/object/activity/offer.rs similarity index 100% rename from src/activitystream/object/activity/offer.rs rename to apb/src/object/activity/offer.rs diff --git a/src/activitystream/object/activity/reject.rs b/apb/src/object/activity/reject.rs similarity index 100% rename from src/activitystream/object/activity/reject.rs rename to apb/src/object/activity/reject.rs diff --git a/apb/src/object/actor.rs b/apb/src/object/actor.rs new file mode 100644 index 0000000..4077aa5 --- /dev/null +++ b/apb/src/object/actor.rs @@ -0,0 +1,84 @@ +use crate::{Node, getter, setter, strenum}; + +use super::{Object, ObjectMut, super::key::PublicKey}; + +strenum! { + pub enum ActorType { + Application, + Group, + Organization, + Person; + }; +} + +pub trait Actor : Object { + type PublicKey : PublicKey; + + fn actor_type(&self) -> Option { None } + fn preferred_username(&self) -> Option<&str> { None } + fn inbox(&self) -> Node; + fn outbox(&self) -> Node; + fn following(&self) -> Node { todo!() } + fn followers(&self) -> Node { todo!() } + fn liked(&self) -> Node { todo!() } + fn streams(&self) -> Node { todo!() } + fn endpoints(&self) -> Option> { None } + fn public_key(&self) -> Node { todo!() } + // idk about this? everyone has it but AP doesn't mention it + fn discoverable(&self) -> Option { None } +} + +pub trait ActorMut : ObjectMut { + type PublicKey : PublicKey; + + fn set_actor_type(self, val: Option) -> Self; + fn set_preferred_username(self, val: Option<&str>) -> Self; + fn set_inbox(self, val: Node) -> Self; + fn set_outbox(self, val: Node) -> Self; + fn set_following(self, val: Node) -> Self; + fn set_followers(self, val: Node) -> Self; + fn set_liked(self, val: Node) -> Self; + fn set_streams(self, val: Node) -> Self; + fn set_endpoints(self, val: Option>) -> Self; + fn set_public_key(self, val: Node) -> Self; + fn set_discoverable(self, val: Option) -> Self; +} + +impl Actor for serde_json::Value { + type PublicKey = serde_json::Value; + + getter! { actor_type -> type ActorType } + getter! { preferred_username::preferredUsername -> &str } + getter! { inbox -> node Self::Collection } + getter! { outbox -> node Self::Collection } + getter! { following -> node Self::Collection } + getter! { followers -> node Self::Collection } + getter! { liked -> node Self::Collection } + getter! { streams -> node Self::Collection } + getter! { public_key::publicKey -> node Self::PublicKey } + getter! { discoverable -> bool } + + fn endpoints(&self) -> Option> { + todo!() + } +} + +impl ActorMut for serde_json::Value { + type PublicKey = serde_json::Value; + + setter! { actor_type -> type ActorType } + setter! { preferred_username::preferredUsername -> &str } + setter! { inbox -> node Self::Collection } + setter! { outbox -> node Self::Collection } + setter! { following -> node Self::Collection } + setter! { followers -> node Self::Collection } + setter! { liked -> node Self::Collection } + setter! { streams -> node Self::Collection } + setter! { public_key::publicKey -> node Self::PublicKey } + setter! { discoverable -> bool } + + fn set_endpoints(mut self, _val: Option>) -> Self { + self.as_object_mut().unwrap().insert("endpoints".to_string(), serde_json::Value::Object(serde_json::Map::default())); + self + } +} diff --git a/apb/src/object/collection/mod.rs b/apb/src/object/collection/mod.rs new file mode 100644 index 0000000..877bf5c --- /dev/null +++ b/apb/src/object/collection/mod.rs @@ -0,0 +1,62 @@ +pub mod page; +pub use page::CollectionPage; + +use crate::{Node, Object, object::ObjectMut, getter, setter, strenum}; + +strenum! { + pub enum CollectionType { + Collection, + CollectionPage, + OrderedCollection, + OrderedCollectionPage; + }; +} + +pub trait Collection : Object { + type CollectionPage : CollectionPage; + + fn collection_type(&self) -> Option { None } + + fn total_items(&self) -> Option { None } + fn current(&self) -> Node { Node::Empty } + fn first(&self) -> Node { Node::Empty } + fn last(&self) -> Node { Node::Empty } + fn items(&self) -> Node { Node::Empty } + fn ordered_items(&self) -> Node { Node::Empty } +} + +pub trait CollectionMut : ObjectMut { + type CollectionPage : CollectionPage; + + fn set_collection_type(self, val: Option) -> Self; + fn set_total_items(self, val: Option) -> Self; + fn set_current(self, val: Node) -> Self; + fn set_first(self, val: Node) -> Self; + fn set_last(self, val: Node) -> Self; + fn set_items(self, val: Node) -> Self; + fn set_ordered_items(self, val: Node) -> Self; +} + +impl Collection for serde_json::Value { + type CollectionPage = serde_json::Value; + + getter! { collection_type -> type CollectionType } + getter! { total_items::totalItems -> u64 } + getter! { current -> node Self::CollectionPage } + getter! { first -> node Self::CollectionPage } + getter! { last -> node Self::CollectionPage } + getter! { items -> node ::Object } + getter! { ordered_items::orderedItems -> node ::Object } +} + +impl CollectionMut for serde_json::Value { + type CollectionPage = serde_json::Value; + + setter! { collection_type -> type CollectionType } + setter! { total_items::totalItems -> u64 } + setter! { current -> node Self::CollectionPage } + setter! { first -> node Self::CollectionPage } + setter! { last -> node Self::CollectionPage } + setter! { items -> node ::Object } + setter! { ordered_items::orderedItems -> node ::Object } +} diff --git a/apb/src/object/collection/page.rs b/apb/src/object/collection/page.rs new file mode 100644 index 0000000..ad581e1 --- /dev/null +++ b/apb/src/object/collection/page.rs @@ -0,0 +1,25 @@ +use crate::{Node, getter, setter}; + +pub trait CollectionPage : super::Collection { + fn part_of(&self) -> Node { Node::Empty } + fn next(&self) -> Node { Node::Empty } + fn prev(&self) -> Node { Node::Empty } +} + +pub trait CollectionPageMut : super::CollectionMut { + fn set_part_of(self, val: Node) -> Self; + fn set_next(self, val: Node) -> Self; + fn set_prev(self, val: Node) -> Self; +} + +impl CollectionPage for serde_json::Value { + getter! { part_of::partOf -> node Self::Collection } + getter! { next -> node Self::CollectionPage } + getter! { prev -> node Self::CollectionPage } +} + +impl CollectionPageMut for serde_json::Value { + setter! { part_of::partOf -> node Self::Collection } + setter! { next -> node Self::CollectionPage } + setter! { prev -> node Self::CollectionPage } +} diff --git a/src/activitystream/object/document.rs b/apb/src/object/document.rs similarity index 88% rename from src/activitystream/object/document.rs rename to apb/src/object/document.rs index 69c9c5e..7878847 100644 --- a/src/activitystream/object/document.rs +++ b/apb/src/object/document.rs @@ -26,8 +26,3 @@ impl Document for serde_json::Value { impl DocumentMut for serde_json::Value { setter! { document_type -> type DocumentType } } - - - -pub trait Image : Document {} -impl Image for serde_json::Value {} diff --git a/apb/src/object/mod.rs b/apb/src/object/mod.rs new file mode 100644 index 0000000..90b7145 --- /dev/null +++ b/apb/src/object/mod.rs @@ -0,0 +1,202 @@ +pub mod activity; +pub mod actor; +pub mod collection; +pub mod document; +pub mod tombstone; +pub mod place; +pub mod profile; +pub mod relationship; + +use crate::{getter, setter, strenum}; + +use super::{Base, BaseMut, Link, Node}; + +use actor::{Actor, ActorType}; +use document::{Document, DocumentType}; +use activity::ActivityType; +use collection::{Collection, CollectionType}; + +strenum! { + pub enum ObjectType { + Object, + Article, + Event, + Note, + Place, + Profile, + Relationship, + Tombstone; + + Activity(ActivityType), + Actor(ActorType), + Collection(CollectionType), + Document(DocumentType) + }; +} + +pub trait Object : Base { + type Link : Link; + type Actor : Actor; + type Object : Object; + type Collection : Collection; + type Document : Document; + + fn object_type(&self) -> Option { None } + fn attachment(&self) -> Node { Node::Empty } + fn attributed_to(&self) -> Node { Node::Empty } + fn audience(&self) -> Node { Node::Empty } + fn content(&self) -> Option<&str> { None } // TODO handle language maps + fn context(&self) -> Node { Node::Empty } + fn name(&self) -> Option<&str> { None } // also in link // TODO handle language maps + fn end_time(&self) -> Option> { None } + fn generator(&self) -> Node { Node::Empty } + fn icon(&self) -> Node { Node::Empty } + fn image(&self) -> Node { Node::Empty } + fn in_reply_to(&self) -> Node { Node::Empty } + fn location(&self) -> Node { Node::Empty } + fn preview(&self) -> Node { Node::Empty } // also in link + fn published(&self) -> Option> { None } + fn replies(&self) -> Node { Node::Empty } + fn start_time(&self) -> Option> { None } + fn summary(&self) -> Option<&str> { None } + fn tag(&self) -> Node { Node::Empty } + fn updated(&self) -> Option> { None } + fn url(&self) -> Node { Node::Empty } + fn to(&self) -> Node { Node::Empty } + fn bto(&self) -> Node { Node::Empty } + fn cc(&self) -> Node { Node::Empty } + fn bcc(&self) -> Node { Node::Empty } + fn media_type(&self) -> Option<&str> { None } // also in link + fn duration(&self) -> Option<&str> { None } // TODO how to parse xsd:duration ? +} + +pub trait ObjectMut : BaseMut { + type Link : Link; + type Actor : Actor; + type Object : Object; + type Collection : Collection; + type Document : Document; + + fn set_object_type(self, val: Option) -> Self; + fn set_attachment(self, val: Node) -> Self; + fn set_attributed_to(self, val: Node) -> Self; + fn set_audience(self, val: Node) -> Self; + fn set_content(self, val: Option<&str>) -> Self; // TODO handle language maps + fn set_context(self, val: Node) -> Self; + fn set_name(self, val: Option<&str>) -> Self; // also in link // TODO handle language maps + fn set_end_time(self, val: Option>) -> Self; + fn set_generator(self, val: Node) -> Self; + fn set_icon(self, val: Node) -> Self; + fn set_image(self, val: Node) -> Self; + fn set_in_reply_to(self, val: Node) -> Self; + fn set_location(self, val: Node) -> Self; + fn set_preview(self, val: Node) -> Self; // also in link + fn set_published(self, val: Option>) -> Self; + fn set_replies(self, val: Node) -> Self; + fn set_start_time(self, val: Option>) -> Self; + fn set_summary(self, val: Option<&str>) -> Self; + fn set_tag(self, val: Node) -> Self; + fn set_updated(self, val: Option>) -> Self; + fn set_url(self, val: Node) -> Self; + fn set_to(self, val: Node) -> Self; + fn set_bto(self, val: Node) -> Self; + fn set_cc(self, val: Node) -> Self; + fn set_bcc(self, val: Node) -> Self; + fn set_media_type(self, val: Option<&str>) -> Self; // also in link + fn set_duration(self, val: Option<&str>) -> Self; // TODO how to parse xsd:duration ? +} + +impl Object for serde_json::Value { + type Link = serde_json::Value; + type Actor = serde_json::Value; + type Object = serde_json::Value; + type Document = serde_json::Value; + type Collection = serde_json::Value; + + getter! { object_type -> type ObjectType } + getter! { attachment -> node ::Object } + getter! { attributed_to::attributedTo -> node Self::Actor } + getter! { audience -> node Self::Actor } + getter! { content -> &str } + getter! { name -> &str } + getter! { end_time::endTime -> chrono::DateTime } + getter! { generator -> node Self::Actor } + getter! { icon -> node Self::Document } + getter! { image -> node Self::Document } + getter! { in_reply_to::inReplyTo -> node ::Object } + getter! { location -> node ::Object } + getter! { preview -> node ::Object } + getter! { published -> chrono::DateTime } + getter! { replies -> node Self::Collection } + getter! { start_time::startTime -> chrono::DateTime } + getter! { summary -> &str } + getter! { tag -> node ::Object } + getter! { updated -> chrono::DateTime } + getter! { to -> node Self::Link } + getter! { bto -> node Self::Link } + getter! { cc -> node Self::Link } + getter! { bcc -> node Self::Link } + getter! { media_type -> &str } + getter! { duration -> &str } + getter! { url -> node Self::Link } + + // TODO Mastodon doesn't use a "context" field on the object but makes up a new one!! + fn context(&self) -> Node<::Object> { + match self.get("context") { + Some(x) => Node::from(x.clone()), + None => match self.get("conversation") { + Some(x) => Node::from(x.clone()), + None => Node::Empty, + } + } + } +} + +impl ObjectMut for serde_json::Value { + type Link = serde_json::Value; + type Actor = serde_json::Value; + type Object = serde_json::Value; + type Document = serde_json::Value; + type Collection = serde_json::Value; + + setter! { object_type -> type ObjectType } + setter! { attachment -> node ::Object } + setter! { attributed_to::attributedTo -> node Self::Actor } + setter! { audience -> node Self::Actor } + setter! { content -> &str } + setter! { name -> &str } + setter! { end_time::endTime -> chrono::DateTime } + setter! { generator -> node Self::Actor } + setter! { icon -> node Self::Document } + setter! { image -> node Self::Document } + setter! { in_reply_to::inReplyTo -> node ::Object } + setter! { location -> node ::Object } + setter! { preview -> node ::Object } + setter! { published -> chrono::DateTime } + setter! { replies -> node Self::Collection } + setter! { start_time::startTime -> chrono::DateTime } + setter! { summary -> &str } + setter! { tag -> node ::Object } + setter! { updated -> chrono::DateTime } + setter! { to -> node Self::Link } + setter! { bto -> node Self::Link} + setter! { cc -> node Self::Link } + setter! { bcc -> node Self::Link } + setter! { media_type -> &str } + setter! { duration -> &str } + setter! { url -> node Self::Link } + + // TODO Mastodon doesn't use a "context" field on the object but makes up a new one!! + fn set_context(mut self, ctx: Node<::Object>) -> Self { + if let Some(conversation) = ctx.id() { + crate::macros::set_maybe_value( + &mut self, "conversation", Some(serde_json::Value::String(conversation)), + ); + } + crate::macros::set_maybe_node( + &mut self, "context", ctx + ); + self + } + +} diff --git a/src/activitystream/object/place.rs b/apb/src/object/place.rs similarity index 100% rename from src/activitystream/object/place.rs rename to apb/src/object/place.rs diff --git a/src/activitystream/object/profile.rs b/apb/src/object/profile.rs similarity index 100% rename from src/activitystream/object/profile.rs rename to apb/src/object/profile.rs diff --git a/src/activitystream/object/relationship.rs b/apb/src/object/relationship.rs similarity index 55% rename from src/activitystream/object/relationship.rs rename to apb/src/object/relationship.rs index a9e1247..eba5d14 100644 --- a/src/activitystream/object/relationship.rs +++ b/apb/src/object/relationship.rs @@ -1,17 +1,17 @@ -use crate::activitystream::Node; +use crate::Node; pub trait Relationship : super::Object { - fn subject(&self) -> Node { Node::Empty:: } + fn subject(&self) -> Node { Node::Empty } fn relationship(&self) -> Option<&str> { None } // TODO what does this mean??? // TODO was just object but clashes with Activity - fn relationship_object(&self) -> Node { Node::Empty:: } + fn relationship_object(&self) -> Node { Node::Empty } } pub trait RelationshipMut : super::ObjectMut { - fn set_subject(self, val: Node) -> Self; + fn set_subject(self, val: Node) -> Self; fn set_relationship(self, val: Option<&str>) -> Self; // TODO what does this mean??? // TODO was just object but clashes with Activity - fn set_relationship_object(self, val: Node) -> Self; + fn set_relationship_object(self, val: Node) -> Self; } impl Relationship for serde_json::Value { diff --git a/src/activitystream/object/tombstone.rs b/apb/src/object/tombstone.rs similarity index 67% rename from src/activitystream/object/tombstone.rs rename to apb/src/object/tombstone.rs index 7216c21..fa38ddf 100644 --- a/src/activitystream/object/tombstone.rs +++ b/apb/src/object/tombstone.rs @@ -1,10 +1,10 @@ pub trait Tombstone : super::Object { - fn former_type(&self) -> Option { None } + fn former_type(&self) -> Option { None } fn deleted(&self) -> Option> { None } } pub trait TombstoneMut : super::ObjectMut { - fn set_former_type(self, val: Option) -> Self; + fn set_former_type(self, val: Option) -> Self; fn set_deleted(self, val: Option>) -> Self; } diff --git a/src/activitypub/activity.rs b/src/activitypub/activity.rs index e71ab53..ac5667d 100644 --- a/src/activitypub/activity.rs +++ b/src/activitypub/activity.rs @@ -1,6 +1,7 @@ use axum::{extract::{Path, State}, http::StatusCode}; use sea_orm::EntityTrait; -use crate::{activitystream::{object::{activity::ActivityMut, ObjectMut}, BaseMut, Node}, model::{self, activity, object}, server::Context}; +use crate::{model::{self, activity, object}, server::Context}; +use apb::{ActivityMut, ObjectMut, BaseMut, Node}; use super::{jsonld::LD, JsonLD}; @@ -13,9 +14,9 @@ pub fn ap_activity(activity: model::activity::Model) -> serde_json::Value { .set_target(Node::maybe_link(activity.target)) .set_published(Some(activity.published)) .set_to(Node::links(activity.to.0.clone())) - .set_bto(Node::empty()) + .set_bto(Node::Empty) .set_cc(Node::links(activity.cc.0.clone())) - .set_bcc(Node::empty()) + .set_bcc(Node::Empty) } pub async fn view(State(ctx) : State, Path(id): Path) -> Result, StatusCode> { diff --git a/src/activitypub/inbox.rs b/src/activitypub/inbox.rs index fe2f037..514df3d 100644 --- a/src/activitypub/inbox.rs +++ b/src/activitypub/inbox.rs @@ -1,7 +1,7 @@ use axum::{extract::{Query, State}, http::StatusCode}; use sea_orm::{ColumnTrait, Condition, EntityTrait, Order, QueryFilter, QueryOrder, QuerySelect}; -use crate::{activitystream::Node, auth::{AuthIdentity, Identity}, errors::UpubError, model, server::Context, url}; +use crate::{auth::{AuthIdentity, Identity}, errors::UpubError, model, server::Context, url}; use super::{activity::ap_activity, jsonld::LD, JsonLD, Pagination, PUBLIC_TARGET}; @@ -39,8 +39,8 @@ pub async fn page( offset, limit, activities .into_iter() - .filter_map(|(_, a)| Some(Node::object(ap_activity(a?)))) - .collect::>>() + .filter_map(|(_, a)| Some(ap_activity(a?))) + .collect::>() ).ld_context() )) } diff --git a/src/activitypub/mod.rs b/src/activitypub/mod.rs index 2e85fb1..f63fdf5 100644 --- a/src/activitypub/mod.rs +++ b/src/activitypub/mod.rs @@ -12,10 +12,25 @@ use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; use rand::Rng; use sea_orm::{ColumnTrait, Condition, EntityTrait, QueryFilter}; -use crate::{activitystream::{key::PublicKeyMut, object::{actor::{ActorMut, ActorType}, ObjectMut}, BaseMut, Node}, model, server::Context, url}; +use apb::{PublicKeyMut, ActorMut, ActorType, Link, Object, ObjectMut, BaseMut, Node}; +use crate::{model, server::Context, url}; use self::jsonld::LD; +pub trait Addressed : Object { + fn addressed(&self) -> Vec; +} + +impl Addressed for serde_json::Value { + fn addressed(&self) -> Vec { + let mut to : Vec = self.to().map(|x| x.href().to_string()).collect(); + to.append(&mut self.bto().map(|x| x.href().to_string()).collect()); + to.append(&mut self.cc().map(|x| x.href().to_string()).collect()); + to.append(&mut self.bcc().map(|x| x.href().to_string()).collect()); + to + } +} + pub const PUBLIC_TARGET : &str = "https://www.w3.org/ns/activitystreams#Public"; pub fn split_id(id: &str) -> (String, String) { diff --git a/src/activitypub/object.rs b/src/activitypub/object.rs index af771ac..40d7cbd 100644 --- a/src/activitypub/object.rs +++ b/src/activitypub/object.rs @@ -1,7 +1,8 @@ use axum::{extract::{Path, State}, http::StatusCode}; use sea_orm::EntityTrait; -use crate::{activitystream::{object::ObjectMut, BaseMut, Node}, model::{self, object}, server::Context}; +use apb::{ObjectMut, BaseMut, Node}; +use crate::{model::{self, object}, server::Context}; use super::{jsonld::LD, JsonLD}; @@ -16,9 +17,9 @@ pub fn ap_object(object: model::object::Model) -> serde_json::Value { .set_context(Node::maybe_link(object.context.clone())) .set_published(Some(object.published)) .set_to(Node::links(object.to.0.clone())) - .set_bto(Node::empty()) + .set_bto(Node::Empty) .set_cc(Node::links(object.cc.0.clone())) - .set_bcc(Node::empty()) + .set_bcc(Node::Empty) } pub async fn view(State(ctx) : State, Path(id): Path) -> Result, StatusCode> { diff --git a/src/activitypub/user/following.rs b/src/activitypub/user/following.rs index 35d6b6e..4f0d760 100644 --- a/src/activitypub/user/following.rs +++ b/src/activitypub/user/following.rs @@ -1,7 +1,7 @@ use axum::{extract::{Path, Query, State}, http::StatusCode}; use sea_orm::{ColumnTrait, Condition, EntityTrait, PaginatorTrait, QueryFilter, QuerySelect, SelectColumns}; -use crate::{activitypub::{jsonld::LD, JsonLD, Pagination}, activitystream::Node, model, server::Context, url}; +use crate::{activitypub::{jsonld::LD, JsonLD, Pagination}, model, server::Context, url}; use model::relation::Column::{Following, Follower}; @@ -51,7 +51,7 @@ pub async fn page( &url!(ctx, "/users/{id}/{follow___}"), offset, limit, - following.into_iter().map(Node::link).collect() + following.into_iter().map(serde_json::Value::String).collect() ).ld_context() )) }, diff --git a/src/activitypub/user/inbox.rs b/src/activitypub/user/inbox.rs index 7358253..6ef7a04 100644 --- a/src/activitypub/user/inbox.rs +++ b/src/activitypub/user/inbox.rs @@ -1,7 +1,8 @@ use axum::{extract::{Path, Query, State}, http::StatusCode, Json}; use sea_orm::{sea_query::Expr, ColumnTrait, Condition, EntityTrait, IntoActiveModel, Order, QueryFilter, QueryOrder, QuerySelect, Set}; -use crate::{activitypub::{activity::ap_activity, jsonld::LD, JsonLD, Pagination}, activitystream::{object::{activity::{Activity, ActivityType}, Addressed, Object, ObjectType}, Base, BaseType, Node}, auth::{AuthIdentity, Identity}, errors::{LoggableError, UpubError}, model, server::Context, url}; +use apb::{Activity, ActivityType, Object, ObjectType, Base, BaseType}; +use crate::{activitypub::{activity::ap_activity, jsonld::LD, Addressed, JsonLD, Pagination}, auth::{AuthIdentity, Identity}, errors::{LoggableError, UpubError}, model, server::Context, url}; pub async fn get( State(ctx): State, @@ -48,8 +49,8 @@ pub async fn page( offset, limit, activities .into_iter() - .filter_map(|(_, a)| Some(Node::object(ap_activity(a?)))) - .collect::>>() + .filter_map(|(_, a)| Some(ap_activity(a?))) + .collect::>() ).ld_context() )) }, @@ -84,7 +85,7 @@ pub async fn post( Some(BaseType::Object(ObjectType::Activity(ActivityType::Delete))) => { // TODO verify the signature before just deleting lmao - let oid = object.object().id().ok_or(StatusCode::BAD_REQUEST)?.to_string(); + let oid = object.object().id().ok_or(StatusCode::BAD_REQUEST)?; // TODO maybe we should keep the tombstone? model::user::Entity::delete_by_id(&oid).exec(ctx.db()).await.info_failed("failed deleting from users"); model::activity::Entity::delete_by_id(&oid).exec(ctx.db()).await.info_failed("failed deleting from activities"); @@ -152,8 +153,8 @@ pub async fn post( }, Some(BaseType::Object(ObjectType::Activity(ActivityType::Like))) => { - let aid = object.actor().id().ok_or(StatusCode::BAD_REQUEST)?.to_string(); - let oid = object.object().id().ok_or(StatusCode::BAD_REQUEST)?.to_string(); + let aid = object.actor().id().ok_or(StatusCode::BAD_REQUEST)?; + let oid = object.object().id().ok_or(StatusCode::BAD_REQUEST)?; let like = model::like::ActiveModel { id: sea_orm::ActiveValue::NotSet, actor: sea_orm::Set(aid.clone()), @@ -182,7 +183,7 @@ pub async fn post( Some(BaseType::Object(ObjectType::Activity(ActivityType::Create))) => { let activity_model = model::activity::Model::new(&object)?; let activity_targets = object.addressed(); - let Some(object_node) = object.object().get() else { + let Some(object_node) = object.object().extract() else { // TODO we could process non-embedded activities or arrays but im lazy rn tracing::error!("refusing to process activity without embedded object: {}", serde_json::to_string_pretty(&object).unwrap()); return Err(StatusCode::UNPROCESSABLE_ENTITY.into()); @@ -200,7 +201,7 @@ pub async fn post( Some(BaseType::Object(ObjectType::Activity(ActivityType::Update))) => { let activity_model = model::activity::Model::new(&object)?; let activity_targets = object.addressed(); - let Some(object_node) = object.object().get() else { + let Some(object_node) = object.object().extract() else { // TODO we could process non-embedded activities or arrays but im lazy rn tracing::error!("refusing to process activity without embedded object: {}", serde_json::to_string_pretty(&object).unwrap()); return Err(StatusCode::UNPROCESSABLE_ENTITY.into()); @@ -214,7 +215,7 @@ pub async fn post( Some(ObjectType::Actor(_)) => { // TODO oof here is an example of the weakness of this model, we have to go all the way // back up to serde_json::Value because impl Object != impl Actor - let actor_model = model::user::Model::new(&object_node.underlying_json_object())?; + let actor_model = model::user::Model::new(&object_node)?; model::user::Entity::update(actor_model.into_active_model()) .exec(ctx.db()).await?; }, diff --git a/src/activitypub/user/mod.rs b/src/activitypub/user/mod.rs index 5a5bad4..94238ba 100644 --- a/src/activitypub/user/mod.rs +++ b/src/activitypub/user/mod.rs @@ -7,7 +7,8 @@ pub mod following; use axum::{extract::{Path, State}, http::StatusCode}; use sea_orm::EntityTrait; -use crate::{activitystream::{key::PublicKeyMut, object::{actor::ActorMut, document::{DocumentMut, DocumentType}, ObjectMut}, BaseMut, Node}, model::{self, user}, server::Context, url}; +use apb::{PublicKeyMut, ActorMut, DocumentMut, DocumentType, ObjectMut, BaseMut, Node}; +use crate::{model::{self, user}, server::Context, url}; use super::{jsonld::LD, JsonLD}; diff --git a/src/activitypub/user/outbox.rs b/src/activitypub/user/outbox.rs index 0796718..e28fccc 100644 --- a/src/activitypub/user/outbox.rs +++ b/src/activitypub/user/outbox.rs @@ -1,7 +1,8 @@ use axum::{extract::{Path, Query, State}, http::StatusCode, Json}; use sea_orm::{EntityTrait, IntoActiveModel, Order, QueryOrder, QuerySelect, Set}; -use crate::{activitypub::{jsonld::LD, CreationResult, JsonLD, Pagination}, activitystream::{object::{activity::{accept::AcceptType, Activity, ActivityMut, ActivityType}, Addressed, ObjectMut}, Base, BaseMut, BaseType, Node, ObjectType}, auth::{AuthIdentity, Identity}, errors::UpubError, model, server::Context, url}; +use apb::{AcceptType, Activity, ActivityMut, ActivityType, ObjectMut, Base, BaseMut, BaseType, Node, ObjectType}; +use crate::{activitypub::{jsonld::LD, Addressed, CreationResult, JsonLD, Pagination}, auth::{AuthIdentity, Identity}, errors::UpubError, model, server::Context, url}; pub async fn get( State(ctx): State, @@ -49,13 +50,11 @@ pub async fn page( .into_iter() .map(|(a, o)| { let oid = a.object.clone(); - Node::object( - super::super::activity::ap_activity(a) - .set_object(match o { - Some(o) => Node::object(super::super::object::ap_object(o)), - None => Node::maybe_link(oid), - }) - ) + super::super::activity::ap_activity(a) + .set_object(match o { + Some(o) => Node::object(super::super::object::ap_object(o)), + None => Node::maybe_link(oid), + }) }) .collect() ).ld_context() @@ -114,7 +113,7 @@ pub async fn post( }, Some(BaseType::Object(ObjectType::Activity(ActivityType::Create))) => { - let Some(object) = activity.object().get().map(|x| x.underlying_json_object()) else { + let Some(object) = activity.object().extract() else { return Err(StatusCode::BAD_REQUEST.into()); }; let oid = ctx.oid(uuid::Uuid::new_v4().to_string()); @@ -152,7 +151,7 @@ pub async fn post( Some(BaseType::Object(ObjectType::Activity(ActivityType::Like))) => { let aid = ctx.aid(uuid::Uuid::new_v4().to_string()); let activity_targets = activity.addressed(); - let Some(oid) = activity.object().id().map(|x| x.to_string()) else { + let Some(oid) = activity.object().id() else { return Err(StatusCode::BAD_REQUEST.into()); }; let activity_model = model::activity::Model::new( @@ -164,7 +163,7 @@ pub async fn post( let like_model = model::like::ActiveModel { actor: Set(uid.clone()), - likes: Set(oid.clone()), + likes: Set(oid), date: Set(chrono::Utc::now()), ..Default::default() }; diff --git a/src/activitystream/mod.rs b/src/activitystream/mod.rs deleted file mode 100644 index 6acebd5..0000000 --- a/src/activitystream/mod.rs +++ /dev/null @@ -1,68 +0,0 @@ -pub mod link; -pub use link::{Link, LinkType}; - -pub mod object; -pub use object::{Object, ObjectType}; - -pub mod node; -pub use node::Node; - -pub mod macros; -pub mod prelude; - -pub mod key; - -use crate::{getter, setter, strenum}; - -strenum! { - pub enum BaseType { - ; - Object(ObjectType), - Link(LinkType) - }; -} - -pub trait Base { - fn id(&self) -> Option<&str> { None } - fn base_type(&self) -> Option { None } - - // TODO this is a dirty fix because my trait model is flawed and leads to circular resolution - // errors, basically can't downcast back to serde_json::Value once i've updasted it to - // impl Object/Actor/whatever... ask me to infodump+bikeshed about this!!! :3 - fn underlying_json_object(self) -> serde_json::Value; -} - - -pub trait BaseMut { - fn set_id(self, val: Option<&str>) -> Self; - fn set_base_type(self, val: Option) -> Self; -} - - -impl Base for String { - fn id(&self) -> Option<&str> { - Some(self) - } - - fn base_type(&self) -> Option { - Some(BaseType::Link(LinkType::Link)) - } - - fn underlying_json_object(self) -> serde_json::Value { - serde_json::Value::String(self) - } -} - -impl Base for serde_json::Value { - fn underlying_json_object(self) -> serde_json::Value { - self - } - - getter! { id -> &str } - getter! { base_type -> type BaseType } -} - -impl BaseMut for serde_json::Value { - setter! { id -> &str } - setter! { base_type -> type BaseType } -} diff --git a/src/activitystream/node.rs b/src/activitystream/node.rs deleted file mode 100644 index 79b87e3..0000000 --- a/src/activitystream/node.rs +++ /dev/null @@ -1,192 +0,0 @@ -pub enum Node { - Array(Vec>), // TODO would be cool to make it Box<[Node]> so that Node is just a ptr - Object(Box), - Link(Box), - Empty, -} - -impl From> for Node { - fn from(value: Option) -> Self { - match value { - Some(x) => Node::Object(Box::new(x)), - None => Node::Empty, - } - } -} - -impl Node { - pub fn get(self) -> Option { - match self { - Node::Empty | Node::Link(_) => None, - Node::Object(x) => Some(*x), - Node::Array(v) => v.into_iter().find_map(|x| match x { - Node::Object(x) => Some(*x), - _ => None, - }), - } - } - - // TODO extremely unforgiving, is this even useful? - pub fn get_items(&self) -> Option> { - match self { - Node::Empty | Node::Link(_) => None, - Node::Object(x) => Some(vec![x]), - Node::Array(v) => - Some(v.iter().filter_map(|x| match x { - Node::Object(x) => Some(&**x), - _ => None, - }).collect()), - } - } - - pub fn get_links(&self) -> Vec { - match self { - Node::Empty => vec![], - Node::Link(x) => vec![x.href().to_string()], - Node::Object(x) => match x.id() { - Some(x) => vec![x.to_string()], - None => vec![], - }, - Node::Array(v) => - v.iter().filter_map(|x| match x { - Node::Link(x) => Some(x.href().to_string()), - Node::Object(x) => x.id().map(|x| x.to_string()), - // TODO handle array of arrays maybe? - _ => None, - }).collect(), - } - } - - pub fn is_empty(&self) -> bool { - match self { - Node::Empty | Node::Link(_) => true, - Node::Object(_) | Node::Array(_) => false, - } - } - - pub fn len(&self) -> usize { - match self { - Node::Empty => 0, - Node::Link(_) => 0, - Node::Object(_) => 1, - Node::Array(v) => v.len(), - } - } - - pub fn flat(self) -> Vec { - match self { - Node::Empty => vec![], - Node::Link(l) => vec![serde_json::Value::String(l.href().to_string())], - Node::Object(x) => vec![x.underlying_json_object()], - Node::Array(arr) => { - arr - .into_iter() - .filter_map(|node| match node { - Node::Empty => None, - Node::Link(l) => Some(serde_json::Value::String(l.href().to_string())), - Node::Object(o) => Some(o.underlying_json_object()), - Node::Array(_) => Some(serde_json::Value::Array(node.flat())), - }).collect() - } - } - } - - pub fn id(&self) -> Option { - match self { - Node::Empty => None, - Node::Link(uri) => Some(uri.href().to_string()), - Node::Object(obj) => obj.id().map(|x| x.to_string()), - Node::Array(arr) => arr.first()?.id().map(|x| x.to_string()), - } - } -} - -impl Node{ - pub fn empty() -> Self { - Node::Empty - } - - pub fn link(uri: String) -> Self { - Node::Link(Box::new(uri)) - } - - pub fn links(uris: Vec) -> Self { - Node::Array( - uris - .into_iter() - .map(Node::link) - .collect() - ) - } - - pub fn maybe_link(uri: Option) -> Self { - match uri { - Some(uri) => Node::Link(Box::new(uri)), - None => Node::Empty, - } - } - - pub fn object(x: impl super::Base) -> Self { - Node::Object(Box::new(x.underlying_json_object())) - } - - pub fn maybe_object(x: Option) -> Self { - match x { - Some(x) => Node::Object(Box::new(x.underlying_json_object())), - None => Node::Empty, - } - } - - pub fn array(x: Vec) -> Self { - Node::Array(x.into_iter().map(|x| Node::object(x.underlying_json_object())).collect()) - } - - pub async fn fetch(&mut self) -> reqwest::Result<()> { - if let Node::Link(link) = self { - *self = reqwest::Client::new() - .get(link.href()) - .header("Accept", "application/json") - .send() - .await? - .json::() - .await? - .into(); - } - Ok(()) - } -} - -impl From> for Node { - fn from(value: Option<&str>) -> Self { - match value { - Some(x) => Node::Link(Box::new(x.to_string())), - None => Node::Empty, - } - } -} - -impl From<&str> for Node { - fn from(value: &str) -> Self { - Node::Link(Box::new(value.to_string())) - } -} - -impl From for Node { - fn from(value: serde_json::Value) -> Self { - match value { - serde_json::Value::String(uri) => Node::Link(Box::new(uri)), - serde_json::Value::Object(_) => match value.get("href") { - None => Node::Object(Box::new(value)), - Some(_) => Node::Link(Box::new(value)), - }, - serde_json::Value::Array(arr) => Node::Array( - arr - .into_iter() - .map(Self::from) - .collect() - ), - _ => Node::Empty, - } - } -} - diff --git a/src/activitystream/object/activity/mod.rs b/src/activitystream/object/activity/mod.rs deleted file mode 100644 index 13cee8c..0000000 --- a/src/activitystream/object/activity/mod.rs +++ /dev/null @@ -1,82 +0,0 @@ -pub mod accept; -pub mod ignore; -pub mod intransitive; -pub mod offer; -pub mod reject; - -use crate::activitystream::Node; -use crate::{getter, setter, strenum}; -use accept::AcceptType; -use reject::RejectType; -use offer::OfferType; -use intransitive::IntransitiveActivityType; -use ignore::IgnoreType; - -strenum! { - pub enum ActivityType { - Activity, - Add, - Announce, - Create, - Delete, - Dislike, - Flag, - Follow, - Join, - Leave, - Like, - Listen, - Move, - Read, - Remove, - Undo, - Update, - View; - - IntransitiveActivity(IntransitiveActivityType), - Accept(AcceptType), - Ignore(IgnoreType), - Offer(OfferType), - Reject(RejectType) - }; -} - -pub trait Activity : super::Object { - fn activity_type(&self) -> Option { None } - fn actor(&self) -> Node { Node::Empty:: } - fn object(&self) -> Node { Node::Empty:: } - fn target(&self) -> Node { Node::Empty:: } - fn result(&self) -> Node { Node::Empty:: } - fn origin(&self) -> Node { Node::Empty:: } - fn instrument(&self) -> Node { Node::Empty:: } -} - -pub trait ActivityMut : super::ObjectMut { - fn set_activity_type(self, val: Option) -> Self; - fn set_actor(self, val: Node) -> Self; - fn set_object(self, val: Node) -> Self; - fn set_target(self, val: Node) -> Self; - fn set_result(self, val: Node) -> Self; - fn set_origin(self, val: Node) -> Self; - fn set_instrument(self, val: Node) -> Self; -} - -impl Activity for serde_json::Value { - getter! { activity_type -> type ActivityType } - getter! { actor -> node impl super::Actor } - getter! { object -> node impl super::Object } - getter! { target -> node impl super::Object } - getter! { result -> node impl super::Object } - getter! { origin -> node impl super::Object } - getter! { instrument -> node impl super::Object } -} - -impl ActivityMut for serde_json::Value { - setter! { activity_type -> type ActivityType } - setter! { actor -> node impl super::Actor } - setter! { object -> node impl super::Object } - setter! { target -> node impl super::Object } - setter! { result -> node impl super::Object } - setter! { origin -> node impl super::Object } - setter! { instrument -> node impl super::Object } -} diff --git a/src/activitystream/object/actor.rs b/src/activitystream/object/actor.rs deleted file mode 100644 index 1fc9c54..0000000 --- a/src/activitystream/object/actor.rs +++ /dev/null @@ -1,77 +0,0 @@ -use crate::{activitystream::Node, getter, setter, strenum}; - -use super::collection::Collection; -use super::super::key::PublicKey; - -strenum! { - pub enum ActorType { - Application, - Group, - Organization, - Person; - }; -} - -pub trait Actor : super::Object { - fn actor_type(&self) -> Option { None } - fn preferred_username(&self) -> Option<&str> { None } - fn inbox(&self) -> Node; - fn outbox(&self) -> Node; - fn following(&self) -> Node { Node::empty() } - fn followers(&self) -> Node { Node::empty() } - fn liked(&self) -> Node { Node::empty() } - fn streams(&self) -> Node { Node::empty() } - fn endpoints(&self) -> Option> { None } - fn public_key(&self) -> Node { Node::empty() } - // idk about this? everyone has it but AP doesn't mention it - fn discoverable(&self) -> Option { None } -} - -pub trait ActorMut : super::ObjectMut { - fn set_actor_type(self, val: Option) -> Self; - fn set_preferred_username(self, val: Option<&str>) -> Self; - fn set_inbox(self, val: Node) -> Self; - fn set_outbox(self, val: Node) -> Self; - fn set_following(self, val: Node) -> Self; - fn set_followers(self, val: Node) -> Self; - fn set_liked(self, val: Node) -> Self; - fn set_streams(self, val: Node) -> Self; - fn set_endpoints(self, val: Option>) -> Self; - fn set_public_key(self, val: Node) -> Self; - fn set_discoverable(self, val: Option) -> Self; -} - -impl Actor for serde_json::Value { - getter! { actor_type -> type ActorType } - getter! { preferred_username::preferredUsername -> &str } - getter! { inbox -> node impl Collection } - getter! { outbox -> node impl Collection } - getter! { following -> node impl Collection } - getter! { followers -> node impl Collection } - getter! { liked -> node impl Collection } - getter! { streams -> node impl Collection } - getter! { public_key::publicKey -> node impl PublicKey } - getter! { discoverable -> bool } - - fn endpoints(&self) -> Option> { - todo!() - } -} - -impl ActorMut for serde_json::Value { - setter! { actor_type -> type ActorType } - setter! { preferred_username::preferredUsername -> &str } - setter! { inbox -> node impl Collection } - setter! { outbox -> node impl Collection } - setter! { following -> node impl Collection } - setter! { followers -> node impl Collection } - setter! { liked -> node impl Collection } - setter! { streams -> node impl Collection } - setter! { public_key::publicKey -> node impl PublicKey } - setter! { discoverable -> bool } - - fn set_endpoints(mut self, _val: Option>) -> Self { - self.as_object_mut().unwrap().insert("endpoints".to_string(), serde_json::Value::Object(serde_json::Map::default())); - self - } -} diff --git a/src/activitystream/object/collection/mod.rs b/src/activitystream/object/collection/mod.rs deleted file mode 100644 index 8be3595..0000000 --- a/src/activitystream/object/collection/mod.rs +++ /dev/null @@ -1,55 +0,0 @@ -pub mod page; -pub use page::CollectionPage; - -use crate::activitystream::Node; -use crate::{getter, setter, strenum}; - -strenum! { - pub enum CollectionType { - Collection, - CollectionPage, - OrderedCollection, - OrderedCollectionPage; - }; -} - -pub trait Collection : super::Object { - fn collection_type(&self) -> Option { None } - - fn total_items(&self) -> Option { None } - fn current(&self) -> Node { Node::Empty:: } - fn first(&self) -> Node { Node::Empty:: } - fn last(&self) -> Node { Node::Empty:: } - fn items(&self) -> Node { Node::Empty:: } - fn ordered_items(&self) -> Node { Node::Empty:: } -} - -pub trait CollectionMut : super::ObjectMut { - fn set_collection_type(self, val: Option) -> Self; - fn set_total_items(self, val: Option) -> Self; - fn set_current(self, val: Node) -> Self; - fn set_first(self, val: Node) -> Self; - fn set_last(self, val: Node) -> Self; - fn set_items(self, val: Node) -> Self; - fn set_ordered_items(self, val: Node) -> Self; -} - -impl Collection for serde_json::Value { - getter! { collection_type -> type CollectionType } - getter! { total_items::totalItems -> u64 } - getter! { current -> node impl CollectionPage } - getter! { first -> node impl CollectionPage } - getter! { last -> node impl CollectionPage } - getter! { items -> node impl super::Object } - getter! { ordered_items::orderedItems -> node impl super::Object } -} - -impl CollectionMut for serde_json::Value { - setter! { collection_type -> type CollectionType } - setter! { total_items::totalItems -> u64 } - setter! { current -> node impl CollectionPage } - setter! { first -> node impl CollectionPage } - setter! { last -> node impl CollectionPage } - setter! { items -> node impl super::Object } - setter! { ordered_items::orderedItems -> node impl super::Object } -} diff --git a/src/activitystream/object/collection/page.rs b/src/activitystream/object/collection/page.rs deleted file mode 100644 index 237d83f..0000000 --- a/src/activitystream/object/collection/page.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::{activitystream::Node, getter, setter}; - -pub trait CollectionPage : super::Collection { - fn part_of(&self) -> Node { Node::Empty:: } - fn next(&self) -> Node { Node::Empty:: } - fn prev(&self) -> Node { Node::Empty:: } -} - -pub trait CollectionPageMut : super::CollectionMut { - fn set_part_of(self, val: Node) -> Self; - fn set_next(self, val: Node) -> Self; - fn set_prev(self, val: Node) -> Self; -} - -impl CollectionPage for serde_json::Value { - getter! { part_of::partOf -> node impl super::Collection } - getter! { next -> node impl CollectionPage } - getter! { prev -> node impl CollectionPage } -} - -impl CollectionPageMut for serde_json::Value { - setter! { part_of::partOf -> node impl super::Collection } - setter! { next -> node impl CollectionPage } - setter! { prev -> node impl CollectionPage } -} diff --git a/src/activitystream/object/mod.rs b/src/activitystream/object/mod.rs deleted file mode 100644 index 0a11396..0000000 --- a/src/activitystream/object/mod.rs +++ /dev/null @@ -1,191 +0,0 @@ -pub mod activity; -pub mod actor; -pub mod collection; -pub mod document; -pub mod tombstone; -pub mod place; -pub mod profile; -pub mod relationship; - -use crate::{getter, setter, strenum}; - -use super::{Link, Node}; - -use actor::{Actor, ActorType}; -use document::{Image, DocumentType}; -use activity::ActivityType; -use collection::{Collection, CollectionType}; - -strenum! { - pub enum ObjectType { - Object, - Article, - Event, - Note, - Place, - Profile, - Relationship, - Tombstone; - - Activity(ActivityType), - Actor(ActorType), - Collection(CollectionType), - Document(DocumentType) - }; -} - -pub trait Object : super::Base { - fn object_type(&self) -> Option { None } - fn attachment(&self) -> Node { Node::Empty:: } - fn attributed_to(&self) -> Node { Node::Empty:: } - fn audience(&self) -> Node { Node::Empty:: } - fn content(&self) -> Option<&str> { None } // TODO handle language maps - fn context(&self) -> Node { Node::Empty:: } - fn name(&self) -> Option<&str> { None } // also in link // TODO handle language maps - fn end_time(&self) -> Option> { None } - fn generator(&self) -> Node { Node::Empty:: } - fn icon(&self) -> Node { Node::Empty:: } - fn image(&self) -> Node { Node::Empty:: } - fn in_reply_to(&self) -> Node { Node::Empty:: } - fn location(&self) -> Node { Node::Empty:: } - fn preview(&self) -> Node { Node::Empty:: } // also in link - fn published(&self) -> Option> { None } - fn replies(&self) -> Node { Node::Empty:: } - fn start_time(&self) -> Option> { None } - fn summary(&self) -> Option<&str> { None } - fn tag(&self) -> Node { Node::Empty:: } - fn updated(&self) -> Option> { None } - fn url(&self) -> Node { Node::empty() } - fn to(&self) -> Node { Node::Empty:: } - fn bto(&self) -> Node { Node::Empty:: } - fn cc(&self) -> Node { Node::Empty:: } - fn bcc(&self) -> Node { Node::Empty:: } - fn media_type(&self) -> Option<&str> { None } // also in link - fn duration(&self) -> Option<&str> { None } // TODO how to parse xsd:duration ? -} - -pub trait Addressed : Object { - fn addressed(&self) -> Vec { - let mut to = self.to().get_links(); - to.append(&mut self.bto().get_links()); - to.append(&mut self.cc().get_links()); - to.append(&mut self.bcc().get_links()); - to - } -} - -pub trait ObjectMut : super::BaseMut { - fn set_object_type(self, val: Option) -> Self; - fn set_attachment(self, val: Node) -> Self; - fn set_attributed_to(self, val: Node) -> Self; - fn set_audience(self, val: Node) -> Self; - fn set_content(self, val: Option<&str>) -> Self; // TODO handle language maps - fn set_context(self, val: Node) -> Self; - fn set_name(self, val: Option<&str>) -> Self; // also in link // TODO handle language maps - fn set_end_time(self, val: Option>) -> Self; - fn set_generator(self, val: Node) -> Self; - fn set_icon(self, val: Node) -> Self; - fn set_image(self, val: Node) -> Self; - fn set_in_reply_to(self, val: Node) -> Self; - fn set_location(self, val: Node) -> Self; - fn set_preview(self, val: Node) -> Self; // also in link - fn set_published(self, val: Option>) -> Self; - fn set_replies(self, val: Node) -> Self; - fn set_start_time(self, val: Option>) -> Self; - fn set_summary(self, val: Option<&str>) -> Self; - fn set_tag(self, val: Node) -> Self; - fn set_updated(self, val: Option>) -> Self; - fn set_url(self, val: Node) -> Self; - fn set_to(self, val: Node) -> Self; - fn set_bto(self, val: Node) -> Self; - fn set_cc(self, val: Node) -> Self; - fn set_bcc(self, val: Node) -> Self; - fn set_media_type(self, val: Option<&str>) -> Self; // also in link - fn set_duration(self, val: Option<&str>) -> Self; // TODO how to parse xsd:duration ? -} - -impl Object for serde_json::Value { - - getter! { object_type -> type ObjectType } - getter! { attachment -> node impl Object } - getter! { attributed_to::attributedTo -> node impl Actor } - getter! { audience -> node impl Actor } - getter! { content -> &str } - getter! { name -> &str } - getter! { end_time::endTime -> chrono::DateTime } - getter! { generator -> node impl Actor } - getter! { icon -> node impl Image } - getter! { image -> node impl Image } - getter! { in_reply_to::inReplyTo -> node impl Object } - getter! { location -> node impl Object } - getter! { preview -> node impl Object } - getter! { published -> chrono::DateTime } - getter! { replies -> node impl Collection } - getter! { start_time::startTime -> chrono::DateTime } - getter! { summary -> &str } - getter! { tag -> node impl Object } - getter! { updated -> chrono::DateTime } - getter! { to -> node impl Link } - getter! { bto -> node impl Link } - getter! { cc -> node impl Link } - getter! { bcc -> node impl Link } - getter! { media_type -> &str } - getter! { duration -> &str } - getter! { url -> node impl super::Link } - - // TODO Mastodon doesn't use a "context" field on the object but makes up a new one!! - fn context(&self) -> Node { - match self.get("context") { - Some(x) => Node::from(x.clone()), - None => match self.get("conversation") { - Some(x) => Node::from(x.clone()), - None => Node::empty(), - } - } - } -} - -impl Addressed for serde_json::Value {} - -impl ObjectMut for serde_json::Value { - setter! { object_type -> type ObjectType } - setter! { attachment -> node impl Object } - setter! { attributed_to::attributedTo -> node impl Actor } - setter! { audience -> node impl Actor } - setter! { content -> &str } - setter! { name -> &str } - setter! { end_time::endTime -> chrono::DateTime } - setter! { generator -> node impl Actor } - setter! { icon -> node impl Image } - setter! { image -> node impl Image } - setter! { in_reply_to::inReplyTo -> node impl Object } - setter! { location -> node impl Object } - setter! { preview -> node impl Object } - setter! { published -> chrono::DateTime } - setter! { replies -> node impl Collection } - setter! { start_time::startTime -> chrono::DateTime } - setter! { summary -> &str } - setter! { tag -> node impl Object } - setter! { updated -> chrono::DateTime } - setter! { to -> node impl Link } - setter! { bto -> node impl Link} - setter! { cc -> node impl Link } - setter! { bcc -> node impl Link } - setter! { media_type -> &str } - setter! { duration -> &str } - setter! { url -> node impl super::Link } - - // TODO Mastodon doesn't use a "context" field on the object but makes up a new one!! - fn set_context(mut self, ctx: Node) -> Self { - if let Some(conversation) = ctx.id() { - crate::activitystream::macros::set_maybe_value( - &mut self, "conversation", Some(serde_json::Value::String(conversation.to_string())), - ); - } - crate::activitystream::macros::set_maybe_node( - &mut self, "context", ctx - ); - self - } - -} diff --git a/src/activitystream/prelude.rs b/src/activitystream/prelude.rs deleted file mode 100644 index e6d8d24..0000000 --- a/src/activitystream/prelude.rs +++ /dev/null @@ -1,28 +0,0 @@ -pub use super::{ - Base as _, BaseMut as _, - key::{PublicKey as _, PublicKeyMut as _}, - link::{Link as _, LinkMut as _}, - object::{ - Object as _, ObjectMut as _, - tombstone::{Tombstone as _, TombstoneMut as _}, - relationship::{Relationship as _, RelationshipMut as _}, - profile::{Profile as _, /* ProfileMut as _ */}, // TODO! - place::{Place as _, PlaceMut as _}, - actor::{Actor as _, ActorMut as _}, - document::{ - Document as _, DocumentMut as _, Image as _, - }, - collection::{ - Collection as _, CollectionMut as _, - page::{CollectionPage as _, CollectionPageMut as _}, - }, - activity::{ - Activity as _, ActivityMut as _, - reject::{Reject as _, RejectMut as _}, - offer::{Offer as _, OfferMut as _}, - intransitive::{IntransitiveActivity as _, IntransitiveActivityMut as _}, - ignore::{Ignore as _, IgnoreMut as _}, - accept::{Accept as _, AcceptMut as _}, - }, - } -}; diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 7edca27..e3ada1d 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -4,7 +4,8 @@ use reqwest::header::{CONTENT_TYPE, USER_AGENT}; use sea_orm::{ColumnTrait, Condition, DatabaseConnection, EntityTrait, Order, QueryFilter, QueryOrder}; use tokio::{sync::broadcast, task::JoinHandle}; -use crate::{activitypub::{activity::ap_activity, object::ap_object}, activitystream::{object::activity::ActivityMut, Node}, errors::UpubError, model, server::Context, VERSION}; +use apb::{ActivityMut, Node}; +use crate::{activitypub::{activity::ap_activity, object::ap_object}, errors::UpubError, model, server::Context, VERSION}; pub struct Dispatcher { waker: broadcast::Sender<()>, diff --git a/src/main.rs b/src/main.rs index eb4db15..0902257 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -pub mod activitystream; pub mod activitypub; mod model; @@ -16,8 +15,6 @@ use sea_orm_migration::MigratorTrait; pub use errors::UpubResult as Result; -use crate::activitystream::{BaseType, ObjectType}; - pub const VERSION: &str = env!("CARGO_PKG_VERSION"); #[derive(Parser)] @@ -102,9 +99,9 @@ async fn main() { async fn fetch(db: &sea_orm::DatabaseConnection, uri: &str, save: bool) -> reqwest::Result<()> { - use crate::activitystream::{Base, Object}; + use apb::{Base, Object}; - let mut node = activitystream::Node::from(uri); + let mut node = apb::Node::from(uri); tracing::info!("fetching object"); node.fetch().await?; tracing::info!("fetched node"); @@ -115,23 +112,23 @@ async fn fetch(db: &sea_orm::DatabaseConnection, uri: &str, save: bool) -> reqwe if save { match obj.base_type() { - Some(BaseType::Object(ObjectType::Actor(_))) => { + Some(apb::BaseType::Object(apb::ObjectType::Actor(_))) => { model::user::Entity::insert( - model::user::Model::new(&obj).unwrap().into_active_model() + model::user::Model::new(obj).unwrap().into_active_model() ).exec(db).await.unwrap(); }, - Some(BaseType::Object(ObjectType::Activity(_))) => { + Some(apb::BaseType::Object(apb::ObjectType::Activity(_))) => { model::activity::Entity::insert( - model::activity::Model::new(&obj).unwrap().into_active_model() + model::activity::Model::new(obj).unwrap().into_active_model() ).exec(db).await.unwrap(); }, - Some(BaseType::Object(ObjectType::Note)) => { + Some(apb::BaseType::Object(apb::ObjectType::Note)) => { model::object::Entity::insert( - model::object::Model::new(&obj).unwrap().into_active_model() + model::object::Model::new(obj).unwrap().into_active_model() ).exec(db).await.unwrap(); }, - Some(BaseType::Object(t)) => tracing::warn!("not implemented: {:?}", t), - Some(BaseType::Link(_)) => tracing::error!("fetched another link?"), + Some(apb::BaseType::Object(t)) => tracing::warn!("not implemented: {:?}", t), + Some(apb::BaseType::Link(_)) => tracing::error!("fetched another link?"), None => tracing::error!("no type on object"), } } diff --git a/src/model/activity.rs b/src/model/activity.rs index cd778b1..421336e 100644 --- a/src/model/activity.rs +++ b/src/model/activity.rs @@ -1,7 +1,5 @@ use sea_orm::entity::prelude::*; -use crate::activitystream::object::activity::{Activity, ActivityType}; - use super::Audience; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] @@ -10,7 +8,7 @@ pub struct Model { #[sea_orm(primary_key)] pub id: String, - pub activity_type: ActivityType, + pub activity_type: apb::ActivityType, pub actor: String, pub object: Option, @@ -25,13 +23,13 @@ pub struct Model { } impl Model { - pub fn new(activity: &impl Activity) -> Result { + pub fn new(activity: &impl apb::Activity) -> Result { Ok(Model { id: activity.id().ok_or(super::FieldError("id"))?.to_string(), activity_type: activity.activity_type().ok_or(super::FieldError("type"))?, - actor: activity.actor().id().ok_or(super::FieldError("actor"))?.to_string(), - object: activity.object().id().map(|x| x.to_string()), - target: activity.target().id().map(|x| x.to_string()), + actor: activity.actor().id().ok_or(super::FieldError("actor"))?, + object: activity.object().id(), + target: activity.target().id(), published: activity.published().unwrap_or(chrono::Utc::now()), to: activity.to().into(), bto: activity.bto().into(), diff --git a/src/model/faker.rs b/src/model/faker.rs index a63456e..587b73b 100644 --- a/src/model/faker.rs +++ b/src/model/faker.rs @@ -22,7 +22,7 @@ pub async fn faker(db: &sea_orm::DatabaseConnection, domain: String, count: u64) inbox: None, shared_inbox: None, outbox: None, - actor_type: crate::activitystream::object::actor::ActorType::Person, + actor_type: apb::ActorType::Person, created: chrono::Utc::now(), updated: chrono::Utc::now(), private_key: Some(std::str::from_utf8(&key.private_key_to_pem().unwrap()).unwrap().to_string()), @@ -55,7 +55,7 @@ pub async fn faker(db: &sea_orm::DatabaseConnection, domain: String, count: u64) object::Entity::insert(object::ActiveModel { id: Set(format!("{domain}/objects/{oid}")), name: Set(None), - object_type: Set(crate::activitystream::object::ObjectType::Note), + object_type: Set(apb::ObjectType::Note), attributed_to: Set(Some(format!("{domain}/users/test"))), summary: Set(None), context: Set(Some(context.clone())), @@ -72,7 +72,7 @@ pub async fn faker(db: &sea_orm::DatabaseConnection, domain: String, count: u64) activity::Entity::insert(activity::ActiveModel { id: Set(format!("{domain}/activities/{aid}")), - activity_type: Set(crate::activitystream::object::activity::ActivityType::Create), + activity_type: Set(apb::ActivityType::Create), actor: Set(format!("{domain}/users/test")), object: Set(Some(format!("{domain}/objects/{oid}"))), target: Set(None), diff --git a/src/model/mod.rs b/src/model/mod.rs index 7236d17..07bf37c 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -28,7 +28,7 @@ impl From for axum::http::StatusCode { #[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, sea_orm::FromJsonQueryResult)] pub struct Audience(pub Vec); -use crate::activitystream::{Link, Node}; +use apb::{Link, Node}; impl From> for Audience { fn from(value: Node) -> Self { Audience( diff --git a/src/model/object.rs b/src/model/object.rs index 4b14300..182dd93 100644 --- a/src/model/object.rs +++ b/src/model/object.rs @@ -1,7 +1,5 @@ use sea_orm::entity::prelude::*; -use crate::activitystream::object::ObjectType; - use super::Audience; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] @@ -9,7 +7,7 @@ use super::Audience; pub struct Model { #[sea_orm(primary_key)] pub id: String, - pub object_type: ObjectType, + pub object_type: apb::ObjectType, pub attributed_to: Option, pub name: Option, pub summary: Option, @@ -26,15 +24,15 @@ pub struct Model { } impl Model { - pub fn new(object: &impl crate::activitystream::object::Object) -> Result { + pub fn new(object: &impl apb::Object) -> Result { Ok(Model { id: object.id().ok_or(super::FieldError("id"))?.to_string(), object_type: object.object_type().ok_or(super::FieldError("type"))?, - attributed_to: object.attributed_to().id().map(|x| x.to_string()), + attributed_to: object.attributed_to().id(), name: object.name().map(|x| x.to_string()), summary: object.summary().map(|x| x.to_string()), content: object.content().map(|x| x.to_string()), - context: object.context().id().map(|x| x.to_string()), + context: object.context().id(), published: object.published().ok_or(super::FieldError("published"))?, comments: 0, likes: 0, diff --git a/src/model/relation.rs b/src/model/relation.rs index f2c34fa..41bcc27 100644 --- a/src/model/relation.rs +++ b/src/model/relation.rs @@ -11,5 +11,6 @@ pub struct Model { #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation {} +// TODO how to represent this User-to-User relation in sea orm?? impl ActiveModelBehavior for ActiveModel {} diff --git a/src/model/user.rs b/src/model/user.rs index 869762f..2859278 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -1,7 +1,7 @@ use sea_orm::entity::prelude::*; -use crate::activitystream::key::PublicKey as _; -use crate::{activitypub, activitystream::object::{collection::Collection, actor::{Actor, ActorType}}}; +use apb::{Collection, Actor, PublicKey, ActorType}; +use crate::activitypub; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "users")] @@ -46,13 +46,13 @@ impl Model { actor_type: object.actor_type().ok_or(super::FieldError("type"))?, name: object.name().map(|x| x.to_string()), summary: object.summary().map(|x| x.to_string()), - icon: object.icon().id().map(|x| x.to_string()), - image: object.image().id().map(|x| x.to_string()), - inbox: object.inbox().id().map(|x| x.to_string()), - outbox: object.inbox().id().map(|x| x.to_string()), + icon: object.icon().id(), + image: object.image().id(), + inbox: object.inbox().id(), + outbox: object.inbox().id(), shared_inbox: None, // TODO!!! parse endpoints - followers: object.followers().id().map(|x| x.to_string()), - following: object.following().id().map(|x| x.to_string()), + followers: object.followers().id(), + following: object.following().id(), created: object.published().unwrap_or(chrono::Utc::now()), updated: chrono::Utc::now(), following_count: object.following().get().map(|f| f.total_items().unwrap_or(0)).unwrap_or(0) as i64, diff --git a/src/server.rs b/src/server.rs index 89ee672..9c5b23b 100644 --- a/src/server.rs +++ b/src/server.rs @@ -3,7 +3,8 @@ use std::{str::Utf8Error, sync::Arc}; use openssl::rsa::Rsa; use sea_orm::{ColumnTrait, Condition, DatabaseConnection, DbErr, EntityTrait, QueryFilter, QuerySelect, SelectColumns, Set}; -use crate::{activitypub::{jsonld::LD, PUBLIC_TARGET}, activitystream::{object::collection::{page::CollectionPageMut, CollectionMut, CollectionType}, BaseMut, Node}, dispatcher::Dispatcher, fetcher::Fetcher, model}; +use crate::{activitypub::{jsonld::LD, PUBLIC_TARGET}, dispatcher::Dispatcher, fetcher::Fetcher, model}; +use apb::{CollectionPageMut, CollectionMut, CollectionType, BaseMut, Node}; #[derive(Clone)] pub struct Context(Arc); @@ -215,7 +216,7 @@ impl Context { .set_total_items(total_items) } - pub fn ap_collection_page(&self, id: &str, offset: u64, limit: u64, items: Vec>) -> serde_json::Value { + pub fn ap_collection_page(&self, id: &str, offset: u64, limit: u64, items: Vec) -> serde_json::Value { serde_json::Value::new_object() .set_id(Some(&format!("{id}?offset={offset}"))) .set_collection_type(Some(CollectionType::OrderedCollectionPage))