So people should now properly be read from the db

This commit is contained in:
mStar aka a person 2024-01-06 21:16:37 +00:00
parent 4d7a81dd25
commit f9509e7791
31 changed files with 952 additions and 213 deletions

407
Cargo.lock generated
View file

@ -4,13 +4,12 @@ version = 3
[[package]] [[package]]
name = "activitypub_federation" name = "activitypub_federation"
version = "0.4.7" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41a0b760e573d41d9f6aec4280e4c0d273d4ce724eb00c3e4c9fb1b98d3ede47" checksum = "8bac58c1d61b6e2358adbd043c78ba853428102b489acb7b6cb74ee6f2ae668f"
dependencies = [ dependencies = [
"activitystreams-kinds", "activitystreams-kinds",
"actix-web", "actix-web",
"anyhow",
"async-trait", "async-trait",
"axum 0.6.20", "axum 0.6.20",
"base64 0.21.5", "base64 0.21.5",
@ -19,13 +18,16 @@ dependencies = [
"derive_builder", "derive_builder",
"dyn-clone", "dyn-clone",
"enum_delegate", "enum_delegate",
"futures",
"futures-core", "futures-core",
"http 0.2.11", "http 0.2.11",
"http-body-util",
"http-signature-normalization", "http-signature-normalization",
"http-signature-normalization-reqwest", "http-signature-normalization-reqwest",
"httpdate", "httpdate",
"hyper 0.14.27", "hyper 0.14.27",
"itertools", "itertools",
"moka",
"once_cell", "once_cell",
"openssl", "openssl",
"pin-project-lite", "pin-project-lite",
@ -71,9 +73,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-http" name = "actix-http"
version = "3.4.0" version = "3.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92ef85799cba03f76e4f7c10f533e66d87c9a7e7055f3391f09000ad8351bc9" checksum = "129d4c88e98860e1758c5de288d1632b07970a16d59bdf7b8d66053d582bb71f"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-rt", "actix-rt",
@ -167,9 +169,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-web" name = "actix-web"
version = "4.4.0" version = "4.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4a5b5e29603ca8c94a77c65cf874718ceb60292c5a5c3e5f4ace041af462b9" checksum = "e43428f3bf11dee6d166b00ec2df4e3aa8cc1606aaa0b7433c146852e2f4e03b"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-http", "actix-http",
@ -309,14 +311,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9d19de80eff169429ac1e9f48fffb163916b448a44e8e046186232046d9e1f9" checksum = "c9d19de80eff169429ac1e9f48fffb163916b448a44e8e046186232046d9e1f9"
[[package]] [[package]]
name = "async-trait" name = "async-lock"
version = "0.1.75" version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b"
dependencies = [
"event-listener",
]
[[package]]
name = "async-trait"
version = "0.1.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -486,6 +497,12 @@ version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
[[package]]
name = "bytecount"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.5.0" version = "1.5.0"
@ -507,6 +524,37 @@ dependencies = [
"bytes", "bytes",
] ]
[[package]]
name = "camino"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
dependencies = [
"serde",
]
[[package]]
name = "cargo-platform"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d"
dependencies = [
"serde",
]
[[package]]
name = "cargo_metadata"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
dependencies = [
"camino",
"cargo-platform",
"semver",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.83" version = "1.0.83"
@ -567,7 +615,7 @@ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -613,6 +661,16 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "crossbeam-channel"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]] [[package]]
name = "crossbeam-deque" name = "crossbeam-deque"
version = "0.8.4" version = "0.8.4"
@ -750,10 +808,12 @@ checksum = "62c6fcf842f17f8c78ecf7c81d75c5ce84436b41ee07e03f490fbb5f5a8731d8"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"byteorder", "byteorder",
"chrono",
"diesel_derives", "diesel_derives",
"itoa", "itoa",
"libsqlite3-sys", "libsqlite3-sys",
"pq-sys", "pq-sys",
"r2d2",
"time", "time",
] ]
@ -766,7 +826,7 @@ dependencies = [
"diesel_table_macro_syntax", "diesel_table_macro_syntax",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -786,7 +846,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5"
dependencies = [ dependencies = [
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -866,6 +926,21 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "error-chain"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
dependencies = [
"version_check",
]
[[package]]
name = "event-listener"
version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "2.0.1" version = "2.0.1"
@ -903,55 +978,83 @@ dependencies = [
] ]
[[package]] [[package]]
name = "futures-channel" name = "futures"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"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 = [ dependencies = [
"futures-core", "futures-core",
"futures-sink",
] ]
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" 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]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]] [[package]]
name = "futures-macro" name = "futures-macro"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [ dependencies = [
"futures-channel",
"futures-core", "futures-core",
"futures-io", "futures-io",
"futures-macro", "futures-macro",
@ -990,6 +1093,12 @@ version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.3.22" version = "0.3.22"
@ -1137,10 +1246,11 @@ dependencies = [
[[package]] [[package]]
name = "http-signature-normalization-reqwest" name = "http-signature-normalization-reqwest"
version = "0.8.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c382c69a07b21accae86298d520579403af6479b1cd1c389e3ee11f01d48627" checksum = "10cfb84663420ec12c4422820bfdf5e8e5e57467892587f43ac432e73ebce880"
dependencies = [ dependencies = [
"async-trait",
"base64 0.13.1", "base64 0.13.1",
"http-signature-normalization", "http-signature-normalization",
"httpdate", "httpdate",
@ -1296,9 +1406,9 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.10.5" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0"
dependencies = [ dependencies = [
"either", "either",
] ]
@ -1363,6 +1473,7 @@ dependencies = [
"rand", "rand",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json",
"sysinfo", "sysinfo",
"tokio", "tokio",
"toml 0.8.8", "toml 0.8.8",
@ -1409,6 +1520,15 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "mach2"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "matchit" name = "matchit"
version = "0.7.3" version = "0.7.3"
@ -1479,6 +1599,30 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "moka"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f353abec74660d4b8533c2516c86eb062f1ec8ca49a2758f4f2b1b60b06b0c6e"
dependencies = [
"async-lock",
"async-trait",
"crossbeam-channel",
"crossbeam-epoch",
"crossbeam-utils",
"futures-util",
"once_cell",
"parking_lot",
"quanta",
"rustc_version",
"skeptic",
"smallvec",
"tagptr",
"thiserror",
"triomphe",
"uuid",
]
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.2.11" version = "0.2.11"
@ -1536,15 +1680,15 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.18.0" version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.60" version = "0.10.62"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"cfg-if", "cfg-if",
@ -1563,7 +1707,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -1574,9 +1718,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.96" version = "0.9.98"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -1636,7 +1780,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -1680,22 +1824,60 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.70" version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "pulldown-cmark"
version = "1.0.33" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
dependencies = [
"bitflags 1.3.2",
"memchr",
"unicase",
]
[[package]]
name = "quanta"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab"
dependencies = [
"crossbeam-utils",
"libc",
"mach2",
"once_cell",
"raw-cpuid",
"wasi",
"web-sys",
"winapi",
]
[[package]]
name = "quote"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "r2d2"
version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93"
dependencies = [
"log",
"parking_lot",
"scheduled-thread-pool",
]
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.5" version = "0.8.5"
@ -1726,6 +1908,15 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "raw-cpuid"
version = "10.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
dependencies = [
"bitflags 1.3.2",
]
[[package]] [[package]]
name = "rayon" name = "rayon"
version = "1.8.0" version = "1.8.0"
@ -1786,9 +1977,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.22" version = "0.11.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41"
dependencies = [ dependencies = [
"base64 0.21.5", "base64 0.21.5",
"bytes", "bytes",
@ -1880,6 +2071,15 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "schannel" name = "schannel"
version = "0.1.22" version = "0.1.22"
@ -1889,6 +2089,15 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "scheduled-thread-pool"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cbc66816425a074528352f5789333ecff06ca41b36b0b0efdfbb29edc391a19"
dependencies = [
"parking_lot",
]
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.2.0" version = "1.2.0"
@ -1923,32 +2132,35 @@ name = "semver"
version = "1.0.20" version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.193" version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.193" version = "1.0.195"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.108" version = "1.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"itoa", "itoa",
@ -2018,6 +2230,21 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "skeptic"
version = "0.13.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8"
dependencies = [
"bytecount",
"cargo_metadata",
"error-chain",
"glob",
"pulldown-cmark",
"tempfile",
"walkdir",
]
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.9" version = "0.4.9"
@ -2072,9 +2299,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.39" version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2123,6 +2350,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "tagptr"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
[[package]] [[package]]
name = "task-local-extensions" name = "task-local-extensions"
version = "0.1.4" version = "0.1.4"
@ -2147,22 +2380,22 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.50" version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.50" version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -2211,9 +2444,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.34.0" version = "1.35.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -2236,7 +2469,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -2370,7 +2603,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]
[[package]] [[package]]
@ -2382,6 +2615,12 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "triomphe"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3"
[[package]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.2.4" version = "0.2.4"
@ -2442,6 +2681,15 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "uuid"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
dependencies = [
"getrandom",
]
[[package]] [[package]]
name = "vcpkg" name = "vcpkg"
version = "0.2.15" version = "0.2.15"
@ -2454,6 +2702,16 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "walkdir"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
dependencies = [
"same-file",
"winapi-util",
]
[[package]] [[package]]
name = "want" name = "want"
version = "0.3.1" version = "0.3.1"
@ -2490,7 +2748,7 @@ dependencies = [
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -2524,7 +2782,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -2574,6 +2832,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@ -2776,5 +3043,5 @@ checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.48",
] ]

View file

@ -12,9 +12,9 @@ exclude = ["/.vscode", "/FeatureTargets.md"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
activitypub_federation = "0.4.7" activitypub_federation = "0.5.0"
axum = "0.7.1" axum = "0.7.1"
diesel = { version = "2.1.4", features = ["sqlite", "postgres"] } diesel = { version = "2.1.4", features = ["sqlite", "postgres", "r2d2", "chrono"] }
tokio = { version = "1.34.0", features = ["full"]} tokio = { version = "1.34.0", features = ["full"]}
build_html = "2.4.0" build_html = "2.4.0"
serde = "1.0.193" serde = "1.0.193"
@ -30,3 +30,4 @@ toml = "0.8.8"
serde_derive = "1.0.193" serde_derive = "1.0.193"
sysinfo = "0.30.3" sysinfo = "0.30.3"
diesel_migrations = "2.1.0" diesel_migrations = "2.1.0"
serde_json = "1.0.111"

View file

@ -1,3 +0,0 @@
#/bin/bash
touch db.sqlite
DATABASE_URL="db.sqlite";diesel --config-file diesel_devel.toml $@

View file

@ -2,8 +2,8 @@
# see https://diesel.rs/guides/configuring-diesel-cli # see https://diesel.rs/guides/configuring-diesel-cli
[print_schema] [print_schema]
file = "src/storage/diesel_db/postgres.rs" file = "src/storage/pg_schemas.rs"
custom_type_derives = ["diesel::query_builder::QueryId"] custom_type_derives = ["diesel::query_builder::QueryId"]
[migrations_directory] [migrations_directory]
dir = "migrations/postgres" dir = "migrations"

View file

@ -1,9 +0,0 @@
# For documentation on how to configure this file,
# see https://diesel.rs/guides/configuring-diesel-cli
[print_schema]
file = "src/storage/diesel_db/sqlite.rs"
custom_type_derives = ["diesel::query_builder::QueryId"]
[migrations_directory]
dir = "migrations/sqlite"

View file

@ -0,0 +1,13 @@
create table people (
ap_id text primary key,
name text not null,
instance text,
mail text,
pw_hash text,
inbox text not null,
public_key text not null,
private_key text,
last_refreshed_at timestamp not null,
local boolean not null,
followers text[] not null
)

View file

@ -1,2 +1 @@
-- This file should undo anything in `up.sql` -- This file should undo anything in `up.sql`
DROP TABLE people;

View file

@ -0,0 +1 @@
-- Your SQL goes here

View file

@ -1,8 +0,0 @@
CREATE TABLE people (
id TEXT primary key,
name TEXT not null,
instance TEXT,
mail TEXT,
pw_hash TEXT,
is_local BOOLEAN
)

View file

@ -1,10 +0,0 @@
// Copyright (c) 2023 mStar
//
// Licensed under the EUPL, Version 1.2
//
// You may not use this work except in compliance with the Licence.
// You should have received a copy of the Licence along with this work. If not, see:
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

View file

@ -1,6 +0,0 @@
-- This file was automatically created by Diesel to setup helper functions
-- and other internal bookkeeping. This file is safe to edit, any future
-- changes will be added to existing projects as new migrations.
DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
DROP FUNCTION IF EXISTS diesel_set_updated_at();

View file

@ -1,36 +0,0 @@
-- This file was automatically created by Diesel to setup helper functions
-- and other internal bookkeeping. This file is safe to edit, any future
-- changes will be added to existing projects as new migrations.
-- Sets up a trigger for the given table to automatically set a column called
-- `updated_at` whenever the row is modified (unless `updated_at` was included
-- in the modified columns)
--
-- # Example
--
-- ```sql
-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW());
--
-- SELECT diesel_manage_updated_at('users');
-- ```
CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$
BEGIN
EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s
FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl);
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$
BEGIN
IF (
NEW IS DISTINCT FROM OLD AND
NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
) THEN
NEW.updated_at := current_timestamp;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

View file

@ -1,9 +0,0 @@
-- Your SQL goes here
CREATE TABLE people (
id STRING primary key,
name STRING not null,
instance STRING,
mail STRING,
pw_hash STRING,
is_local BOOLEAN
)

View file

@ -0,0 +1,14 @@
// Routes
// User info: /:user
// Inbox: /:user/inbox
// Webfinger: /.well-known/webfinger
use axum::Router;
pub fn register(router: Router) -> Router {
router
}
fn get_user() -> String {
"Foo".into()
}

View file

@ -0,0 +1,370 @@
// admin/meta
// admin/abuse-user-reports
// admin/accounts/create
// admin/accounts/delete
// admin/accounts/find-by-email
// admin/ad/create
// admin/ad/delete
// admin/ad/list
// admin/ad/update
// admin/announcements/create
// admin/announcements/delete
// admin/announcements/list
// admin/announcements/update
// admin/avatar-decorations/create
// admin/avatar-decorations/delete
// admin/avatar-decorations/list
// admin/avatar-decorations/update
// admin/delete-all-files-of-a-user
// admin/unset-user-avatar
// admin/unset-user-banner
// admin/drive/clean-remote-files
// admin/drive/cleanup
// admin/drive/files
// admin/drive/show-file
// admin/emoji/add-aliases-bulk
// admin/emoji/add
// admin/emoji/copy
// admin/emoji/delete-bulk
// admin/emoji/delete
// admin/emoji/import-zip
// admin/emoji/list-remote
// admin/emoji/list
// admin/emoji/remove-aliases-bulk
// admin/emoji/set-aliases-bulk
// admin/emoji/set-category-bulk
// admin/emoji/set-license-bulk
// admin/emoji/update
// admin/federation/delete-all-files
// admin/federation/refresh-remote-instance-metadata
// admin/federation/remove-all-following
// admin/federation/update-instance
// admin/get-index-stats
// admin/get-table-stats
// admin/get-user-ips
// admin/invite/create
// admin/invite/list
// admin/promo/create
// admin/queue/clear
// admin/queue/deliver-delayed
// admin/queue/inbox-delayed
// admin/queue/promote
// admin/queue/stats
// admin/relays/add
// admin/relays/list
// admin/relays/remove
// admin/reset-password
// admin/resolve-abuse-user-report
// admin/send-email
// admin/server-info
// admin/show-moderation-logs
// admin/show-user
// admin/show-users
// admin/nsfw-user
// admin/unnsfw-user
// admin/silence-user
// admin/unsilence-user
// admin/suspend-user
// admin/approve-user
// admin/unsuspend-user
// admin/update-meta
// admin/delete-account
// admin/update-user-note
// admin/roles/create
// admin/roles/delete
// admin/roles/list
// admin/roles/show
// admin/roles/update
// admin/roles/assign
// admin/roles/unassign
// admin/roles/update-default-policies
// admin/roles/users
// announcements
// antennas/create
// antennas/delete
// antennas/list
// antennas/notes
// antennas/show
// antennas/update
// ap/get
// ap/show
// app/create
// app/show
// auth/accept
// auth/session/generate
// auth/session/show
// auth/session/userkey
// blocking/create
// blocking/delete
// blocking/list
// channels/create
// channels/featured
// channels/follow
// channels/followed
// channels/owned
// channels/show
// channels/timeline
// channels/unfollow
// channels/update
// channels/favorite
// channels/unfavorite
// channels/my-favorites
// channels/search
// charts/active-users
// charts/ap-request
// charts/drive
// charts/federation
// charts/instance
// charts/notes
// charts/user/drive
// charts/user/following
// charts/user/notes
// charts/user/pv
// charts/user/reactions
// charts/users
// clips/add-note
// clips/remove-note
// clips/create
// clips/delete
// clips/list
// clips/notes
// clips/show
// clips/update
// clips/favorite
// clips/unfavorite
// clips/my-favorites
// drive
// drive/files
// drive/files/attached-notes
// drive/files/check-existence
// drive/files/create
// drive/files/delete
// drive/files/find-by-hash
// drive/files/find
// drive/files/show
// drive/files/update
// drive/files/upload-from-url
// drive/folders
// drive/folders/create
// drive/folders/delete
// drive/folders/find
// drive/folders/show
// drive/folders/update
// drive/stream
// email-address/available
// endpoint
// endpoints
// export-custom-emojis
// federation/followers
// federation/following
// federation/instances
// federation/show-instance
// federation/update-remote-user
// federation/users
// federation/stats
// following/create
// following/delete
// following/update
// following/update-all
// following/invalidate
// following/requests/accept
// following/requests/cancel
// following/requests/list
// following/requests/reject
// gallery/featured
// gallery/popular
// gallery/posts
// gallery/posts/create
// gallery/posts/delete
// gallery/posts/like
// gallery/posts/show
// gallery/posts/unlike
// gallery/posts/update
// get-online-users-count
// get-avatar-decorations
// hashtags/list
// hashtags/search
// hashtags/show
// hashtags/trend
// hashtags/users
// i
// i/2fa/done
// i/2fa/key-done
// i/2fa/password-less
// i/2fa/register-key
// i/2fa/register
// i/2fa/update-key
// i/2fa/remove-key
// i/2fa/unregister
// i/apps
// i/authorized-apps
// i/claim-achievement
// i/change-password
// i/delete-account
// i/export-data
// i/export-blocking
// i/export-following
// i/export-mute
// i/export-notes
// i/export-favorites
// i/export-user-lists
// i/export-antennas
// i/favorites
// i/gallery/likes
// i/gallery/posts
// i/import-blocking
// i/import-following
// i/import-notes
// i/import-muting
// i/import-user-lists
// i/import-antennas
// i/notifications
// i/notifications-grouped
// i/page-likes
// i/pages
// i/pin
// i/read-all-unread-notes
// i/read-announcement
// i/regenerate-token
// i/registry/get-all
// i/registry/get-unsecure
// i/registry/get-detail
// i/registry/get
// i/registry/keys-with-type
// i/registry/keys
// i/registry/remove
// i/registry/scopes-with-domain
// i/registry/set
// i/revoke-token
// i/signin-history
// i/unpin
// i/update-email
// i/update
// i/move
// i/webhooks/create
// i/webhooks/list
// i/webhooks/show
// i/webhooks/update
// i/webhooks/delete
// invite/create
// invite/delete
// invite/list
// invite/limit
// meta
// emojis
// emoji
// miauth/gen-token
// mute/create
// mute/delete
// mute/list
// renote-mute/create
// renote-mute/delete
// renote-mute/list
// my/apps
// notes
// notes/children
// notes/clips
// notes/conversation
// notes/create
// notes/delete
// notes/favorites/create
// notes/favorites/delete
// notes/featured
// notes/global-timeline
// notes/bubble-timeline
// notes/hybrid-timeline
// notes/local-timeline
// notes/mentions
// notes/polls/recommendation
// notes/polls/vote
// notes/reactions
// notes/reactions/create
// notes/reactions/delete
// notes/like
// notes/renotes
// notes/replies
// notes/search-by-tag
// notes/search
// notes/show
// notes/state
// notes/thread-muting/create
// notes/thread-muting/delete
// notes/timeline
// notes/translate
// notes/unrenote
// notes/user-list-timeline
// notes/edit
// notes/versions
// notifications/create
// notifications/mark-all-as-read
// notifications/test-notification
// page-push
// pages/create
// pages/delete
// pages/featured
// pages/like
// pages/show
// pages/unlike
// pages/update
// flash/create
// flash/delete
// flash/featured
// flash/like
// flash/show
// flash/unlike
// flash/update
// flash/my
// flash/my-likes
// ping
// pinned-users
// promo/read
// roles/list
// roles/show
// roles/users
// roles/notes
// request-reset-password
// reset-db
// reset-password
// server-info
// stats
// sw/show-registration
// sw/update-registration
// sw/register
// sw/unregister
// test
// username/available
// users
// users/clips
// users/followers
// users/following
// users/gallery/posts
// users/get-frequently-replied-users
// users/featured-notes
// users/lists/create
// users/lists/delete
// users/lists/list
// users/lists/pull
// users/lists/push
// users/lists/show
// users/lists/favorite
// users/lists/unfavorite
// users/lists/update
// users/lists/create-from-public
// users/lists/update-membership
// users/lists/get-memberships
// users/notes
// users/pages
// users/flashs
// users/reactions
// users/recommendation
// users/relation
// users/report-abuse
// users/search-by-username-and-host
// users/search
// users/show
// users/achievements
// users/update-memo
// fetch-rss
// fetch-external-resources
// retention
// sponsors

20
src/error.rs Normal file
View file

@ -0,0 +1,20 @@
use std::fmt::{Display, Formatter};
/// Necessary because of this issue: https://github.com/actix/actix-web/issues/1711
#[derive(Debug)]
pub struct Error(pub(crate) anyhow::Error);
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
impl<T> From<T> for Error
where
T: Into<anyhow::Error>,
{
fn from(t: T) -> Self {
Error(t.into())
}
}

View file

@ -16,9 +16,11 @@ mod storage;
mod guardian; mod guardian;
mod config; mod config;
mod webui; mod webui;
mod error;
fn main() -> Result<(), Error> { #[tokio::main]
async fn main() -> Result<(), Error> {
let conf = config::read_from_env()?; let conf = config::read_from_env()?;
let _db = storage::establish_connection(&conf.database_path)?; let _db = storage::establish_connection(&conf.database_path)?;
Ok(()) Ok(())

View file

@ -8,10 +8,23 @@
// See the Licence for the specific language governing permissions and limitations under the Licence. // See the Licence for the specific language governing permissions and limitations under the Licence.
// //
use activitypub_federation::{kinds::actor::PersonType, fetch::object_id::ObjectId, protocol::public_key::PublicKey};
use serde_derive::{Deserialize, Serialize};
use url::Url;
use crate::storage::pg_models::PersonPG;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Person { pub struct Person {
name: String, pub kind: PersonType,
instance: Option<String>, // If not set, assume local user pub preferred_username: String,
id: String, // @<id>@<instance> pub id: ObjectId<PersonPG>,
mail: Option<String>, pub inbox: Url,
pw_hash: String, // If not set, user uses hardware token pub public_key: PublicKey,
}
pub trait IntoPerson {
fn into_person(&self) -> Person;
} }

View file

@ -0,0 +1,25 @@
use activitypub_federation::{kinds::object::NoteType, fetch::object_id::ObjectId};
use serde_derive::{Deserialize, Serialize};
use url::Url;
use crate::storage::pg_person::PersonPG;
#[derive(Deserialize, Serialize, Debug)]
pub struct Post {
#[serde(rename = "type")]
pub kind: NoteType,
pub id: ObjectId<>,
pub(crate) attributed_to: ObjectId<PersonPG>,
#[serde(deserialize_with = "deserialize_one_or_many")]
pub(crate) to: Vec<Url>,
pub content: String,
pub in_reply_to: Option<ObjectId<>>,
tag: Vec<Mention>
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Mention {
pub href: Url,
#[serde(rename = "type")]
pub kind: MentionType,
}

View file

@ -1,12 +0,0 @@
// Copyright (c) 2023 mStar
//
// Licensed under the EUPL, Version 1.2
//
// You may not use this work except in compliance with the Licence.
// You should have received a copy of the Licence along with this work. If not, see:
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
// See the Licence for the specific language governing permissions and limitations under the Licence.
//
mod sqlite;
mod postgres;

View file

@ -8,37 +8,39 @@
// See the Licence for the specific language governing permissions and limitations under the Licence. // See the Licence for the specific language governing permissions and limitations under the Licence.
// //
pub mod diesel_db; // TODO: Once diesel-async supports sqlite (see https://github.com/weiznich/diesel_async/discussions/95), convert to async
pub mod pg_schemas;
pub mod pg_person;
pub mod pg_post;
use anyhow::{Error, bail}; use anyhow::{Error, bail};
use diesel::{prelude::*, pg::{PgConnection, Pg}, sqlite::Sqlite}; use diesel::{pg::Pg, r2d2::{Pool, ConnectionManager, self}};
use diesel::PgConnection;
use diesel_migrations::{EmbeddedMigrations, embed_migrations, MigrationHarness}; use diesel_migrations::{EmbeddedMigrations, embed_migrations, MigrationHarness};
pub const POSTGRES_MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations/postgres"); pub const POSTGRES_MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
pub enum DB {
Postgres(PgConnection), #[derive(Clone)]
Sqlite(SqliteConnection) pub struct Storage {
pub pool: Pool<ConnectionManager<PgConnection>>,
} }
/// Try and connect to a database at the given url /// Try and connect to a database at the given url
/// The url can be a path to an sqlite db file or an url to a postgres db /// The url can be a path to an sqlite db file or an url to a postgres db
pub fn establish_connection(db_url: &str) -> Result<DB, Error> { pub fn establish_connection(db_url: &str) -> Result<Storage, Error> {
if db_url.starts_with("postgres") { let manager = ConnectionManager::<PgConnection>::new(db_url);
Ok(DB::Postgres(establish_connection_postgres(db_url)?)) let pool = match r2d2::Pool::builder().build(manager) {
} else { Ok(a) => a,
Ok(DB::Sqlite(establish_connection_sqlite(db_url)?)) Err(err) => bail!("Error while creating the connection pool. Error {}", err)
};
match pool.get() {
Ok(mut conn) => {run_migrations_postgres(&mut conn)?;}
Err(e) => bail!(e)
} }
} Ok(Storage{
pool
/// Try and connect to a postgres db })
pub fn establish_connection_postgres(db_url: &str) -> Result<PgConnection, Error> {
//SqliteConnection::establish(db_url).unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e))
let mut conn = PgConnection::establish(db_url)
.unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e));
run_migrations_postgres(&mut conn)?;
//c.run_pending_migrations(MIGRATIONS)?;
Ok(conn)
} }
fn run_migrations_postgres(conn: &mut impl MigrationHarness<Pg>) -> Result<(), Error> { fn run_migrations_postgres(conn: &mut impl MigrationHarness<Pg>) -> Result<(), Error> {
@ -47,20 +49,3 @@ fn run_migrations_postgres(conn: &mut impl MigrationHarness<Pg>) -> Result<(), E
Err(e) => bail!("Migrations failed. Error {}", e) Err(e) => bail!("Migrations failed. Error {}", e)
} }
} }
/// Try and connect to a sqlite db
pub fn establish_connection_sqlite(db_url: &str) -> Result<SqliteConnection, Error> {
//SqliteConnection::establish(db_url).unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e))
let mut conn = SqliteConnection::establish(db_url)
.unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e));
run_migrations_sqlite(&mut conn)?;
//c.run_pending_migrations(MIGRATIONS)?;
Ok(conn)
}
fn run_migrations_sqlite(conn: &mut impl MigrationHarness<Sqlite>) -> Result<(), Error> {
match conn.run_pending_migrations(POSTGRES_MIGRATIONS) {
Ok(_) => Ok(()),
Err(e) => bail!("Migrations failed. Error {}", e)
}
}

98
src/storage/pg_person.rs Normal file
View file

@ -0,0 +1,98 @@
use activitypub_federation::{traits::Object, config::Data, fetch::object_id::ObjectId, protocol::verification::verify_domains_match};
use anyhow::{anyhow, Error};
use chrono::{Utc, NaiveDateTime, DateTime};
use diesel::prelude::*;
use url::Url;
use crate::objects::person::Person;
use super::{Storage, pg_schemas};
#[derive(Queryable, Selectable, Debug, Clone)]
#[diesel(table_name = crate::storage::pg_schemas::people)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct PersonPG {
pub ap_id: String,
pub name: String,
pub instance: Option<String>, // Also url
pub mail: Option<String>,
pub pw_hash: Option<String>,
pub inbox: String, // Is an url but diesel no likey
pub public_key: String,
pub private_key: Option<String>,
pub last_refreshed_at: NaiveDateTime,
pub local: bool,
pub followers: Vec<Option<String>> // Strings are URLs. This is stupid. I wish I could simply use Vec<Url> instead
}
#[async_trait::async_trait]
impl Object for PersonPG {
type DataType = Storage;
type Kind = Person;
type Error = Error;
fn last_refreshed_at(&self) -> Option<DateTime<Utc>> {
Some(self.last_refreshed_at.and_utc())
}
async fn read_from_id(
object_id: Url,
data: &Data<Self::DataType>,
) -> Result<Option<Self>, Self::Error> {
use pg_schemas::people::dsl::*;
let pool = data.pool.clone();
let mut conn = pool.get()?;
let results: Vec<PersonPG> = people
.filter(ap_id.eq(object_id.as_str()))
.limit(1)
.select(PersonPG::as_select())
.load(&mut conn)
.expect(format!("Error loading person from id {}", object_id).as_str());
if results.len() == 1 {
Ok(Some(results[0].clone()))
} else {
Ok(None)
}
}
async fn into_json(self, _data: &Data<Self::DataType>) -> Result<Self::Kind, Self::Error> {
Ok(Person {
kind: Default::default(),
preferred_username: self.name.clone(),
id: ObjectId::parse(&self.ap_id)?,
inbox: Url::parse(&self.inbox)?,
public_key: serde_json::from_str(&self.public_key).unwrap(),
})
}
async fn verify(
json: &Self::Kind,
expected_domain: &Url,
_data: &Data<Self::DataType>,
) -> Result<(), Self::Error> {
Ok(verify_domains_match(&json.id.inner(), &expected_domain)?)
}
async fn from_json(
json: Self::Kind,
_data: &Data<Self::DataType>,
) -> Result<Self, Self::Error> {
Ok(
PersonPG {
ap_id: json.id.inner().to_string(),
name: json.preferred_username,
instance: Some(json.inbox.authority().to_string()),
mail: None,
pw_hash: None,
inbox: json.inbox.to_string(),
public_key: serde_json::to_string(&json.public_key).unwrap(),
private_key: None,
last_refreshed_at: Utc::now().naive_utc(),
local: false,
followers: vec![]
}
)
}
}

7
src/storage/pg_post.rs Normal file
View file

@ -0,0 +1,7 @@
pub struct PostPG {
pub ap_id: String,
pub text: String,
pub creator: String,
pub local: bool,
pub instance: Option<String>
}

17
src/storage/pg_schemas.rs Normal file
View file

@ -0,0 +1,17 @@
// @generated automatically by Diesel CLI.
diesel::table! {
people (ap_id) {
ap_id -> Text,
name -> Text,
instance -> Nullable<Text>,
mail -> Nullable<Text>,
pw_hash -> Nullable<Text>,
inbox -> Text,
public_key -> Text,
private_key -> Nullable<Text>,
last_refreshed_at -> Timestamp,
local -> Bool,
followers -> Array<Nullable<Text>>,
}
}