diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index cdf891126..06a92b09b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ -* @Nutomic @dessalines @phiresky @dullbananas +* @Nutomic @dessalines @phiresky @dullbananas @SleeplessOne1917 crates/apub/ @Nutomic migrations/ @dessalines @phiresky @dullbananas diff --git a/.woodpecker.yml b/.woodpecker.yml index a1f008bd0..ab38db329 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -6,21 +6,23 @@ variables: - &install_pnpm "corepack enable pnpm" - &slow_check_paths - path: - # rust source code - - "crates/**" - - "src/**" - - "**/Cargo.toml" - - "Cargo.lock" - # database migrations - - "migrations/**" - # typescript tests - - "api_tests/**" - # config files and scripts used by ci - - ".woodpecker.yml" - - ".rustfmt.toml" - - "scripts/update_config_defaults.sh" - - "diesel.toml" - - ".gitmodules" + include: [ + # rust source code + "crates/**", + "src/**", + "**/Cargo.toml", + "Cargo.lock", + # database migrations + "migrations/**", + # typescript tests + "api_tests/**", + # config files and scripts used by ci + ".woodpecker.yml", + ".rustfmt.toml", + "scripts/update_config_defaults.sh", + "diesel.toml", + ".gitmodules", + ] # Broken for cron jobs currently, see # https://github.com/woodpecker-ci/woodpecker/issues/1716 @@ -198,7 +200,7 @@ steps: - cat target/log/lemmy_*.out || true - "# If you can't see all output, then use the download button" when: - status: [failure] + - status: [failure] publish_release_docker: image: woodpeckerci/plugin-docker-buildx @@ -211,7 +213,7 @@ steps: - RUST_RELEASE_MODE=release tag: ${CI_COMMIT_TAG} when: - event: tag + - event: tag nightly_build: image: woodpeckerci/plugin-docker-buildx @@ -224,7 +226,7 @@ steps: - RUST_RELEASE_MODE=release tag: dev when: - event: cron + - event: cron # using https://github.com/pksunkara/cargo-workspaces publish_to_crates_io: @@ -237,7 +239,7 @@ steps: - cargo workspaces publish --from-git --allow-dirty --no-verify --allow-branch "${CI_COMMIT_TAG}" --yes custom "${CI_COMMIT_TAG}" secrets: [cargo_api_token] when: - event: tag + - event: tag notify_on_failure: image: alpine:3 @@ -245,7 +247,7 @@ steps: - apk add curl - "curl -d'Lemmy CI build failed: ${CI_PIPELINE_URL}' ntfy.sh/lemmy_drone_ci" when: - status: [failure] + - status: [failure] notify_on_tag_deploy: image: alpine:3 @@ -253,7 +255,7 @@ steps: - apk add curl - "curl -d'lemmy:${CI_COMMIT_TAG} deployed' ntfy.sh/lemmy_drone_ci" when: - event: tag + - event: tag services: database: diff --git a/Cargo.lock b/Cargo.lock index b9ebfa540..0ce7859e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,11 +64,11 @@ dependencies = [ [[package]] name = "actix-codec" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" +checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "bytes", "futures-core", "futures-sink", @@ -157,7 +157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -246,8 +246,10 @@ dependencies = [ "futures-core", "impl-more", "pin-project-lite", + "rustls-pki-types", "tokio", "tokio-rustls 0.23.4", + "tokio-rustls 0.25.0", "tokio-util", "tracing", "webpki-roots 0.22.6", @@ -313,7 +315,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -361,9 +363,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -419,9 +421,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ "anstyle", "anstyle-parse", @@ -433,9 +435,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -467,9 +469,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" dependencies = [ "backtrace", ] @@ -531,18 +533,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -655,12 +657,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] -name = "bcrypt" -version = "0.15.0" +name = "base64" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d1c9c15093eb224f0baa400f38fcd713fc1391a6f1c389d886beef146d60a3" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bb8" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df7c2093d15d6a1d33b1f972e1c5ea3177748742b97a5f392aa83a65262c6780" dependencies = [ - "base64 0.21.7", + "async-trait", + "futures-channel", + "futures-util", + "parking_lot 0.12.1", + "tokio", +] + +[[package]] +name = "bcder" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627747a6774aab38beb35990d88309481378558875a41da1a4b2e373c906ef0" +dependencies = [ + "bytes", + "smallvec", +] + +[[package]] +name = "bcrypt" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e65938ed058ef47d92cf8b346cc76ef48984572ade631927e9937b5ffc7662c7" +dependencies = [ + "base64 0.22.0", "blowfish", "getrandom", "subtle", @@ -702,6 +739,9 @@ name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +dependencies = [ + "serde", +] [[package]] name = "block-buffer" @@ -723,10 +763,16 @@ dependencies = [ ] [[package]] -name = "brotli" -version = "3.4.0" +name = "blurhash-update" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" +checksum = "bfb5ea45aeb912f2dd334834e64ecf674a6673d57c73e9d12de0298b9bf98ee8" + +[[package]] +name = "brotli" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -745,9 +791,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytecount" @@ -757,9 +803,9 @@ checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "byteorder" @@ -807,9 +853,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -829,9 +875,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ "jobserver", "libc", @@ -851,9 +897,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", @@ -861,7 +907,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -886,9 +932,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", "clap_derive", @@ -896,33 +942,33 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.0", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "clokwerk" @@ -935,9 +981,9 @@ dependencies = [ [[package]] name = "color-eyre" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" dependencies = [ "backtrace", "color-spantrace", @@ -984,18 +1030,17 @@ dependencies = [ [[package]] name = "config" -version = "0.13.4" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" dependencies = [ - "async-trait", "lazy_static", "nom", "pathdiff", "ron", "serde", "serde_json", - "toml 0.5.11", + "toml 0.8.12", "yaml-rust", ] @@ -1072,6 +1117,12 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const_format" version = "0.2.32" @@ -1142,18 +1193,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" dependencies = [ "crossbeam-utils", ] @@ -1205,12 +1256,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" dependencies = [ - "darling_core 0.20.3", - "darling_macro 0.20.3", + "darling_core 0.20.8", + "darling_macro 0.20.8", ] [[package]] @@ -1223,7 +1274,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -1237,22 +1288,22 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim", - "syn 2.0.48", + "strsim 0.10.0", + "syn 2.0.53", ] [[package]] @@ -1279,13 +1330,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ - "darling_core 0.20.3", + "darling_core 0.20.8", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -1335,6 +1386,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -1411,9 +1472,9 @@ dependencies = [ [[package]] name = "diesel" -version = "2.1.4" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62c6fcf842f17f8c78ecf7c81d75c5ce84436b41ee07e03f490fbb5f5a8731d8" +checksum = "03fc05c17098f21b89bc7d98fe1dd3cce2c11c2ad8e145f2a44fe08ed28eb559" dependencies = [ "bitflags 2.4.2", "byteorder", @@ -1433,6 +1494,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acada1517534c92d3f382217b485db8a8638f111b0e3f2a2a8e26165050f77be" dependencies = [ "async-trait", + "bb8", "deadpool 0.9.5", "diesel", "futures-util", @@ -1447,33 +1509,33 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81c5131a2895ef64741dad1d483f358c2a229a3a2d1b256778cdc5e146db64d4" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "diesel-derive-newtype" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7267437d5b12df60ae29bd97f8d120f1c3a6272d6f213551afa56bbb2ecfbb7" +checksum = "f4ed4d69628c8de8eb4c3f50cddb0678cba3c5b4cbe3cb1067d4d6c62ca47e4e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "diesel_derives" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8337737574f55a468005a83499da720f20c65586241ffea339db9ecdfd2b44" +checksum = "5d02eecb814ae714ffe61ddc2db2dd03e6c49a42e269b5001355500d431cce0c" dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -1503,7 +1565,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -1570,9 +1632,9 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elementtree" @@ -1695,7 +1757,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -1755,9 +1817,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "eyre" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" dependencies = [ "indenter", "once_cell", @@ -1775,7 +1837,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a88c69768c0a15262df21899142bc6df9b9b823546d4b4b9a7bc2d6c448ec6fd" dependencies = [ - "hashbrown 0.13.1", + "hashbrown 0.13.2", ] [[package]] @@ -1937,7 +1999,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -2016,9 +2078,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ "bytes", "fnv", @@ -2041,9 +2103,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ "ahash", ] @@ -2078,10 +2140,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "hermit-abi" -version = "0.3.4" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -2167,9 +2235,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -2311,14 +2379,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8215279f83f9b829403812f845aa2d0dd5966332aa2fd0334a375256f3dd0322" dependencies = [ "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2365,9 +2433,9 @@ dependencies = [ [[package]] name = "image" -version = "0.24.8" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", @@ -2500,18 +2568,18 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -2523,7 +2591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ "base64 0.21.7", - "pem", + "pem 1.1.1", "ring 0.16.20", "serde", "serde_json", @@ -2577,6 +2645,7 @@ version = "0.19.3" dependencies = [ "activitypub_federation", "actix-web", + "anyhow", "chrono", "encoding", "enum-map", @@ -2589,6 +2658,7 @@ dependencies = [ "lemmy_db_views_moderator", "lemmy_utils", "mime", + "moka", "once_cell", "pretty_assertions", "regex", @@ -2714,7 +2784,7 @@ dependencies = [ "strum_macros", "tokio", "tokio-postgres", - "tokio-postgres-rustls", + "tokio-postgres-rustls 0.10.0", "tracing", "ts-rs", "typed-builder", @@ -2908,9 +2978,9 @@ dependencies = [ [[package]] name = "lettre" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5aaf628956b6b0852e12ac3505d20d7a12ecc1e32d5ea921f002af4a74036a5" +checksum = "357ff5edb6d8326473a64c82cf41ddf78ab116f89668c50c4fac1b321e5e80f4" dependencies = [ "async-trait", "base64 0.21.7", @@ -2926,6 +2996,7 @@ dependencies = [ "mime", "native-tls", "nom", + "percent-encoding", "quoted_printable", "socket2", "tokio", @@ -2935,9 +3006,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "line-wrap" @@ -3017,9 +3088,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "mac" @@ -3126,9 +3197,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "metrics" -version = "0.22.0" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b9e10a211c839210fd7f99954bda26e5f8e26ec686ad68da6a32df7c80e782" +checksum = "2be3cbd384d4e955b231c895ce10685e3d8260c5ccffae898c96c723b0772835" dependencies = [ "ahash", "portable-atomic", @@ -3136,13 +3207,13 @@ dependencies = [ [[package]] name = "metrics-exporter-prometheus" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a4c4718a371ddfb7806378f23617876eea8b82e5ff1324516bcd283249d9ea" +checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21" dependencies = [ "base64 0.21.7", "hyper", - "indexmap 1.9.3", + "indexmap 2.2.5", "ipnet", "metrics", "metrics-util", @@ -3153,13 +3224,13 @@ dependencies = [ [[package]] name = "metrics-util" -version = "0.16.0" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2670b8badcc285d486261e2e9f1615b506baff91427b61bd336a472b65bbf5ed" +checksum = "8b07a5eb561b8cbc16be2d216faf7757f9baf3bfb94dbb0fae3df8387a5bb47f" dependencies = [ "crossbeam-epoch", "crossbeam-utils", - "hashbrown 0.13.1", + "hashbrown 0.14.3", "metrics", "num_cpus", "quanta", @@ -3211,9 +3282,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -3221,9 +3292,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -3296,9 +3367,9 @@ checksum = "c96aba5aa877601bb3f6dd6a63a969e1f82e60646e81e71b14496995e9853c91" [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nom" @@ -3332,20 +3403,25 @@ dependencies = [ ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "num-conv" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -3398,7 +3474,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -3448,13 +3524,12 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" +checksum = "900d57987be3f2aeb70d385fff9b27fb74c5723cc9a52d904d4f9c807a0667bf" dependencies = [ "futures-core", "futures-sink", - "indexmap 2.2.5", "js-sys", "once_cell", "pin-project-lite", @@ -3482,21 +3557,21 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24cda83b20ed2433c68241f918d0f6fdec8b1d43b7a9590ab4420c5095ca930" +checksum = "1a016b8d9495c639af2145ac22387dcb88e44118e45320d9238fbf4e7889abcb" dependencies = [ "async-trait", "futures-core", "http", - "opentelemetry 0.21.0", - "opentelemetry-proto 0.4.0", + "opentelemetry 0.22.0", + "opentelemetry-proto 0.5.0", "opentelemetry-semantic-conventions", - "opentelemetry_sdk 0.21.2", - "prost 0.11.9", + "opentelemetry_sdk 0.22.1", + "prost 0.12.3", "thiserror", "tokio", - "tonic 0.9.2", + "tonic 0.11.0", ] [[package]] @@ -3514,24 +3589,21 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e155ce5cc812ea3d1dffbd1539aed653de4bf4882d60e6e04dcf0901d674e1" +checksum = "3a8fddc9b68f5b80dae9d6f510b88e02396f006ad48cac349411fbecc80caae4" dependencies = [ - "opentelemetry 0.21.0", - "opentelemetry_sdk 0.21.2", - "prost 0.11.9", - "tonic 0.9.2", + "opentelemetry 0.22.0", + "opentelemetry_sdk 0.22.1", + "prost 0.12.3", + "tonic 0.11.0", ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5774f1ef1f982ef2a447f6ee04ec383981a3ab99c8e77a1a7b30182e65bbc84" -dependencies = [ - "opentelemetry 0.21.0", -] +checksum = "f9ab5bd6c42fb9349dcf28af2ba9a0667f697f9bdcca045d39f2cec5543e2910" [[package]] name = "opentelemetry_api" @@ -3573,9 +3645,9 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.21.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" +checksum = "9e90c7113be649e31e9a0f8b5ee24ed7a16923b322c3c5ab6367469c049d6b7e" dependencies = [ "async-trait", "crossbeam-channel", @@ -3584,7 +3656,7 @@ dependencies = [ "futures-util", "glob", "once_cell", - "opentelemetry 0.21.0", + "opentelemetry 0.22.0", "ordered-float", "percent-encoding", "rand", @@ -3683,6 +3755,16 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "pem" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +dependencies = [ + "base64 0.21.7", + "serde", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -3747,21 +3829,22 @@ dependencies = [ [[package]] name = "pict-rs" -version = "0.5.1" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca72ffda2e229b6be6aeda550b7069aa8dc72589711da63c59914df89bf91b02" +checksum = "e709cefc614ddbe5685b30298790a2fe8637523190c182c0215c18053ce7cfdf" dependencies = [ "actix-form-data", "actix-web", "async-trait", "barrel", "base64 0.21.7", + "bb8", + "blurhash-update", "clap", "color-eyre", "config", "console-subscriber 0.2.0", "dashmap", - "deadpool 0.9.5", "diesel", "diesel-async", "diesel-derive-enum", @@ -3772,14 +3855,17 @@ dependencies = [ "metrics", "metrics-exporter-prometheus", "mime", - "opentelemetry 0.21.0", - "opentelemetry-otlp 0.14.0", - "opentelemetry_sdk 0.21.2", + "opentelemetry 0.22.0", + "opentelemetry-otlp 0.15.0", + "opentelemetry_sdk 0.22.1", "pin-project-lite", "refinery", "reqwest", "reqwest-middleware", "reqwest-tracing", + "rustls 0.22.2", + "rustls-channel-resolver", + "rustls-pemfile 2.1.1", "rusty-s3", "serde", "serde-tuple-vec-map", @@ -3787,43 +3873,44 @@ dependencies = [ "serde_urlencoded", "sha2", "sled", - "storage-path-generator", "streem", "subtle", "thiserror", "time", "tokio", "tokio-postgres", + "tokio-postgres-rustls 0.11.1", "tokio-util", - "toml 0.8.8", + "toml 0.8.12", "tracing", "tracing-actix-web", "tracing-error", "tracing-log 0.2.0", - "tracing-opentelemetry 0.22.0", + "tracing-opentelemetry 0.23.0", "tracing-subscriber", "url", "uuid", + "webpki-roots 0.26.1", ] [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -3840,9 +3927,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plist" @@ -3860,9 +3947,9 @@ dependencies = [ [[package]] name = "png" -version = "0.17.11" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -3963,9 +4050,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -4043,7 +4130,7 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -4081,11 +4168,11 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.3" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "memchr", "unicase", ] @@ -4187,7 +4274,7 @@ checksum = "a25d631e41bfb5fdcde1d4e2215f62f7f0afa3ff11e26563765bd6ea1d229aeb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -4230,12 +4317,12 @@ dependencies = [ "postgres", "regex", "serde", - "siphasher 1.0.0", + "siphasher 1.0.1", "thiserror", "time", "tokio", "tokio-postgres", - "toml 0.8.8", + "toml 0.8.12", "url", "walkdir", ] @@ -4250,7 +4337,7 @@ dependencies = [ "quote", "refinery-core", "regex", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -4261,7 +4348,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.6", "regex-syntax 0.8.2", ] @@ -4276,9 +4363,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -4291,12 +4378,6 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" -[[package]] -name = "regex-syntax" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" - [[package]] name = "regex-syntax" version = "0.8.2" @@ -4305,9 +4386,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.24" +version = "0.11.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" dependencies = [ "async-compression", "base64 0.21.7", @@ -4331,7 +4412,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.10", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -4347,15 +4428,15 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.25.3", + "webpki-roots 0.25.4", "winreg", ] [[package]] name = "reqwest-middleware" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a3e86aa6053e59030e7ce2d2a3b258dd08fc2d337d52f73f6cb480f5858690" +checksum = "5a735987236a8e238bf0296c7e351b999c188ccc11477f311b82b55c93984216" dependencies = [ "anyhow", "async-trait", @@ -4368,9 +4449,9 @@ dependencies = [ [[package]] name = "reqwest-tracing" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0152176687dd5cfe7f507ac1cb1a491c679cfe483afd133a7db7aaea818bb3" +checksum = "190838e54153d7a7e2ea98851304b3ce92daeabf14c54d32b01b84a3e636f683" dependencies = [ "anyhow", "async-trait", @@ -4422,27 +4503,29 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom", "libc", "spin 0.9.8", "untrusted 0.9.0", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "ron" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.7", + "bitflags 2.4.2", "serde", + "serde_derive", ] [[package]] @@ -4508,9 +4591,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", @@ -4538,11 +4621,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", - "ring 0.17.7", - "rustls-webpki", + "ring 0.17.8", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring 0.17.8", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-channel-resolver" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbd1941204442f051576a9a7ea8e8db074ad7fd43db1eb3378c3633f9f9e166" +dependencies = [ + "nanorand", + "rustls 0.22.2", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -4552,13 +4659,40 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab" +dependencies = [ + "base64 0.21.7", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" + [[package]] name = "rustls-webpki" version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", + "untrusted 0.9.0", +] + +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring 0.17.8", + "rustls-pki-types", "untrusted 0.9.0", ] @@ -4589,9 +4723,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safemem" @@ -4639,7 +4773,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -4679,9 +4813,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" dependencies = [ "serde", ] @@ -4712,7 +4846,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -4759,9 +4893,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.5.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5c9fdb6b00a489875b22efd4b78fe2b363b72265cc5f6eb2e2b9ee270e6140c" +checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" dependencies = [ "base64 0.21.7", "chrono", @@ -4769,6 +4903,7 @@ dependencies = [ "indexmap 1.9.3", "indexmap 2.2.5", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -4776,14 +4911,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.5.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff351eb4b33600a2e138dfa0b10b65a238ea8ff8fb2387c422c5022a3e8298" +checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" dependencies = [ - "darling 0.20.3", + "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -4808,7 +4943,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -4851,6 +4986,15 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -4877,15 +5021,15 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "siphasher" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "sitemap-rs" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b58125f0ab4317b5ba3cdc1f60696e47958760e356874c759334fa56ae1596" +checksum = "88cc73a9aac975541c9054e74ceae8d8ee85edc89a322404c275c1d100fffa51" dependencies = [ "chrono", "xml-builder", @@ -4908,9 +5052,9 @@ dependencies = [ [[package]] name = "sketches-ddsketch" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a406c1882ed7f29cd5e248c9848a80e7cb6ae0fea82346d2746f2f941c07e1" +checksum = "85636c14b73d81f541e525f585c0a2109e6744e1565b5c1668e31c70c10ed65c" [[package]] name = "slab" @@ -4951,17 +5095,17 @@ checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -4979,6 +5123,16 @@ 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 = "stacker" version = "0.1.15" @@ -4992,12 +5146,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "storage-path-generator" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f11d35dae9818c4313649da4a97c8329e29357a7fe584526c1d78f5b63ef836" - [[package]] name = "streem" version = "0.2.0" @@ -5057,6 +5205,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "strum" version = "0.25.0" @@ -5069,11 +5223,11 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -5095,9 +5249,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote", @@ -5112,9 +5266,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "syntect" -version = "5.1.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" dependencies = [ "bincode", "bitflags 1.3.2", @@ -5123,8 +5277,9 @@ dependencies = [ "fnv", "once_cell", "plist", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", "serde", + "serde_derive", "serde_json", "thiserror", "walkdir", @@ -5169,14 +5324,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", - "rustix 0.38.30", + "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -5202,29 +5356,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -5232,12 +5386,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -5252,10 +5407,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -5318,7 +5474,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -5371,6 +5527,21 @@ dependencies = [ "tokio-rustls 0.24.1", ] +[[package]] +name = "tokio-postgres-rustls" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea13f22eda7127c827983bdaf0d7fff9df21c8817bab02815ac277a21143677" +dependencies = [ + "futures", + "ring 0.17.8", + "rustls 0.22.2", + "tokio", + "tokio-postgres", + "tokio-rustls 0.25.0", + "x509-certificate", +] + [[package]] name = "tokio-rustls" version = "0.23.4" @@ -5393,10 +5564,21 @@ dependencies = [ ] [[package]] -name = "tokio-stream" -version = "0.1.14" +name = "tokio-rustls" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.2", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -5417,15 +5599,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml" version = "0.7.8" @@ -5440,14 +5613,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.8" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.0", + "toml_edit 0.22.8", ] [[package]] @@ -5469,20 +5642,20 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.22.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "c12219811e0c1ba077867254e5ad62ee2c9c190b0d957110750ac0cda1ae96cd" dependencies = [ "indexmap 2.2.5", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.5", ] [[package]] @@ -5572,6 +5745,33 @@ dependencies = [ "tracing", ] +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost 0.12.3", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "totp-rs" version = "5.5.1" @@ -5634,16 +5834,16 @@ dependencies = [ [[package]] name = "tracing-actix-web" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe0d5feac3f4ca21ba33496bcb1ccab58cca6412b1405ae80f0581541e0ca78" +checksum = "fa069bd1503dd526ee793bb3fce408895136c95fc86d2edb2acf1c646d7f0684" dependencies = [ "actix-web", "mutually_exclusive_features", - "opentelemetry 0.21.0", + "opentelemetry 0.22.0", "pin-project", "tracing", - "tracing-opentelemetry 0.22.0", + "tracing-opentelemetry 0.23.0", "uuid", ] @@ -5655,7 +5855,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -5739,14 +5939,14 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67ac25c5407e7b961fafc6f7e9aa5958fd297aada2d20fa2ae1737357e55596" +checksum = "a9be14ba1bbe4ab79e9229f7f89fab8d120b865859f10527f31c033e599d2284" dependencies = [ "js-sys", "once_cell", - "opentelemetry 0.21.0", - "opentelemetry_sdk 0.21.2", + "opentelemetry 0.22.0", + "opentelemetry_sdk 0.22.1", "smallvec", "tracing", "tracing-core", @@ -5818,7 +6018,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", "termcolor", ] @@ -5839,7 +6039,7 @@ checksum = "563b3b88238ec95680aef36bdece66896eaa7ce3c0f1b4f39d38fb2435261352" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -5877,9 +6077,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] @@ -5946,9 +6146,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "atomic", "getrandom", @@ -5975,9 +6175,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -5999,10 +6199,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasm-bindgen" -version = "0.2.90" +name = "wasite" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +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", @@ -6010,24 +6216,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -6037,9 +6243,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6047,22 +6253,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-streams" @@ -6088,9 +6294,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -6098,9 +6304,9 @@ dependencies = [ [[package]] name = "web-time" -version = "0.2.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", @@ -6139,7 +6345,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -6154,17 +6360,27 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "whoami" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" +checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ - "wasm-bindgen", + "redox_syscall 0.4.1", + "wasite", "web-sys", ] @@ -6205,7 +6421,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -6232,7 +6448,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -6267,17 +6483,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "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]] @@ -6294,9 +6510,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -6312,9 +6528,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -6330,9 +6546,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -6348,9 +6564,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -6366,9 +6582,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -6384,9 +6600,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -6402,15 +6618,24 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" dependencies = [ "memchr", ] @@ -6425,6 +6650,25 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "x509-certificate" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66534846dec7a11d7c50a74b7cdb208b9a581cad890b7866430d438455847c85" +dependencies = [ + "bcder", + "bytes", + "chrono", + "der", + "hex", + "pem 3.0.3", + "ring 0.17.8", + "signature", + "spki", + "thiserror", + "zeroize", +] + [[package]] name = "xml-builder" version = "0.5.2" @@ -6474,7 +6718,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -6482,6 +6726,20 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.53", +] [[package]] name = "zstd" diff --git a/Cargo.toml b/Cargo.toml index 5e0cdb16e..366bdc353 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,8 @@ debug = 0 [features] embed-pictrs = ["pict-rs"] +# This feature requires building with `tokio_unstable` flag, see documentation: +# https://docs.rs/tokio/latest/tokio/#unstable-features console = [ "console-subscriber", "opentelemetry", @@ -102,9 +104,9 @@ activitypub_federation = { version = "0.5.2", default-features = false, features diesel = "2.1.4" diesel_migrations = "2.1.0" diesel-async = "0.4.1" -serde = { version = "1.0.195", features = ["derive"] } -serde_with = "3.5.1" -actix-web = { version = "4.4.1", default-features = false, features = [ +serde = { version = "1.0.197", features = ["derive"] } +serde_with = "3.7.0" +actix-web = { version = "4.5.1", default-features = false, features = [ "macros", "rustls", "compress-brotli", @@ -113,39 +115,39 @@ actix-web = { version = "4.4.1", default-features = false, features = [ "cookies", ] } tracing = "0.1.40" -tracing-actix-web = { version = "0.7.9", default-features = false } +tracing-actix-web = { version = "0.7.10", default-features = false } tracing-error = "0.2.0" tracing-log = "0.2.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } url = { version = "2.5.0", features = ["serde"] } -reqwest = { version = "0.11.23", features = ["json", "blocking", "gzip"] } +reqwest = { version = "0.11.26", features = ["json", "blocking", "gzip"] } reqwest-middleware = "0.2.4" reqwest-tracing = "0.4.7" clokwerk = "0.4.0" doku = { version = "0.21.1", features = ["url-2"] } bcrypt = "0.15.0" -chrono = { version = "0.4.32", features = ["serde"], default-features = false } -serde_json = { version = "1.0.111", features = ["preserve_order"] } +chrono = { version = "0.4.35", features = ["serde"], default-features = false } +serde_json = { version = "1.0.114", features = ["preserve_order"] } base64 = "0.21.7" uuid = { version = "1.7.0", features = ["serde", "v4"] } async-trait = "0.1.77" captcha = "0.0.9" -anyhow = { version = "1.0.79", features = [ +anyhow = { version = "1.0.81", features = [ "backtrace", ] } # backtrace is on by default on nightly, but not stable rust diesel_ltree = "0.3.1" typed-builder = "0.18.1" serial_test = "2.0.0" -tokio = { version = "1.35.1", features = ["full"] } +tokio = { version = "1.36.0", features = ["full"] } regex = "1.10.3" once_cell = "1.19.0" diesel-derive-newtype = "2.1.0" diesel-derive-enum = { version = "2.1.0", features = ["postgres"] } strum = "0.25.0" strum_macros = "0.25.3" -itertools = "0.12.0" +itertools = "0.12.1" futures = "0.3.30" -http = "0.2.11" +http = "0.2.12" rosetta-i18n = "0.1.3" opentelemetry = { version = "0.19.0", features = ["rt-tokio"] } tracing-opentelemetry = { version = "0.19.0" } @@ -160,9 +162,9 @@ tokio-postgres = "0.7.10" tokio-postgres-rustls = "0.10.0" urlencoding = "2.1.3" enum-map = "2.7" -moka = { version = "0.12.4", features = ["future"] } +moka = { version = "0.12.5", features = ["future"] } i-love-jesus = { version = "0.1.0" } -clap = { version = "4.4.18", features = ["derive"] } +clap = { version = "4.5.2", features = ["derive"] } pretty_assertions = "1.4.0" [dependencies] @@ -193,7 +195,7 @@ tracing-opentelemetry = { workspace = true, optional = true } opentelemetry = { workspace = true, optional = true } console-subscriber = { version = "0.1.10", optional = true } opentelemetry-otlp = { version = "0.12.0", optional = true } -pict-rs = { version = "0.5.1", optional = true } +pict-rs = { version = "0.5.9", optional = true } tokio.workspace = true actix-cors = "0.6.5" futures-util = { workspace = true } diff --git a/api_tests/package.json b/api_tests/package.json index 9e7042f2d..07f9fa776 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -20,16 +20,16 @@ }, "devDependencies": { "@types/jest": "^29.5.12", - "@types/node": "^20.11.22", - "@typescript-eslint/eslint-plugin": "^7.1.0", - "@typescript-eslint/parser": "^7.1.0", + "@types/node": "^20.11.27", + "@typescript-eslint/eslint-plugin": "^7.2.0", + "@typescript-eslint/parser": "^7.2.0", "download-file-sync": "^1.0.4", "eslint": "^8.57.0", - "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-prettier": "^5.1.3", "jest": "^29.5.0", - "lemmy-js-client": "0.19.4-alpha.6", + "lemmy-js-client": "0.19.4-alpha.8", "prettier": "^3.2.5", "ts-jest": "^29.1.0", - "typescript": "^5.3.3" + "typescript": "^5.4.2" } } diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index 213111ab1..39bba75a1 100644 --- a/api_tests/pnpm-lock.yaml +++ b/api_tests/pnpm-lock.yaml @@ -9,14 +9,14 @@ devDependencies: specifier: ^29.5.12 version: 29.5.12 '@types/node': - specifier: ^20.11.22 - version: 20.11.22 + specifier: ^20.11.27 + version: 20.11.27 '@typescript-eslint/eslint-plugin': - specifier: ^7.1.0 - version: 7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3) + specifier: ^7.2.0 + version: 7.2.0(@typescript-eslint/parser@7.2.0)(eslint@8.57.0)(typescript@5.4.2) '@typescript-eslint/parser': - specifier: ^7.1.0 - version: 7.1.0(eslint@8.57.0)(typescript@5.3.3) + specifier: ^7.2.0 + version: 7.2.0(eslint@8.57.0)(typescript@5.4.2) download-file-sync: specifier: ^1.0.4 version: 1.0.4 @@ -24,23 +24,23 @@ devDependencies: specifier: ^8.57.0 version: 8.57.0 eslint-plugin-prettier: - specifier: ^5.0.1 + specifier: ^5.1.3 version: 5.1.3(eslint@8.57.0)(prettier@3.2.5) jest: specifier: ^29.5.0 - version: 29.7.0(@types/node@20.11.22) + version: 29.7.0(@types/node@20.11.27) lemmy-js-client: - specifier: 0.19.4-alpha.6 - version: 0.19.4-alpha.6 + specifier: 0.19.4-alpha.8 + version: 0.19.4-alpha.8 prettier: specifier: ^3.2.5 version: 3.2.5 ts-jest: specifier: ^29.1.0 - version: 29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.3.3) + version: 29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.2) typescript: - specifier: ^5.3.3 - version: 5.3.3 + specifier: ^5.4.2 + version: 5.4.2 packages: @@ -464,7 +464,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -485,14 +485,14 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.11.22) + jest-config: 29.7.0(@types/node@20.11.27) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -520,7 +520,7 @@ packages: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 jest-mock: 29.7.0 dev: true @@ -547,7 +547,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 20.11.22 + '@types/node': 20.11.27 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -580,7 +580,7 @@ packages: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.22 - '@types/node': 20.11.22 + '@types/node': 20.11.27 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -668,7 +668,7 @@ packages: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.11.22 + '@types/node': 20.11.27 '@types/yargs': 17.0.32 chalk: 4.1.2 dev: true @@ -777,7 +777,7 @@ packages: /@types/graceful-fs@4.1.9: resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} dependencies: - '@types/node': 20.11.22 + '@types/node': 20.11.27 dev: true /@types/istanbul-lib-coverage@2.0.6: @@ -807,8 +807,8 @@ packages: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true - /@types/node@20.11.22: - resolution: {integrity: sha512-/G+IxWxma6V3E+pqK1tSl2Fo1kl41pK1yeCyDsgkF9WlVAme4j5ISYM2zR11bgLFJGLN5sVK40T4RJNuiZbEjA==} + /@types/node@20.11.27: + resolution: {integrity: sha512-qyUZfMnCg1KEz57r7pzFtSGt49f6RPkPBis3Vo4PbS7roQEDn22hiHzl/Lo1q4i4hDEgBJmBF/NTNg2XR0HbFg==} dependencies: undici-types: 5.26.5 dev: true @@ -831,8 +831,8 @@ packages: '@types/yargs-parser': 21.0.3 dev: true - /@typescript-eslint/eslint-plugin@7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-j6vT/kCulhG5wBmGtstKeiVr1rdXE4nk+DT1k6trYkwlrvW9eOF5ZbgKnd/YR6PcM4uTEXa0h6Fcvf6X7Dxl0w==} + /@typescript-eslint/eslint-plugin@7.2.0(@typescript-eslint/parser@7.2.0)(eslint@8.57.0)(typescript@5.4.2): + resolution: {integrity: sha512-mdekAHOqS9UjlmyF/LSs6AIEvfceV749GFxoBAjwAv0nkevfKHWQFDMcBZWUiIC5ft6ePWivXoS36aKQ0Cy3sw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: '@typescript-eslint/parser': ^7.0.0 @@ -843,25 +843,25 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.1.0(eslint@8.57.0)(typescript@5.3.3) - '@typescript-eslint/scope-manager': 7.1.0 - '@typescript-eslint/type-utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3) - '@typescript-eslint/utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3) - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/parser': 7.2.0(eslint@8.57.0)(typescript@5.4.2) + '@typescript-eslint/scope-manager': 7.2.0 + '@typescript-eslint/type-utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2) + '@typescript-eslint/utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2) + '@typescript-eslint/visitor-keys': 7.2.0 debug: 4.3.4 eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.1 natural-compare: 1.4.0 semver: 7.6.0 - ts-api-utils: 1.2.1(typescript@5.3.3) - typescript: 5.3.3 + ts-api-utils: 1.3.0(typescript@5.4.2) + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-V1EknKUubZ1gWFjiOZhDSNToOjs63/9O0puCgGS8aDOgpZY326fzFu15QAUjwaXzRZjf/qdsdBrckYdv9YxB8w==} + /@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.4.2): + resolution: {integrity: sha512-5FKsVcHTk6TafQKQbuIVkXq58Fnbkd2wDL4LB7AURN7RUOu1utVP+G8+6u3ZhEroW3DF6hyo3ZEXxgKgp4KeCg==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^8.56.0 @@ -870,27 +870,27 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 7.1.0 - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3) - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/scope-manager': 7.2.0 + '@typescript-eslint/types': 7.2.0 + '@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2) + '@typescript-eslint/visitor-keys': 7.2.0 debug: 4.3.4 eslint: 8.57.0 - typescript: 5.3.3 + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/scope-manager@7.1.0: - resolution: {integrity: sha512-6TmN4OJiohHfoOdGZ3huuLhpiUgOGTpgXNUPJgeZOZR3DnIpdSgtt83RS35OYNNXxM4TScVlpVKC9jyQSETR1A==} + /@typescript-eslint/scope-manager@7.2.0: + resolution: {integrity: sha512-Qh976RbQM/fYtjx9hs4XkayYujB/aPwglw2choHmf3zBjB4qOywWSdt9+KLRdHubGcoSwBnXUH2sR3hkyaERRg==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/types': 7.2.0 + '@typescript-eslint/visitor-keys': 7.2.0 dev: true - /@typescript-eslint/type-utils@7.1.0(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-UZIhv8G+5b5skkcuhgvxYWHjk7FW7/JP5lPASMEUoliAPwIH/rxoUSQPia2cuOj9AmDZmwUl1usKm85t5VUMew==} + /@typescript-eslint/type-utils@7.2.0(eslint@8.57.0)(typescript@5.4.2): + resolution: {integrity: sha512-xHi51adBHo9O9330J8GQYQwrKBqbIPJGZZVQTHHmy200hvkLZFWJIFtAG/7IYTWUyun6DE6w5InDReePJYJlJA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^8.56.0 @@ -899,23 +899,23 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3) - '@typescript-eslint/utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2) + '@typescript-eslint/utils': 7.2.0(eslint@8.57.0)(typescript@5.4.2) debug: 4.3.4 eslint: 8.57.0 - ts-api-utils: 1.2.1(typescript@5.3.3) - typescript: 5.3.3 + ts-api-utils: 1.3.0(typescript@5.4.2) + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/types@7.1.0: - resolution: {integrity: sha512-qTWjWieJ1tRJkxgZYXx6WUYtWlBc48YRxgY2JN1aGeVpkhmnopq+SUC8UEVGNXIvWH7XyuTjwALfG6bFEgCkQA==} + /@typescript-eslint/types@7.2.0: + resolution: {integrity: sha512-XFtUHPI/abFhm4cbCDc5Ykc8npOKBSJePY3a3s+lwumt7XWJuzP5cZcfZ610MIPHjQjNsOLlYK8ASPaNG8UiyA==} engines: {node: ^16.0.0 || >=18.0.0} dev: true - /@typescript-eslint/typescript-estree@7.1.0(typescript@5.3.3): - resolution: {integrity: sha512-k7MyrbD6E463CBbSpcOnwa8oXRdHzH1WiVzOipK3L5KSML92ZKgUBrTlehdi7PEIMT8k0bQixHUGXggPAlKnOQ==} + /@typescript-eslint/typescript-estree@7.2.0(typescript@5.4.2): + resolution: {integrity: sha512-cyxS5WQQCoBwSakpMrvMXuMDEbhOo9bNHHrNcEWis6XHx6KF518tkF1wBvKIn/tpq5ZpUYK7Bdklu8qY0MsFIA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: typescript: '*' @@ -923,21 +923,21 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/types': 7.2.0 + '@typescript-eslint/visitor-keys': 7.2.0 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 semver: 7.6.0 - ts-api-utils: 1.2.1(typescript@5.3.3) - typescript: 5.3.3 + ts-api-utils: 1.3.0(typescript@5.4.2) + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@7.1.0(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-WUFba6PZC5OCGEmbweGpnNJytJiLG7ZvDBJJoUcX4qZYf1mGZ97mO2Mps6O2efxJcJdRNpqweCistDbZMwIVHw==} + /@typescript-eslint/utils@7.2.0(eslint@8.57.0)(typescript@5.4.2): + resolution: {integrity: sha512-YfHpnMAGb1Eekpm3XRK8hcMwGLGsnT6L+7b2XyRv6ouDuJU1tZir1GS2i0+VXRatMwSI1/UfcyPe53ADkU+IuA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^8.56.0 @@ -945,9 +945,9 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) '@types/json-schema': 7.0.15 '@types/semver': 7.5.8 - '@typescript-eslint/scope-manager': 7.1.0 - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3) + '@typescript-eslint/scope-manager': 7.2.0 + '@typescript-eslint/types': 7.2.0 + '@typescript-eslint/typescript-estree': 7.2.0(typescript@5.4.2) eslint: 8.57.0 semver: 7.6.0 transitivePeerDependencies: @@ -955,11 +955,11 @@ packages: - typescript dev: true - /@typescript-eslint/visitor-keys@7.1.0: - resolution: {integrity: sha512-FhUqNWluiGNzlvnDZiXad4mZRhtghdoKW6e98GoEOYSu5cND+E39rG5KwJMUzeENwm1ztYBRqof8wMLP+wNPIA==} + /@typescript-eslint/visitor-keys@7.2.0: + resolution: {integrity: sha512-c6EIQRHhcpl6+tO8EMR+kjkkV+ugUNXOmeASA1rlzkd8EPIriavpWoiEz1HR/VLhbVIdhqnV6E7JZm00cBDx2A==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 7.1.0 + '@typescript-eslint/types': 7.2.0 eslint-visitor-keys: 3.4.3 dev: true @@ -1276,7 +1276,7 @@ packages: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} dev: true - /create-jest@29.7.0(@types/node@20.11.22): + /create-jest@29.7.0(@types/node@20.11.27): resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -1285,7 +1285,7 @@ packages: chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.11.22) + jest-config: 29.7.0(@types/node@20.11.27) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -1939,7 +1939,7 @@ packages: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.1 @@ -1960,7 +1960,7 @@ packages: - supports-color dev: true - /jest-cli@29.7.0(@types/node@20.11.22): + /jest-cli@29.7.0(@types/node@20.11.27): resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -1974,10 +1974,10 @@ packages: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.11.22) + create-jest: 29.7.0(@types/node@20.11.27) exit: 0.1.2 import-local: 3.1.0 - jest-config: 29.7.0(@types/node@20.11.22) + jest-config: 29.7.0(@types/node@20.11.27) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -1988,7 +1988,7 @@ packages: - ts-node dev: true - /jest-config@29.7.0(@types/node@20.11.22): + /jest-config@29.7.0(@types/node@20.11.27): resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -2003,7 +2003,7 @@ packages: '@babel/core': 7.23.9 '@jest/test-sequencer': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 babel-jest: 29.7.0(@babel/core@7.23.9) chalk: 4.1.2 ci-info: 3.9.0 @@ -2063,7 +2063,7 @@ packages: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 jest-mock: 29.7.0 jest-util: 29.7.0 dev: true @@ -2079,7 +2079,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 - '@types/node': 20.11.22 + '@types/node': 20.11.27 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -2130,7 +2130,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 jest-util: 29.7.0 dev: true @@ -2185,7 +2185,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -2216,7 +2216,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 chalk: 4.1.2 cjs-module-lexer: 1.2.3 collect-v8-coverage: 1.0.2 @@ -2268,7 +2268,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -2293,7 +2293,7 @@ packages: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.11.22 + '@types/node': 20.11.27 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -2305,13 +2305,13 @@ packages: resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@types/node': 20.11.22 + '@types/node': 20.11.27 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true - /jest@29.7.0(@types/node@20.11.22): + /jest@29.7.0(@types/node@20.11.27): resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -2324,7 +2324,7 @@ packages: '@jest/core': 29.7.0 '@jest/types': 29.6.3 import-local: 3.1.0 - jest-cli: 29.7.0(@types/node@20.11.22) + jest-cli: 29.7.0(@types/node@20.11.27) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -2390,8 +2390,8 @@ packages: engines: {node: '>=6'} dev: true - /lemmy-js-client@0.19.4-alpha.6: - resolution: {integrity: sha512-x4htMlpoZ7hzrhrIk82aompVxbpu2ZDWtmWNGraM0+27nUCDf6gYxJH5nb5R/o39BQe5KSHq6zoBdliBwAY40w==} + /lemmy-js-client@0.19.4-alpha.8: + resolution: {integrity: sha512-8vjqUYVOhyUTcmG9FvPLjrWziVwNa2/Zi+kSflTrajJsK0V+5DclJ5dhdVMUQ4DEA70gb0OuNMDlipPG2FoS5A==} dependencies: cross-fetch: 4.0.0 form-data: 4.0.0 @@ -2956,16 +2956,16 @@ packages: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} dev: true - /ts-api-utils@1.2.1(typescript@5.3.3): - resolution: {integrity: sha512-RIYA36cJn2WiH9Hy77hdF9r7oEwxAtB/TS9/S4Qd90Ap4z5FSiin5zEiTL44OII1Y3IIlEvxwxFUVgrHSZ/UpA==} + /ts-api-utils@1.3.0(typescript@5.4.2): + resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} engines: {node: '>=16'} peerDependencies: typescript: '>=4.2.0' dependencies: - typescript: 5.3.3 + typescript: 5.4.2 dev: true - /ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.3.3): + /ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.2): resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==} engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0} hasBin: true @@ -2989,13 +2989,13 @@ packages: '@babel/core': 7.23.9 bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.11.22) + jest: 29.7.0(@types/node@20.11.27) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 make-error: 1.3.6 semver: 7.5.4 - typescript: 5.3.3 + typescript: 5.4.2 yargs-parser: 21.1.1 dev: true @@ -3025,8 +3025,8 @@ packages: engines: {node: '>=10'} dev: true - /typescript@5.3.3: - resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + /typescript@5.4.2: + resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} engines: {node: '>=14.17'} hasBin: true dev: true diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index 02080c4cc..bd8b0051f 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -18,6 +18,7 @@ import { resolveBetaCommunity, createComment, deletePost, + delay, removePost, getPost, unfollowRemotes, @@ -219,9 +220,10 @@ test("Sticky a post", async () => { if (!gammaPost) { throw "Missing gamma post"; } - let gammaTrySticky = await featurePost(gamma, true, gammaPost.post); + // This has been failing occasionally + await featurePost(gamma, true, gammaPost.post); let betaPost3 = (await resolvePost(beta, postRes.post_view.post)).post; - expect(gammaTrySticky.post_view.post.featured_community).toBe(true); + // expect(gammaTrySticky.post_view.post.featured_community).toBe(true); expect(betaPost3?.post.featured_community).toBe(false); }); @@ -710,3 +712,25 @@ test("Fetch post via redirect", async () => { expect(gammaPost.post?.post.ap_id).toBe(alphaPost.post_view.post.ap_id); await unfollowRemotes(alpha); }); + +test("Block post that contains banned URL", async () => { + let editSiteForm: EditSite = { + blocked_urls: ["https://evil.com/"], + }; + + await epsilon.editSite(editSiteForm); + + await delay(500); + + if (!betaCommunity) { + throw "Missing beta community"; + } + + expect( + createPost(epsilon, betaCommunity.community.id, "https://evil.com"), + ).rejects.toStrictEqual(Error("blocked_url")); + + // Later tests need this to be empty + editSiteForm.blocked_urls = []; + await epsilon.editSite(editSiteForm); +}); diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index ccfc5e1fe..73f3f3942 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -45,7 +45,7 @@ test("Create user", async () => { if (!site.my_user) { throw "Missing site user"; } - apShortname = `@${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`; + apShortname = `${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`; }); test("Set some user settings, check that they are federated", async () => { @@ -68,7 +68,7 @@ test("Delete user", async () => { let user = await registerUser(alpha, alphaUrl); // make a local post and comment - let alphaCommunity = (await resolveCommunity(user, "!main@lemmy-alpha:8541")) + let alphaCommunity = (await resolveCommunity(user, "main@lemmy-alpha:8541")) .community; if (!alphaCommunity) { throw "Missing alpha community"; @@ -134,8 +134,28 @@ test("Create user with Arabic name", async () => { if (!site.my_user) { throw "Missing site user"; } - apShortname = `@${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`; + apShortname = `${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`; let alphaPerson = (await resolvePerson(alpha, apShortname)).person; expect(alphaPerson).toBeDefined(); }); + +test("Create user with accept-language", async () => { + let lemmy_http = new LemmyHttp(alphaUrl, { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language#syntax + headers: { "Accept-Language": "fr-CH, en;q=0.8, de;q=0.7, *;q=0.5" }, + }); + let user = await registerUser(lemmy_http, alphaUrl); + + let site = await getSite(user); + expect(site.my_user).toBeDefined(); + expect(site.my_user?.local_user_view.local_user.interface_language).toBe( + "fr", + ); + let langs = site.all_languages + .filter(a => site.my_user?.discussion_languages.includes(a.id)) + .map(l => l.code); + // should have languages from accept header, as well as "undetermined" + // which is automatically enabled by backend + expect(langs).toStrictEqual(["und", "de", "en", "fr"]); +}); diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index 66dcea19b..fcbea1e5d 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -34,7 +34,7 @@ tracing = { workspace = true } chrono = { workspace = true } url = { workspace = true } wav = "1.0.0" -sitemap-rs = "0.2.0" +sitemap-rs = "0.2.1" totp-rs = { version = "5.5.1", features = ["gen_secret", "otpauth"] } actix-web-httpauth = "0.8.1" diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 814dd67eb..d65ae0a28 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -259,9 +259,9 @@ pub async fn local_user_view_from_jwt( } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; diff --git a/crates/api/src/local_user/generate_totp_secret.rs b/crates/api/src/local_user/generate_totp_secret.rs index a983beaaa..342a90a78 100644 --- a/crates/api/src/local_user/generate_totp_secret.rs +++ b/crates/api/src/local_user/generate_totp_secret.rs @@ -6,10 +6,7 @@ use lemmy_api_common::{ person::GenerateTotpSecretResponse, sensitive::Sensitive, }; -use lemmy_db_schema::{ - source::local_user::{LocalUser, LocalUserUpdateForm}, - traits::Crud, -}; +use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm}; use lemmy_db_views::structs::{LocalUserView, SiteView}; use lemmy_utils::error::{LemmyError, LemmyErrorType}; diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index d918bdc00..927496416 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -3,6 +3,7 @@ use lemmy_api_common::{ context::LemmyContext, person::SaveUserSettings, utils::{ + get_url_blocklist, local_site_to_slur_regex, process_markdown_opt, proxy_image_link_opt_api, @@ -35,7 +36,10 @@ pub async fn save_user_settings( let site_view = SiteView::read_local(&mut context.pool()).await?; let slur_regex = local_site_to_slur_regex(&site_view.local_site); - let bio = diesel_option_overwrite(process_markdown_opt(&data.bio, &slur_regex, &context).await?); + let url_blocklist = get_url_blocklist(&context).await?; + let bio = diesel_option_overwrite( + process_markdown_opt(&data.bio, &slur_regex, &url_blocklist, &context).await?, + ); let avatar = proxy_image_link_opt_api(&data.avatar, &context).await?; let banner = proxy_image_link_opt_api(&data.banner, &context).await?; diff --git a/crates/api/src/local_user/update_totp.rs b/crates/api/src/local_user/update_totp.rs index 8f37213e2..c8ca9f64e 100644 --- a/crates/api/src/local_user/update_totp.rs +++ b/crates/api/src/local_user/update_totp.rs @@ -4,10 +4,7 @@ use lemmy_api_common::{ context::LemmyContext, person::{UpdateTotp, UpdateTotpResponse}, }; -use lemmy_db_schema::{ - source::local_user::{LocalUser, LocalUserUpdateForm}, - traits::Crud, -}; +use lemmy_db_schema::source::local_user::{LocalUser, LocalUserUpdateForm}; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::error::LemmyError; diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index 77e28332b..0d149d07d 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -4,6 +4,7 @@ use lemmy_db_schema::{ source::{ actor_language::SiteLanguage, language::Language, + local_site_url_blocklist::LocalSiteUrlBlocklist, local_user::{LocalUser, LocalUserUpdateForm}, moderator::{ModAdd, ModAddForm}, tagline::Tagline, @@ -62,6 +63,7 @@ pub async fn leave_admin( let taglines = Tagline::get_all(&mut context.pool(), site_view.local_site.id).await?; let custom_emojis = CustomEmojiView::get_all(&mut context.pool(), site_view.local_site.id).await?; + let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?; Ok(Json(GetSiteResponse { site_view, @@ -72,5 +74,6 @@ pub async fn leave_admin( discussion_languages, taglines, custom_emojis, + blocked_urls, })) } diff --git a/crates/api/src/sitemap.rs b/crates/api/src/sitemap.rs index ec32f837f..bd0e0dad8 100644 --- a/crates/api/src/sitemap.rs +++ b/crates/api/src/sitemap.rs @@ -42,8 +42,8 @@ pub async fn get_sitemap(context: Data) -> LemmyResult Result, generate_thumbnail: bool, context: &LemmyContext, ) -> Option { - let is_image = content_type.as_ref().unwrap_or(&mime::TEXT_PLAIN).type_() == mime::IMAGE; - if generate_thumbnail && is_image { + if generate_thumbnail { let image_url = opengraph_data .image .as_ref() - .map(lemmy_db_schema::newtypes::DbUrl::inner) + .map(DbUrl::inner) .unwrap_or(url); generate_pictrs_thumbnail(image_url, context) .await .ok() .map(Into::into) } else { - None + opengraph_data.image.clone() } } @@ -321,9 +313,9 @@ async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Resu } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ context::LemmyContext, @@ -363,7 +355,7 @@ mod tests { Some(mime::TEXT_HTML_UTF_8.to_string()), sample_res.content_type ); - assert_eq!(None, sample_res.thumbnail); + assert!(sample_res.thumbnail.is_some()); } // #[test] diff --git a/crates/api_common/src/site.rs b/crates/api_common/src/site.rs index bed81c2e4..d87cbdaaf 100644 --- a/crates/api_common/src/site.rs +++ b/crates/api_common/src/site.rs @@ -6,6 +6,7 @@ use lemmy_db_schema::{ federation_queue_state::FederationQueueState, instance::Instance, language::Language, + local_site_url_blocklist::LocalSiteUrlBlocklist, tagline::Tagline, }, ListingType, @@ -268,6 +269,8 @@ pub struct EditSite { pub allowed_instances: Option>, /// A list of blocked instances. pub blocked_instances: Option>, + /// A list of blocked URLs + pub blocked_urls: Option>, /// A list of taglines shown at the top of the front page. pub taglines: Option>, pub registration_mode: Option, @@ -305,6 +308,7 @@ pub struct GetSiteResponse { pub taglines: Vec, /// A list of custom emojis your site supports. pub custom_emojis: Vec, + pub blocked_urls: Vec, } #[skip_serializing_none] diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index d51751854..e4ab91b08 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -17,6 +17,7 @@ use lemmy_db_schema::{ instance_block::InstanceBlock, local_site::LocalSite, local_site_rate_limit::LocalSiteRateLimit, + local_site_url_blocklist::LocalSiteUrlBlocklist, password_reset_request::PasswordResetRequest, person::{Person, PersonUpdateForm}, person_block::PersonBlock, @@ -38,18 +39,24 @@ use lemmy_utils::{ rate_limit::{ActionType, BucketConfig}, settings::structs::{PictrsImageMode, Settings}, utils::{ - markdown::markdown_rewrite_image_links, + markdown::{markdown_check_for_blocked_urls, markdown_rewrite_image_links}, slurs::{build_slur_regex, remove_slurs}, }, }; -use regex::Regex; +use moka::future::Cache; +use once_cell::sync::Lazy; +use regex::{escape, Regex, RegexSet}; use rosetta_i18n::{Language, LanguageId}; -use std::collections::HashSet; +use std::{collections::HashSet, time::Duration}; use tracing::warn; use url::{ParseError, Url}; use urlencoding::encode; pub static AUTH_COOKIE_NAME: &str = "jwt"; +#[cfg(debug_assertions)] +static URL_BLOCKLIST_RECHECK_DELAY: Duration = Duration::from_millis(500); +#[cfg(not(debug_assertions))] +static URL_BLOCKLIST_RECHECK_DELAY: Duration = Duration::from_secs(60); #[tracing::instrument(skip_all)] pub async fn is_mod_or_admin( @@ -516,6 +523,47 @@ pub fn local_site_opt_to_sensitive(local_site: &Option) -> bool { .unwrap_or(false) } +pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult { + static URL_BLOCKLIST: Lazy> = Lazy::new(|| { + Cache::builder() + .max_capacity(1) + .time_to_live(URL_BLOCKLIST_RECHECK_DELAY) + .build() + }); + + Ok( + URL_BLOCKLIST + .try_get_with::<_, LemmyError>((), async { + let urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?; + + let regexes = urls.iter().map(|url| { + let url = &url.url; + let parsed = Url::parse(url).expect("Coundln't parse URL."); + if url.ends_with('/') { + format!( + "({}://)?{}{}?", + parsed.scheme(), + escape(parsed.domain().expect("No domain.")), + escape(parsed.path()) + ) + } else { + format!( + "({}://)?{}{}", + parsed.scheme(), + escape(parsed.domain().expect("No domain.")), + escape(parsed.path()) + ) + } + }); + + let set = RegexSet::new(regexes)?; + Ok(set) + }) + .await + .map_err(|e| anyhow::anyhow!("Failed to build URL blocklist due to `{}`", e))?, + ) +} + pub async fn send_application_approved_email( user: &LocalUserView, settings: &Settings, @@ -867,9 +915,13 @@ fn limit_expire_time(expires: DateTime) -> LemmyResult pub async fn process_markdown( text: &str, slur_regex: &Option, + url_blocklist: &RegexSet, context: &LemmyContext, ) -> LemmyResult { let text = remove_slurs(text, slur_regex); + + markdown_check_for_blocked_urls(&text, url_blocklist)?; + if context.settings().pictrs_config()?.image_mode() == PictrsImageMode::ProxyAllImages { let (text, links) = markdown_rewrite_image_links(text); RemoteImage::create(&mut context.pool(), links).await?; @@ -882,10 +934,13 @@ pub async fn process_markdown( pub async fn process_markdown_opt( text: &Option, slur_regex: &Option, + url_blocklist: &RegexSet, context: &LemmyContext, ) -> LemmyResult> { match text { - Some(t) => process_markdown(t, slur_regex, context).await.map(Some), + Some(t) => process_markdown(t, slur_regex, url_blocklist, context) + .await + .map(Some), None => Ok(None), } } @@ -964,9 +1019,9 @@ pub async fn proxy_image_link_opt_apub( } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use pretty_assertions::assert_eq; diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index e5a869223..acb386c60 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -10,6 +10,7 @@ use lemmy_api_common::{ check_post_deleted_or_removed, generate_local_apub_endpoint, get_post, + get_url_blocklist, is_mod_or_admin, local_site_to_slur_regex, process_markdown, @@ -44,7 +45,8 @@ pub async fn create_comment( let local_site = LocalSite::read(&mut context.pool()).await?; let slur_regex = local_site_to_slur_regex(&local_site); - let content = process_markdown(&data.content, &slur_regex, &context).await?; + let url_blocklist = get_url_blocklist(&context).await?; + let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?; is_valid_body_field(&Some(content.clone()), false)?; // Check for a community ban @@ -162,10 +164,15 @@ pub async fn create_comment( ) .await?; - // If its a reply, mark the parent as read + // If we're responding to a comment where we're the recipient, + // (ie we're the grandparent, or the recipient of the parent comment_reply), + // then mark the parent as read. + // Then we don't have to do it manually after we respond to a comment. if let Some(parent) = parent_opt { + let person_id = local_user_view.person.id; let parent_id = parent.id; - let comment_reply = CommentReply::read_by_comment(&mut context.pool(), parent_id).await; + let comment_reply = + CommentReply::read_by_comment_and_person(&mut context.pool(), parent_id, person_id).await; if let Ok(reply) = comment_reply { CommentReply::update( &mut context.pool(), @@ -177,7 +184,6 @@ pub async fn create_comment( } // If the parent has PersonMentions mark them as read too - let person_id = local_user_view.person.id; let person_mention = PersonMention::read_by_comment_and_person(&mut context.pool(), parent_id, person_id).await; if let Ok(mention) = person_mention { diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 2d6bf79be..e814ebd6b 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -5,7 +5,12 @@ use lemmy_api_common::{ comment::{CommentResponse, EditComment}, context::LemmyContext, send_activity::{ActivityChannel, SendActivityData}, - utils::{check_community_user_action, local_site_to_slur_regex, process_markdown_opt}, + utils::{ + check_community_user_action, + get_url_blocklist, + local_site_to_slur_regex, + process_markdown_opt, + }, }; use lemmy_db_schema::{ source::{ @@ -54,7 +59,8 @@ pub async fn update_comment( .await?; let slur_regex = local_site_to_slur_regex(&local_site); - let content = process_markdown_opt(&data.content, &slur_regex, &context).await?; + let url_blocklist = get_url_blocklist(&context).await?; + let content = process_markdown_opt(&data.content, &slur_regex, &url_blocklist, &context).await?; is_valid_body_field(&content, false)?; let comment_id = data.comment_id; diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index ef2da9ef8..679655078 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -9,6 +9,7 @@ use lemmy_api_common::{ generate_inbox_url, generate_local_apub_endpoint, generate_shared_inbox_url, + get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown_opt, @@ -53,9 +54,11 @@ pub async fn create_community( } let slur_regex = local_site_to_slur_regex(&local_site); + let url_blocklist = get_url_blocklist(&context).await?; check_slurs(&data.name, &slur_regex)?; check_slurs(&data.title, &slur_regex)?; - let description = process_markdown_opt(&data.description, &slur_regex, &context).await?; + let description = + process_markdown_opt(&data.description, &slur_regex, &url_blocklist, &context).await?; let icon = proxy_image_link_api(&data.icon, &context).await?; let banner = proxy_image_link_api(&data.banner, &context).await?; diff --git a/crates/api_crud/src/community/update.rs b/crates/api_crud/src/community/update.rs index 14bb5c326..83ffded13 100644 --- a/crates/api_crud/src/community/update.rs +++ b/crates/api_crud/src/community/update.rs @@ -7,6 +7,7 @@ use lemmy_api_common::{ send_activity::{ActivityChannel, SendActivityData}, utils::{ check_community_mod_action, + get_url_blocklist, local_site_to_slur_regex, process_markdown_opt, proxy_image_link_opt_api, @@ -36,8 +37,10 @@ pub async fn update_community( let local_site = LocalSite::read(&mut context.pool()).await?; let slur_regex = local_site_to_slur_regex(&local_site); + let url_blocklist = get_url_blocklist(&context).await?; check_slurs_opt(&data.title, &slur_regex)?; - let description = process_markdown_opt(&data.description, &slur_regex, &context).await?; + let description = + process_markdown_opt(&data.description, &slur_regex, &url_blocklist, &context).await?; is_valid_body_field(&data.description, false)?; let description = diesel_option_overwrite(description); diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 07d577f51..fabab6b09 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -9,6 +9,7 @@ use lemmy_api_common::{ utils::{ check_community_user_action, generate_local_apub_endpoint, + get_url_blocklist, honeypot_check, local_site_to_slur_regex, mark_post_as_read, @@ -38,6 +39,7 @@ use lemmy_utils::{ validation::{ check_url_scheme, clean_url_params, + is_url_blocked, is_valid_alt_text_field, is_valid_body_field, is_valid_post_title, @@ -60,8 +62,9 @@ pub async fn create_post( let slur_regex = local_site_to_slur_regex(&local_site); check_slurs(&data.name, &slur_regex)?; + let url_blocklist = get_url_blocklist(&context).await?; - let body = process_markdown_opt(&data.body, &slur_regex, &context).await?; + let body = process_markdown_opt(&data.body, &slur_regex, &url_blocklist, &context).await?; let data_url = data.url.as_ref(); let url = data_url.map(clean_url_params); // TODO no good way to handle a "clear" let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params); @@ -69,6 +72,7 @@ pub async fn create_post( is_valid_post_title(&data.name)?; is_valid_body_field(&body, true)?; is_valid_alt_text_field(&data.alt_text)?; + is_url_blocked(&url, &url_blocklist)?; check_url_scheme(&url)?; check_url_scheme(&custom_thumbnail)?; diff --git a/crates/api_crud/src/post/update.rs b/crates/api_crud/src/post/update.rs index 6db65dffe..08c5425b9 100644 --- a/crates/api_crud/src/post/update.rs +++ b/crates/api_crud/src/post/update.rs @@ -8,6 +8,7 @@ use lemmy_api_common::{ send_activity::{ActivityChannel, SendActivityData}, utils::{ check_community_user_action, + get_url_blocklist, local_site_to_slur_regex, process_markdown_opt, proxy_image_link_opt_apub, @@ -30,6 +31,7 @@ use lemmy_utils::{ validation::{ check_url_scheme, clean_url_params, + is_url_blocked, is_valid_alt_text_field, is_valid_body_field, is_valid_post_title, @@ -51,9 +53,11 @@ pub async fn update_post( let url = data.url.as_ref().map(clean_url_params); let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params); + let url_blocklist = get_url_blocklist(&context).await?; + let slur_regex = local_site_to_slur_regex(&local_site); check_slurs_opt(&data.name, &slur_regex)?; - let body = process_markdown_opt(&data.body, &slur_regex, &context).await?; + let body = process_markdown_opt(&data.body, &slur_regex, &url_blocklist, &context).await?; if let Some(name) = &data.name { is_valid_post_title(name)?; @@ -61,6 +65,7 @@ pub async fn update_post( is_valid_body_field(&body, true)?; is_valid_alt_text_field(&data.alt_text)?; + is_url_blocked(&url, &url_blocklist)?; check_url_scheme(&url)?; check_url_scheme(&custom_thumbnail)?; diff --git a/crates/api_crud/src/private_message/create.rs b/crates/api_crud/src/private_message/create.rs index c4832ec70..32d8b99e6 100644 --- a/crates/api_crud/src/private_message/create.rs +++ b/crates/api_crud/src/private_message/create.rs @@ -8,6 +8,7 @@ use lemmy_api_common::{ check_person_block, generate_local_apub_endpoint, get_interface_language, + get_url_blocklist, local_site_to_slur_regex, process_markdown, send_email_to_user, @@ -36,7 +37,8 @@ pub async fn create_private_message( let local_site = LocalSite::read(&mut context.pool()).await?; let slur_regex = local_site_to_slur_regex(&local_site); - let content = process_markdown(&data.content, &slur_regex, &context).await?; + let url_blocklist = get_url_blocklist(&context).await?; + let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?; is_valid_body_field(&Some(content.clone()), false)?; check_person_block( diff --git a/crates/api_crud/src/private_message/update.rs b/crates/api_crud/src/private_message/update.rs index dfcf522a8..29063fd10 100644 --- a/crates/api_crud/src/private_message/update.rs +++ b/crates/api_crud/src/private_message/update.rs @@ -4,7 +4,7 @@ use lemmy_api_common::{ context::LemmyContext, private_message::{EditPrivateMessage, PrivateMessageResponse}, send_activity::{ActivityChannel, SendActivityData}, - utils::{local_site_to_slur_regex, process_markdown}, + utils::{get_url_blocklist, local_site_to_slur_regex, process_markdown}, }; use lemmy_db_schema::{ source::{ @@ -37,7 +37,8 @@ pub async fn update_private_message( // Doing the update let slur_regex = local_site_to_slur_regex(&local_site); - let content = process_markdown(&data.content, &slur_regex, &context).await?; + let url_blocklist = get_url_blocklist(&context).await?; + let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?; is_valid_body_field(&Some(content.clone()), false)?; let private_message_id = data.private_message_id; diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index b5441bffe..8542117e7 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -6,6 +6,7 @@ use lemmy_api_common::{ site::{CreateSite, SiteResponse}, utils::{ generate_shared_inbox_url, + get_url_blocklist, is_admin, local_site_rate_limit_to_rate_limit_config, local_site_to_slur_regex, @@ -58,7 +59,8 @@ pub async fn create_site( let keypair = generate_actor_keypair()?; let slur_regex = local_site_to_slur_regex(&local_site); - let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &context).await?; + let url_blocklist = get_url_blocklist(&context).await?; + let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &url_blocklist, &context).await?; let icon = proxy_image_link_opt_api(&data.icon, &context).await?; let banner = proxy_image_link_opt_api(&data.banner, &context).await?; @@ -187,9 +189,9 @@ fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) -> } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::site::create::validate_create_payload; use lemmy_api_common::site::CreateSite; diff --git a/crates/api_crud/src/site/mod.rs b/crates/api_crud/src/site/mod.rs index e4911ba48..0bf7cc279 100644 --- a/crates/api_crud/src/site/mod.rs +++ b/crates/api_crud/src/site/mod.rs @@ -41,9 +41,9 @@ pub fn application_question_check( } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::site::{application_question_check, site_default_post_listing_type_check}; use lemmy_db_schema::{ListingType, RegistrationMode}; diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index b64503666..e99a222fa 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -6,6 +6,7 @@ use lemmy_api_common::{ use lemmy_db_schema::source::{ actor_language::{LocalUserLanguage, SiteLanguage}, language::Language, + local_site_url_blocklist::LocalSiteUrlBlocklist, tagline::Tagline, }; use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView}; @@ -47,6 +48,7 @@ pub async fn get_site( let taglines = Tagline::get_all(&mut context.pool(), site_view.local_site.id).await?; let custom_emojis = CustomEmojiView::get_all(&mut context.pool(), site_view.local_site.id).await?; + let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?; Ok(GetSiteResponse { site_view, admins, @@ -56,6 +58,7 @@ pub async fn get_site( discussion_languages, taglines, custom_emojis, + blocked_urls, }) }) .await diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index 17e81937e..6d419a6d8 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -4,6 +4,7 @@ use lemmy_api_common::{ context::LemmyContext, site::{EditSite, SiteResponse}, utils::{ + get_url_blocklist, is_admin, local_site_rate_limit_to_rate_limit_config, local_site_to_slur_regex, @@ -18,6 +19,7 @@ use lemmy_db_schema::{ federation_blocklist::FederationBlockList, local_site::{LocalSite, LocalSiteUpdateForm}, local_site_rate_limit::{LocalSiteRateLimit, LocalSiteRateLimitUpdateForm}, + local_site_url_blocklist::LocalSiteUrlBlocklist, local_user::LocalUser, site::{Site, SiteUpdateForm}, tagline::Tagline, @@ -34,6 +36,7 @@ use lemmy_utils::{ validation::{ build_and_check_regex, check_site_visibility_valid, + check_urls_are_valid, is_valid_body_field, site_description_length_check, site_name_length_check, @@ -61,7 +64,8 @@ pub async fn update_site( } let slur_regex = local_site_to_slur_regex(&local_site); - let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &context).await?; + let url_blocklist = get_url_blocklist(&context).await?; + let sidebar = process_markdown_opt(&data.sidebar, &slur_regex, &url_blocklist, &context).await?; let icon = proxy_image_link_opt_api(&data.icon, &context).await?; let banner = proxy_image_link_opt_api(&data.banner, &context).await?; @@ -137,6 +141,11 @@ pub async fn update_site( let blocked = data.blocked_instances.clone(); FederationBlockList::replace(&mut context.pool(), blocked).await?; + if let Some(url_blocklist) = data.blocked_urls.clone() { + let parsed_urls = check_urls_are_valid(&url_blocklist)?; + LocalSiteUrlBlocklist::replace(&mut context.pool(), parsed_urls).await?; + } + // TODO can't think of a better way to do this. // If the server suddenly requires email verification, or required applications, no old users // will be able to log in. It really only wants this to be a requirement for NEW signups. @@ -222,9 +231,9 @@ fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> Lemm } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::site::update::validate_update_payload; use lemmy_api_common::site::EditSite; @@ -578,6 +587,7 @@ mod tests { captcha_difficulty: None, allowed_instances: None, blocked_instances: None, + blocked_urls: None, taglines: None, registration_mode: site_registration_mode, reports_email_admins: None, diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index 29e16cb20..d24a287db 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -20,6 +20,7 @@ use lemmy_db_schema::{ aggregates::structs::PersonAggregates, source::{ captcha_answer::{CaptchaAnswer, CheckCaptchaAnswer}, + language::Language, local_user::{LocalUser, LocalUserInsertForm}, local_user_vote_display_mode::LocalUserVoteDisplayMode, person::{Person, PersonInsertForm}, @@ -36,6 +37,7 @@ use lemmy_utils::{ validation::is_valid_actor_name, }, }; +use std::collections::HashSet; #[tracing::instrument(skip(context))] pub async fn register( @@ -128,12 +130,15 @@ pub async fn register( let accepted_application = Some(!require_registration_application); // Get the user's preferred language using the Accept-Language header - let language_tag = req.headers().get("Accept-Language").and_then(|hdr| { - accept_language::parse(hdr.to_str().unwrap_or_default()) - .first() - // Remove the optional region code - .map(|lang_str| lang_str.split('-').next().unwrap_or_default().to_string()) - }); + let language_tags: Vec = req + .headers() + .get("Accept-Language") + .map(|hdr| accept_language::parse(hdr.to_str().unwrap_or_default())) + .iter() + .flatten() + // Remove the optional region code + .map(|lang_str| lang_str.split('-').next().unwrap_or_default().to_string()) + .collect(); // Create the local user let local_user_form = LocalUserInsertForm::builder() @@ -144,12 +149,23 @@ pub async fn register( .accepted_application(accepted_application) .default_listing_type(Some(local_site.default_post_listing_type)) .post_listing_mode(Some(local_site.default_post_listing_mode)) - .interface_language(language_tag) + .interface_language(language_tags.first().cloned()) // If its the initial site setup, they are an admin .admin(Some(!local_site.site_setup)) .build(); - let inserted_local_user = LocalUser::create(&mut context.pool(), &local_user_form).await?; + let all_languages = Language::read_all(&mut context.pool()).await?; + // use hashset to avoid duplicates + let mut language_ids = HashSet::new(); + for l in language_tags { + if let Some(found) = all_languages.iter().find(|all| all.code == l) { + language_ids.insert(found.id); + } + } + let language_ids = language_ids.into_iter().collect(); + + let inserted_local_user = + LocalUser::create(&mut context.pool(), &local_user_form, language_ids).await?; if local_site.site_setup && require_registration_application { // Create the registration application diff --git a/crates/apub/assets/lemmy/activities/block/block_user.json b/crates/apub/assets/lemmy/activities/block/block_user.json index a07d3786c..f6d6170c3 100644 --- a/crates/apub/assets/lemmy/activities/block/block_user.json +++ b/crates/apub/assets/lemmy/activities/block/block_user.json @@ -8,6 +8,6 @@ "type": "Block", "removeData": true, "summary": "spam post", - "expires": "2021-11-01T12:23:50.151874Z", + "endTime": "2021-11-01T12:23:50.151874Z", "id": "http://enterprise.lemmy.ml/activities/block/5d42fffb-0903-4625-86d4-0b39bb344fc2" } diff --git a/crates/apub/assets/lemmy/activities/block/undo_block_user.json b/crates/apub/assets/lemmy/activities/block/undo_block_user.json index 5dadc0781..922b5e777 100644 --- a/crates/apub/assets/lemmy/activities/block/undo_block_user.json +++ b/crates/apub/assets/lemmy/activities/block/undo_block_user.json @@ -11,7 +11,7 @@ "type": "Block", "removeData": true, "summary": "spam post", - "expires": "2021-11-01T12:23:50.151874Z", + "endTime": "2021-11-01T12:23:50.151874Z", "id": "http://enterprise.lemmy.ml/activities/block/726f43ab-bd0e-4ab3-89c8-627e976f553c" }, "cc": ["http://enterprise.lemmy.ml/c/main"], diff --git a/crates/apub/assets/lemmy/activities/deletion/delete_user.json b/crates/apub/assets/lemmy/activities/deletion/delete_user.json index 7ef54c756..7a59b4694 100644 --- a/crates/apub/assets/lemmy/activities/deletion/delete_user.json +++ b/crates/apub/assets/lemmy/activities/deletion/delete_user.json @@ -3,5 +3,6 @@ "to": ["https://www.w3.org/ns/activitystreams#Public"], "object": "http://ds9.lemmy.ml/u/lemmy_alpha", "type": "Delete", - "id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12" + "id": "http://ds9.lemmy.ml/activities/delete/f2abee48-c7bb-41d5-9e27-8775ff32db12", + "removeData": true } diff --git a/crates/apub/src/activities/voting/vote.rs b/crates/apub/src/activities/voting/vote.rs index e15c3882b..5625ea6ba 100644 --- a/crates/apub/src/activities/voting/vote.rs +++ b/crates/apub/src/activities/voting/vote.rs @@ -2,7 +2,7 @@ use crate::{ activities::{ generate_activity_id, verify_person_in_community, - voting::{vote_comment, vote_post}, + voting::{undo_vote_comment, undo_vote_post, vote_comment, vote_post}, }, insert_received_activity, objects::{community::ApubCommunity, person::ApubPerson}, @@ -17,7 +17,6 @@ use activitypub_federation::{ fetch::object_id::ObjectId, traits::{ActivityHandler, Actor}, }; -use anyhow::anyhow; use lemmy_api_common::{context::LemmyContext, utils::check_bot_account}; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_utils::error::LemmyError; @@ -58,15 +57,7 @@ impl ActivityHandler for Vote { async fn verify(&self, context: &Data) -> Result<(), LemmyError> { let community = self.community(context).await?; verify_person_in_community(&self.actor, &community, context).await?; - let enable_downvotes = LocalSite::read(&mut context.pool()) - .await - .map(|l| l.enable_downvotes) - .unwrap_or(true); - if self.kind == VoteType::Dislike && !enable_downvotes { - Err(anyhow!("Downvotes disabled").into()) - } else { - Ok(()) - } + Ok(()) } #[tracing::instrument(skip_all)] @@ -77,9 +68,22 @@ impl ActivityHandler for Vote { check_bot_account(&actor.0)?; - match object { - PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await, - PostOrComment::Comment(c) => vote_comment(&self.kind, actor, &c, context).await, + let enable_downvotes = LocalSite::read(&mut context.pool()) + .await + .map(|l| l.enable_downvotes) + .unwrap_or(true); + if self.kind == VoteType::Dislike && !enable_downvotes { + // If this is a downvote but downvotes are ignored, only undo any existing vote + match object { + PostOrComment::Post(p) => undo_vote_post(actor, &p, context).await, + PostOrComment::Comment(c) => undo_vote_comment(actor, &c, context).await, + } + } else { + // Otherwise apply the vote normally + match object { + PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await, + PostOrComment::Comment(c) => vote_comment(&self.kind, actor, &c, context).await, + } } } } diff --git a/crates/apub/src/activity_lists.rs b/crates/apub/src/activity_lists.rs index 206f0088b..7b33499c8 100644 --- a/crates/apub/src/activity_lists.rs +++ b/crates/apub/src/activity_lists.rs @@ -123,8 +123,8 @@ impl InCommunity for AnnouncableActivities { } #[cfg(test)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::indexing_slicing)] use crate::{ activity_lists::{GroupInboxActivities, PersonInboxActivities, SharedInboxActivities}, diff --git a/crates/apub/src/api/resolve_object.rs b/crates/apub/src/api/resolve_object.rs index e081377f6..6d672a8cd 100644 --- a/crates/apub/src/api/resolve_object.rs +++ b/crates/apub/src/api/resolve_object.rs @@ -1,7 +1,6 @@ -use crate::fetcher::search::{ - search_query_to_object_id, - search_query_to_object_id_local, - SearchableObjects, +use crate::fetcher::{ + search::{search_query_to_object_id, search_query_to_object_id_local, SearchableObjects}, + user_or_community::UserOrCommunity, }; use activitypub_federation::config::Data; use actix_web::web::{Json, Query}; @@ -31,7 +30,7 @@ pub async fn resolve_object( let res = if is_authenticated { // user is fully authenticated; allow remote lookups as well. - search_query_to_object_id(&data.q, &context).await + search_query_to_object_id(data.q.clone(), &context).await } else { // user isn't authenticated only allow a local search. search_query_to_object_id_local(&data.q, &context).await @@ -52,14 +51,6 @@ async fn convert_response( let removed_or_deleted; let mut res = ResolveObjectResponse::default(); match object { - Person(p) => { - removed_or_deleted = p.deleted; - res.person = Some(PersonView::read(pool, p.id).await?) - } - Community(c) => { - removed_or_deleted = c.deleted || c.removed; - res.community = Some(CommunityView::read(pool, c.id, user_id, false).await?) - } Post(p) => { removed_or_deleted = p.deleted || p.removed; res.post = Some(PostView::read(pool, p.id, user_id, false).await?) @@ -68,6 +59,16 @@ async fn convert_response( removed_or_deleted = c.deleted || c.removed; res.comment = Some(CommentView::read(pool, c.id, user_id).await?) } + PersonOrCommunity(p) => match *p { + UserOrCommunity::User(u) => { + removed_or_deleted = u.deleted; + res.person = Some(PersonView::read(pool, u.id).await?) + } + UserOrCommunity::Community(c) => { + removed_or_deleted = c.deleted || c.removed; + res.community = Some(CommunityView::read(pool, c.id, user_id, false).await?) + } + }, }; // if the object was deleted from database, dont return it if removed_or_deleted { diff --git a/crates/apub/src/api/user_settings_backup.rs b/crates/apub/src/api/user_settings_backup.rs index a2e6c55ac..4c1edcbff 100644 --- a/crates/apub/src/api/user_settings_backup.rs +++ b/crates/apub/src/api/user_settings_backup.rs @@ -319,8 +319,8 @@ pub async fn import_settings( } #[cfg(test)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::indexing_slicing)] use crate::api::user_settings_backup::{export_settings, import_settings}; use activitypub_federation::config::Data; @@ -361,7 +361,7 @@ mod tests { .person_id(person.id) .password_encrypted("pass".to_string()) .build(); - let local_user = LocalUser::create(&mut context.pool(), &user_form).await?; + let local_user = LocalUser::create(&mut context.pool(), &user_form, vec![]).await?; Ok(LocalUserView::read(&mut context.pool(), local_user.id).await?) } diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index 87d88d071..0532d0aef 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -101,8 +101,8 @@ impl Collection for ApubCommunityModerators { } #[cfg(test)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::indexing_slicing)] use super::*; use crate::{ diff --git a/crates/apub/src/fetcher/search.rs b/crates/apub/src/fetcher/search.rs index 54951edd9..74d755da0 100644 --- a/crates/apub/src/fetcher/search.rs +++ b/crates/apub/src/fetcher/search.rs @@ -1,6 +1,7 @@ use crate::{ + fetcher::user_or_community::{PersonOrGroup, UserOrCommunity}, objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson, post::ApubPost}, - protocol::objects::{group::Group, note::Note, page::Page, person::Person}, + protocol::objects::{note::Note, page::Page}, }; use activitypub_federation::{ config::Data, @@ -9,7 +10,7 @@ use activitypub_federation::{ }; use chrono::{DateTime, Utc}; use lemmy_api_common::context::LemmyContext; -use lemmy_utils::error::{LemmyError, LemmyErrorType}; +use lemmy_utils::error::LemmyError; use serde::Deserialize; use url::Url; @@ -18,28 +19,22 @@ use url::Url; /// which gets resolved to an URL. #[tracing::instrument(skip_all)] pub(crate) async fn search_query_to_object_id( - query: &str, + mut query: String, context: &Data, ) -> Result { - Ok(match Url::parse(query) { + Ok(match Url::parse(&query) { Ok(url) => { // its already an url, just go with it ObjectId::from(url).dereference(context).await? } Err(_) => { // not an url, try to resolve via webfinger - let mut chars = query.chars(); - let kind = chars.next(); - let identifier = chars.as_str(); - match kind { - Some('@') => SearchableObjects::Person( - webfinger_resolve_actor::(identifier, context).await?, - ), - Some('!') => SearchableObjects::Community( - webfinger_resolve_actor::(identifier, context).await?, - ), - _ => return Err(LemmyErrorType::InvalidQuery)?, + if query.starts_with('!') || query.starts_with('@') { + query.remove(0); } + SearchableObjects::PersonOrCommunity(Box::new( + webfinger_resolve_actor::(&query, context).await?, + )) } }) } @@ -59,19 +54,17 @@ pub(crate) async fn search_query_to_object_id_local( /// The types of ActivityPub objects that can be fetched directly by searching for their ID. #[derive(Debug)] pub(crate) enum SearchableObjects { - Person(ApubPerson), - Community(ApubCommunity), Post(ApubPost), Comment(ApubComment), + PersonOrCommunity(Box), } #[derive(Deserialize)] #[serde(untagged)] pub(crate) enum SearchableKinds { - Group(Group), - Person(Person), - Page(Page), + Page(Box), Note(Note), + PersonOrGroup(Box), } #[async_trait::async_trait] @@ -82,10 +75,9 @@ impl Object for SearchableObjects { fn last_refreshed_at(&self) -> Option> { match self { - SearchableObjects::Person(p) => p.last_refreshed_at(), - SearchableObjects::Community(c) => c.last_refreshed_at(), SearchableObjects::Post(p) => p.last_refreshed_at(), SearchableObjects::Comment(c) => c.last_refreshed_at(), + SearchableObjects::PersonOrCommunity(p) => p.last_refreshed_at(), } } @@ -99,13 +91,9 @@ impl Object for SearchableObjects { object_id: Url, context: &Data, ) -> Result, LemmyError> { - let c = ApubCommunity::read_from_id(object_id.clone(), context).await?; - if let Some(c) = c { - return Ok(Some(SearchableObjects::Community(c))); - } - let p = ApubPerson::read_from_id(object_id.clone(), context).await?; - if let Some(p) = p { - return Ok(Some(SearchableObjects::Person(p))); + let uc = UserOrCommunity::read_from_id(object_id.clone(), context).await?; + if let Some(uc) = uc { + return Ok(Some(SearchableObjects::PersonOrCommunity(Box::new(uc)))); } let p = ApubPost::read_from_id(object_id.clone(), context).await?; if let Some(p) = p { @@ -121,10 +109,12 @@ impl Object for SearchableObjects { #[tracing::instrument(skip_all)] async fn delete(self, data: &Data) -> Result<(), LemmyError> { match self { - SearchableObjects::Person(p) => p.delete(data).await, - SearchableObjects::Community(c) => c.delete(data).await, SearchableObjects::Post(p) => p.delete(data).await, SearchableObjects::Comment(c) => c.delete(data).await, + SearchableObjects::PersonOrCommunity(pc) => match *pc { + UserOrCommunity::User(p) => p.delete(data).await, + UserOrCommunity::Community(c) => c.delete(data).await, + }, } } @@ -139,10 +129,12 @@ impl Object for SearchableObjects { data: &Data, ) -> Result<(), LemmyError> { match apub { - SearchableKinds::Group(a) => ApubCommunity::verify(a, expected_domain, data).await, - SearchableKinds::Person(a) => ApubPerson::verify(a, expected_domain, data).await, SearchableKinds::Page(a) => ApubPost::verify(a, expected_domain, data).await, SearchableKinds::Note(a) => ApubComment::verify(a, expected_domain, data).await, + SearchableKinds::PersonOrGroup(pg) => match pg.as_ref() { + PersonOrGroup::Person(a) => ApubPerson::verify(a, expected_domain, data).await, + PersonOrGroup::Group(a) => ApubCommunity::verify(a, expected_domain, data).await, + }, } } @@ -151,10 +143,11 @@ impl Object for SearchableObjects { use SearchableKinds as SAT; use SearchableObjects as SO; Ok(match apub { - SAT::Group(g) => SO::Community(ApubCommunity::from_json(g, context).await?), - SAT::Person(p) => SO::Person(ApubPerson::from_json(p, context).await?), - SAT::Page(p) => SO::Post(ApubPost::from_json(p, context).await?), + SAT::Page(p) => SO::Post(ApubPost::from_json(*p, context).await?), SAT::Note(n) => SO::Comment(ApubComment::from_json(n, context).await?), + SAT::PersonOrGroup(pg) => { + SO::PersonOrCommunity(Box::new(UserOrCommunity::from_json(*pg, context).await?)) + } }) } } diff --git a/crates/apub/src/http/community.rs b/crates/apub/src/http/community.rs index 83ccdacf9..cf0d1625d 100644 --- a/crates/apub/src/http/community.rs +++ b/crates/apub/src/http/community.rs @@ -115,9 +115,9 @@ pub(crate) async fn get_apub_community_featured( } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] pub(crate) mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use crate::protocol::objects::{group::Group, tombstone::Tombstone}; diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 6d8d814bf..ba7cc914f 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -18,7 +18,7 @@ use activitypub_federation::{ use chrono::{DateTime, Utc}; use lemmy_api_common::{ context::LemmyContext, - utils::{is_mod_or_admin, local_site_opt_to_slur_regex, process_markdown}, + utils::{get_url_blocklist, is_mod_or_admin, local_site_opt_to_slur_regex, process_markdown}, }; use lemmy_db_schema::{ source::{ @@ -165,7 +165,8 @@ impl Object for ApubComment { let local_site = LocalSite::read(&mut context.pool()).await.ok(); let slur_regex = &local_site_opt_to_slur_regex(&local_site); - let content = process_markdown(&content, slur_regex, context).await?; + let url_blocklist = get_url_blocklist(context).await?; + let content = process_markdown(&content, slur_regex, &url_blocklist, context).await?; let language_id = LanguageTag::to_language_id_single(note.language, &mut context.pool()).await?; diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index e71f6d9b5..7630d80b2 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -21,6 +21,7 @@ use lemmy_api_common::{ generate_featured_url, generate_moderators_url, generate_outbox_url, + get_url_blocklist, local_site_opt_to_slur_regex, process_markdown_opt, proxy_image_link_opt_apub, @@ -141,8 +142,10 @@ impl Object for ApubCommunity { let local_site = LocalSite::read(&mut context.pool()).await.ok(); let slur_regex = &local_site_opt_to_slur_regex(&local_site); + let url_blocklist = get_url_blocklist(context).await?; let description = read_from_string_or_source_opt(&group.summary, &None, &group.source); - let description = process_markdown_opt(&description, slur_regex, context).await?; + let description = + process_markdown_opt(&description, slur_regex, &url_blocklist, context).await?; let icon = proxy_image_link_opt_apub(group.icon.map(|i| i.url), context).await?; let banner = proxy_image_link_opt_apub(group.image.map(|i| i.url), context).await?; diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 8f4f163db..6894643d6 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -19,7 +19,12 @@ use activitypub_federation::{ use chrono::{DateTime, Utc}; use lemmy_api_common::{ context::LemmyContext, - utils::{local_site_opt_to_slur_regex, process_markdown_opt, proxy_image_link_opt_apub}, + utils::{ + get_url_blocklist, + local_site_opt_to_slur_regex, + process_markdown_opt, + proxy_image_link_opt_apub, + }, }; use lemmy_db_schema::{ newtypes::InstanceId, @@ -138,8 +143,9 @@ impl Object for ApubSite { let local_site = LocalSite::read(&mut context.pool()).await.ok(); let slur_regex = &local_site_opt_to_slur_regex(&local_site); + let url_blocklist = get_url_blocklist(context).await?; let sidebar = read_from_string_or_source_opt(&apub.content, &None, &apub.source); - let sidebar = process_markdown_opt(&sidebar, slur_regex, context).await?; + let sidebar = process_markdown_opt(&sidebar, slur_regex, &url_blocklist, context).await?; let icon = proxy_image_link_opt_apub(apub.icon.map(|i| i.url), context).await?; let banner = proxy_image_link_opt_apub(apub.image.map(|i| i.url), context).await?; diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index 7bfb68a04..d4456344f 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -22,6 +22,7 @@ use lemmy_api_common::{ context::LemmyContext, utils::{ generate_outbox_url, + get_url_blocklist, local_site_opt_to_slur_regex, process_markdown_opt, proxy_image_link_opt_apub, @@ -152,8 +153,9 @@ impl Object for ApubPerson { let local_site = LocalSite::read(&mut context.pool()).await.ok(); let slur_regex = &local_site_opt_to_slur_regex(&local_site); + let url_blocklist = get_url_blocklist(context).await?; let bio = read_from_string_or_source_opt(&person.summary, &None, &person.source); - let bio = process_markdown_opt(&bio, slur_regex, context).await?; + let bio = process_markdown_opt(&bio, slur_regex, &url_blocklist, context).await?; let avatar = proxy_image_link_opt_apub(person.icon.map(|i| i.url), context).await?; let banner = proxy_image_link_opt_apub(person.image.map(|i| i.url), context).await?; diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index ff42b9cbd..15184b622 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -26,6 +26,7 @@ use lemmy_api_common::{ context::LemmyContext, request::fetch_link_metadata_opt, utils::{ + get_url_blocklist, local_site_opt_to_sensitive, local_site_opt_to_slur_regex, process_markdown_opt, @@ -246,9 +247,10 @@ impl Object for ApubPost { let thumbnail_url = proxy_image_link_opt_apub(thumbnail_url, context).await?; let slur_regex = &local_site_opt_to_slur_regex(&local_site); + let url_blocklist = get_url_blocklist(context).await?; let body = read_from_string_or_source_opt(&page.content, &page.media_type, &page.source); - let body = process_markdown_opt(&body, slur_regex, context).await?; + let body = process_markdown_opt(&body, slur_regex, &url_blocklist, context).await?; let language_id = LanguageTag::to_language_id_single(page.language, &mut context.pool()).await?; diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index d5c00632f..647510802 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -14,7 +14,7 @@ use activitypub_federation::{ use chrono::{DateTime, Utc}; use lemmy_api_common::{ context::LemmyContext, - utils::{check_person_block, local_site_opt_to_slur_regex, process_markdown}, + utils::{check_person_block, get_url_blocklist, local_site_opt_to_slur_regex, process_markdown}, }; use lemmy_db_schema::{ source::{ @@ -127,8 +127,9 @@ impl Object for ApubPrivateMessage { let local_site = LocalSite::read(&mut context.pool()).await.ok(); let slur_regex = &local_site_opt_to_slur_regex(&local_site); + let url_blocklist = get_url_blocklist(context).await?; let content = read_from_string_or_source(¬e.content, &None, ¬e.source); - let content = process_markdown(&content, slur_regex, context).await?; + let content = process_markdown(&content, slur_regex, &url_blocklist, context).await?; let form = PrivateMessageInsertForm { creator_id: creator.id, diff --git a/crates/db_schema/src/aggregates/comment_aggregates.rs b/crates/db_schema/src/aggregates/comment_aggregates.rs index 78ceaa0c6..2120c7f38 100644 --- a/crates/db_schema/src/aggregates/comment_aggregates.rs +++ b/crates/db_schema/src/aggregates/comment_aggregates.rs @@ -33,9 +33,9 @@ impl CommentAggregates { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ aggregates::comment_aggregates::CommentAggregates, diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index 334688b97..f1f54663b 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -31,9 +31,9 @@ impl CommunityAggregates { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ aggregates::community_aggregates::CommunityAggregates, diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index b48b37641..520b45225 100644 --- a/crates/db_schema/src/aggregates/person_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_aggregates.rs @@ -18,9 +18,9 @@ impl PersonAggregates { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ aggregates::person_aggregates::PersonAggregates, diff --git a/crates/db_schema/src/aggregates/post_aggregates.rs b/crates/db_schema/src/aggregates/post_aggregates.rs index 9415f8971..7f95dc05a 100644 --- a/crates/db_schema/src/aggregates/post_aggregates.rs +++ b/crates/db_schema/src/aggregates/post_aggregates.rs @@ -52,9 +52,9 @@ impl PostAggregates { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ aggregates::post_aggregates::PostAggregates, diff --git a/crates/db_schema/src/aggregates/site_aggregates.rs b/crates/db_schema/src/aggregates/site_aggregates.rs index 453430841..b179ff7c7 100644 --- a/crates/db_schema/src/aggregates/site_aggregates.rs +++ b/crates/db_schema/src/aggregates/site_aggregates.rs @@ -14,9 +14,9 @@ impl SiteAggregates { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ aggregates::site_aggregates::SiteAggregates, diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index bb17c83e7..e1802c7c5 100644 --- a/crates/db_schema/src/impls/activity.rs +++ b/crates/db_schema/src/impls/activity.rs @@ -61,9 +61,9 @@ impl ReceivedActivity { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use crate::{source::activity::ActorType, utils::build_db_pool_for_tests}; diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index 1cb5f4c77..0191dd872 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -385,9 +385,9 @@ async fn convert_read_languages( } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use crate::{ @@ -523,10 +523,6 @@ mod tests { let pool = &mut pool.into(); let (site, instance) = create_test_site(pool).await; - let mut test_langs = test_langs1(pool).await; - SiteLanguage::update(pool, test_langs.clone(), &site) - .await - .unwrap(); let person_form = PersonInsertForm::builder() .name("my test person".to_string()) @@ -539,14 +535,13 @@ mod tests { .password_encrypted("my_pw".to_string()) .build(); - let local_user = LocalUser::create(pool, &local_user_form).await.unwrap(); + let local_user = LocalUser::create(pool, &local_user_form, vec![]) + .await + .unwrap(); let local_user_langs1 = LocalUserLanguage::read(pool, local_user.id).await.unwrap(); - // new user should be initialized with site languages and undetermined - //test_langs.push(UNDETERMINED_ID); - //test_langs.sort(); - test_langs.insert(0, UNDETERMINED_ID); - assert_eq!(test_langs, local_user_langs1); + // new user should be initialized with all languages + assert_eq!(0, local_user_langs1.len()); // update user languages let test_langs2 = test_langs2(pool).await; @@ -655,7 +650,9 @@ mod tests { .person_id(person.id) .password_encrypted("my_pw".to_string()) .build(); - let local_user = LocalUser::create(pool, &local_user_form).await.unwrap(); + let local_user = LocalUser::create(pool, &local_user_form, vec![]) + .await + .unwrap(); LocalUserLanguage::update(pool, test_langs2, local_user.id) .await .unwrap(); diff --git a/crates/db_schema/src/impls/captcha_answer.rs b/crates/db_schema/src/impls/captcha_answer.rs index 72e2d1285..1d0604c0a 100644 --- a/crates/db_schema/src/impls/captcha_answer.rs +++ b/crates/db_schema/src/impls/captcha_answer.rs @@ -48,9 +48,9 @@ impl CaptchaAnswer { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer}, diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 979c3b721..b27d44591 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -241,9 +241,9 @@ impl Saveable for CommentSaved { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ newtypes::LanguageId, diff --git a/crates/db_schema/src/impls/comment_reply.rs b/crates/db_schema/src/impls/comment_reply.rs index d76b46b8a..e6d0915e9 100644 --- a/crates/db_schema/src/impls/comment_reply.rs +++ b/crates/db_schema/src/impls/comment_reply.rs @@ -1,6 +1,6 @@ use crate::{ newtypes::{CommentId, CommentReplyId, PersonId}, - schema::comment_reply::dsl::{comment_id, comment_reply, read, recipient_id}, + schema::comment_reply, source::comment_reply::{CommentReply, CommentReplyInsertForm, CommentReplyUpdateForm}, traits::Crud, utils::{get_conn, DbPool}, @@ -22,9 +22,9 @@ impl Crud for CommentReply { // since the return here isnt utilized, we dont need to do an update // but get_result doesnt return the existing row here - insert_into(comment_reply) + insert_into(comment_reply::table) .values(comment_reply_form) - .on_conflict((recipient_id, comment_id)) + .on_conflict((comment_reply::recipient_id, comment_reply::comment_id)) .do_update() .set(comment_reply_form) .get_result::(conn) @@ -37,7 +37,7 @@ impl Crud for CommentReply { comment_reply_form: &Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; - diesel::update(comment_reply.find(comment_reply_id)) + diesel::update(comment_reply::table.find(comment_reply_id)) .set(comment_reply_form) .get_result::(conn) .await @@ -51,11 +51,11 @@ impl CommentReply { ) -> Result, Error> { let conn = &mut get_conn(pool).await?; diesel::update( - comment_reply - .filter(recipient_id.eq(for_recipient_id)) - .filter(read.eq(false)), + comment_reply::table + .filter(comment_reply::recipient_id.eq(for_recipient_id)) + .filter(comment_reply::read.eq(false)), ) - .set(read.eq(true)) + .set(comment_reply::read.eq(true)) .get_results::(conn) .await } @@ -65,17 +65,30 @@ impl CommentReply { for_comment_id: CommentId, ) -> Result { let conn = &mut get_conn(pool).await?; - comment_reply - .filter(comment_id.eq(for_comment_id)) + comment_reply::table + .filter(comment_reply::comment_id.eq(for_comment_id)) + .first::(conn) + .await + } + + pub async fn read_by_comment_and_person( + pool: &mut DbPool<'_>, + for_comment_id: CommentId, + for_recipient_id: PersonId, + ) -> Result { + let conn = &mut get_conn(pool).await?; + comment_reply::table + .filter(comment_reply::comment_id.eq(for_comment_id)) + .filter(comment_reply::recipient_id.eq(for_recipient_id)) .first::(conn) .await } } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 88b0ef46d..dbacbcb72 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -381,9 +381,9 @@ impl ApubActor for Community { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ diff --git a/crates/db_schema/src/impls/federation_allowlist.rs b/crates/db_schema/src/impls/federation_allowlist.rs index 0664a8a4f..80408a526 100644 --- a/crates/db_schema/src/impls/federation_allowlist.rs +++ b/crates/db_schema/src/impls/federation_allowlist.rs @@ -48,9 +48,9 @@ impl FederationAllowList { } } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{federation_allowlist::FederationAllowList, instance::Instance}, diff --git a/crates/db_schema/src/impls/language.rs b/crates/db_schema/src/impls/language.rs index 66fc05729..905221402 100644 --- a/crates/db_schema/src/impls/language.rs +++ b/crates/db_schema/src/impls/language.rs @@ -41,9 +41,9 @@ impl Language { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{source::language::Language, utils::build_db_pool_for_tests}; use pretty_assertions::assert_eq; diff --git a/crates/db_schema/src/impls/local_site_url_blocklist.rs b/crates/db_schema/src/impls/local_site_url_blocklist.rs new file mode 100644 index 000000000..73dedabce --- /dev/null +++ b/crates/db_schema/src/impls/local_site_url_blocklist.rs @@ -0,0 +1,49 @@ +use crate::{ + schema::local_site_url_blocklist, + source::local_site_url_blocklist::{LocalSiteUrlBlocklist, LocalSiteUrlBlocklistForm}, + utils::{get_conn, DbPool}, +}; +use diesel::{dsl::insert_into, result::Error}; +use diesel_async::{AsyncPgConnection, RunQueryDsl}; + +impl LocalSiteUrlBlocklist { + pub async fn replace(pool: &mut DbPool<'_>, url_blocklist: Vec) -> Result<(), Error> { + let conn = &mut get_conn(pool).await?; + + conn + .build_transaction() + .run(|conn| { + Box::pin(async move { + use crate::schema::local_site_url_blocklist::dsl::local_site_url_blocklist; + + Self::clear(conn).await?; + + let forms = url_blocklist + .into_iter() + .map(|url| LocalSiteUrlBlocklistForm { url, updated: None }) + .collect::>(); + + insert_into(local_site_url_blocklist) + .values(forms) + .execute(conn) + .await?; + + Ok(()) + }) as _ + }) + .await + } + + async fn clear(conn: &mut AsyncPgConnection) -> Result { + diesel::delete(local_site_url_blocklist::table) + .execute(conn) + .await + } + + pub async fn get_all(pool: &mut DbPool<'_>) -> Result, Error> { + let conn = &mut get_conn(pool).await?; + local_site_url_blocklist::table + .get_results::(conn) + .await + } +} diff --git a/crates/db_schema/src/impls/local_user.rs b/crates/db_schema/src/impls/local_user.rs index 14ae65469..d253afd8d 100644 --- a/crates/db_schema/src/impls/local_user.rs +++ b/crates/db_schema/src/impls/local_user.rs @@ -1,12 +1,11 @@ use crate::{ - newtypes::{DbUrl, LocalUserId, PersonId}, + newtypes::{DbUrl, LanguageId, LocalUserId, PersonId}, schema::{local_user, person, registration_application}, source::{ - actor_language::{LocalUserLanguage, SiteLanguage}, + actor_language::LocalUserLanguage, local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm}, local_user_vote_display_mode::{LocalUserVoteDisplayMode, LocalUserVoteDisplayModeInsertForm}, }, - traits::Crud, utils::{ functions::{coalesce, lower}, get_conn, @@ -25,6 +24,52 @@ use diesel::{ use diesel_async::RunQueryDsl; impl LocalUser { + pub async fn create( + pool: &mut DbPool<'_>, + form: &LocalUserInsertForm, + languages: Vec, + ) -> Result { + let conn = &mut get_conn(pool).await?; + let mut form_with_encrypted_password = form.clone(); + let password_hash = + hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password"); + form_with_encrypted_password.password_encrypted = password_hash; + + let local_user_ = insert_into(local_user::table) + .values(form_with_encrypted_password) + .get_result::(conn) + .await?; + + LocalUserLanguage::update(pool, languages, local_user_.id).await?; + + // Create their vote_display_modes + let vote_display_mode_form = LocalUserVoteDisplayModeInsertForm::builder() + .local_user_id(local_user_.id) + .build(); + LocalUserVoteDisplayMode::create(pool, &vote_display_mode_form).await?; + + Ok(local_user_) + } + + pub async fn update( + pool: &mut DbPool<'_>, + local_user_id: LocalUserId, + form: &LocalUserUpdateForm, + ) -> Result { + let conn = &mut get_conn(pool).await?; + diesel::update(local_user::table.find(local_user_id)) + .set(form) + .get_result::(conn) + .await + } + + pub async fn delete(pool: &mut DbPool<'_>, id: LocalUserId) -> Result { + let conn = &mut *get_conn(pool).await?; + diesel::delete(local_user::table.find(id)) + .execute(conn) + .await + } + pub async fn update_password( pool: &mut DbPool<'_>, local_user_id: LocalUserId, @@ -183,52 +228,3 @@ pub struct UserBackupLists { pub blocked_users: Vec, pub blocked_instances: Vec, } - -#[async_trait] -impl Crud for LocalUser { - type InsertForm = LocalUserInsertForm; - type UpdateForm = LocalUserUpdateForm; - type IdType = LocalUserId; - - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { - let conn = &mut get_conn(pool).await?; - let mut form_with_encrypted_password = form.clone(); - let password_hash = - hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password"); - form_with_encrypted_password.password_encrypted = password_hash; - - let local_user_ = insert_into(local_user::table) - .values(form_with_encrypted_password) - .get_result::(conn) - .await?; - - let site_languages = SiteLanguage::read_local_raw(pool).await; - if let Ok(langs) = site_languages { - // if site exists, init user with site languages - LocalUserLanguage::update(pool, langs, local_user_.id).await?; - } else { - // otherwise, init with all languages (this only happens during tests and - // for first admin user, which is created before site) - LocalUserLanguage::update(pool, vec![], local_user_.id).await?; - } - - // Create their vote_display_modes - let vote_display_mode_form = LocalUserVoteDisplayModeInsertForm::builder() - .local_user_id(local_user_.id) - .build(); - LocalUserVoteDisplayMode::create(pool, &vote_display_mode_form).await?; - - Ok(local_user_) - } - async fn update( - pool: &mut DbPool<'_>, - local_user_id: LocalUserId, - form: &Self::UpdateForm, - ) -> Result { - let conn = &mut get_conn(pool).await?; - diesel::update(local_user::table.find(local_user_id)) - .set(form) - .get_result::(conn) - .await - } -} diff --git a/crates/db_schema/src/impls/mod.rs b/crates/db_schema/src/impls/mod.rs index 711a6c4e6..3a4e71307 100644 --- a/crates/db_schema/src/impls/mod.rs +++ b/crates/db_schema/src/impls/mod.rs @@ -17,6 +17,7 @@ pub mod instance_block; pub mod language; pub mod local_site; pub mod local_site_rate_limit; +pub mod local_site_url_blocklist; pub mod local_user; pub mod local_user_vote_display_mode; pub mod login_token; diff --git a/crates/db_schema/src/impls/moderator.rs b/crates/db_schema/src/impls/moderator.rs index cfb64d883..99f117878 100644 --- a/crates/db_schema/src/impls/moderator.rs +++ b/crates/db_schema/src/impls/moderator.rs @@ -465,9 +465,9 @@ impl Crud for AdminPurgeComment { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index 6fcf86014..491097135 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -81,9 +81,9 @@ impl PasswordResetRequest { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ @@ -121,7 +121,9 @@ mod tests { .password_encrypted("pass".to_string()) .build(); - let inserted_local_user = LocalUser::create(pool, &new_local_user).await.unwrap(); + let inserted_local_user = LocalUser::create(pool, &new_local_user, vec![]) + .await + .unwrap(); let token = "nope"; diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index 0de7c32f5..c90f67891 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -212,9 +212,9 @@ impl PersonFollower { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ diff --git a/crates/db_schema/src/impls/person_mention.rs b/crates/db_schema/src/impls/person_mention.rs index 75950e7e9..5524f87ee 100644 --- a/crates/db_schema/src/impls/person_mention.rs +++ b/crates/db_schema/src/impls/person_mention.rs @@ -1,6 +1,6 @@ use crate::{ newtypes::{CommentId, PersonId, PersonMentionId}, - schema::person_mention::dsl::{comment_id, person_mention, read, recipient_id}, + schema::person_mention, source::person_mention::{PersonMention, PersonMentionInsertForm, PersonMentionUpdateForm}, traits::Crud, utils::{get_conn, DbPool}, @@ -21,9 +21,9 @@ impl Crud for PersonMention { let conn = &mut get_conn(pool).await?; // since the return here isnt utilized, we dont need to do an update // but get_result doesnt return the existing row here - insert_into(person_mention) + insert_into(person_mention::table) .values(person_mention_form) - .on_conflict((recipient_id, comment_id)) + .on_conflict((person_mention::recipient_id, person_mention::comment_id)) .do_update() .set(person_mention_form) .get_result::(conn) @@ -36,7 +36,7 @@ impl Crud for PersonMention { person_mention_form: &Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; - diesel::update(person_mention.find(person_mention_id)) + diesel::update(person_mention::table.find(person_mention_id)) .set(person_mention_form) .get_result::(conn) .await @@ -50,11 +50,11 @@ impl PersonMention { ) -> Result, Error> { let conn = &mut get_conn(pool).await?; diesel::update( - person_mention - .filter(recipient_id.eq(for_recipient_id)) - .filter(read.eq(false)), + person_mention::table + .filter(person_mention::recipient_id.eq(for_recipient_id)) + .filter(person_mention::read.eq(false)), ) - .set(read.eq(true)) + .set(person_mention::read.eq(true)) .get_results::(conn) .await } @@ -65,18 +65,18 @@ impl PersonMention { for_recipient_id: PersonId, ) -> Result { let conn = &mut get_conn(pool).await?; - person_mention - .filter(comment_id.eq(for_comment_id)) - .filter(recipient_id.eq(for_recipient_id)) + person_mention::table + .filter(person_mention::comment_id.eq(for_comment_id)) + .filter(person_mention::recipient_id.eq(for_recipient_id)) .first::(conn) .await } } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index a75fa4349..8db871ad5 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -27,7 +27,7 @@ use crate::{ }, }; use ::url::Url; -use chrono::{Duration, Utc}; +use chrono::Utc; use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextExpressionMethods}; use diesel_async::RunQueryDsl; use std::collections::HashSet; @@ -104,7 +104,9 @@ impl Post { .filter(post::local.eq(true)) .filter(post::deleted.eq(false)) .filter(post::removed.eq(false)) - .filter(post::published.ge(Utc::now().naive_utc() - Duration::days(SITEMAP_DAYS))) + .filter( + post::published.ge(Utc::now().naive_utc() - SITEMAP_DAYS.expect("TimeDelta out of bounds")), + ) .order(post::published.desc()) .limit(SITEMAP_LIMIT) .load::<(DbUrl, chrono::DateTime)>(conn) @@ -360,9 +362,9 @@ impl PostHide { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index face766db..260574bd2 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -80,9 +80,9 @@ impl Reportable for PostReport { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use crate::{ diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index 961e36518..ee0009189 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -74,9 +74,9 @@ impl PrivateMessage { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ source::{ diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index a61b2d24f..408ed0540 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -409,6 +409,15 @@ diesel::table! { } } +diesel::table! { + local_site_url_blocklist (id) { + id -> Int4, + url -> Text, + published -> Timestamptz, + updated -> Nullable, + } +} + diesel::table! { use diesel::sql_types::*; use super::sql_types::SortTypeEnum; @@ -1052,6 +1061,7 @@ diesel::allow_tables_to_appear_in_same_query!( local_image, local_site, local_site_rate_limit, + local_site_url_blocklist, local_user, local_user_language, local_user_vote_display_mode, diff --git a/crates/db_schema/src/source/local_site_url_blocklist.rs b/crates/db_schema/src/source/local_site_url_blocklist.rs new file mode 100644 index 000000000..4ac0893ec --- /dev/null +++ b/crates/db_schema/src/source/local_site_url_blocklist.rs @@ -0,0 +1,28 @@ +#[cfg(feature = "full")] +use crate::schema::local_site_url_blocklist; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use serde_with::skip_serializing_none; +#[cfg(feature = "full")] +use ts_rs::TS; + +#[skip_serializing_none] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))] +#[cfg_attr(feature = "full", diesel(table_name = local_site_url_blocklist))] +#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] +#[cfg_attr(feature = "full", ts(export))] +pub struct LocalSiteUrlBlocklist { + pub id: i32, + pub url: String, + pub published: DateTime, + pub updated: Option>, +} + +#[derive(Default, Clone)] +#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] +#[cfg_attr(feature = "full", diesel(table_name = local_site_url_blocklist))] +pub struct LocalSiteUrlBlocklistForm { + pub url: String, + pub updated: Option>, +} diff --git a/crates/db_schema/src/source/mod.rs b/crates/db_schema/src/source/mod.rs index ab82a114c..3a6501717 100644 --- a/crates/db_schema/src/source/mod.rs +++ b/crates/db_schema/src/source/mod.rs @@ -22,6 +22,7 @@ pub mod instance_block; pub mod language; pub mod local_site; pub mod local_site_rate_limit; +pub mod local_site_url_blocklist; pub mod local_user; pub mod local_user_vote_display_mode; pub mod login_token; diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 038ab129a..465ecb4cd 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -6,7 +6,7 @@ use crate::{ SortType, }; use anyhow::Context; -use chrono::{DateTime, Utc}; +use chrono::{DateTime, TimeDelta, Utc}; use deadpool::Runtime; use diesel::{ helper_types::AsExprOf, @@ -51,7 +51,7 @@ use url::Url; const FETCH_LIMIT_DEFAULT: i64 = 10; pub const FETCH_LIMIT_MAX: i64 = 50; pub const SITEMAP_LIMIT: i64 = 50000; -pub const SITEMAP_DAYS: i64 = 31; +pub const SITEMAP_DAYS: Option = TimeDelta::try_days(31); pub const RANK_DEFAULT: f64 = 0.0001; pub type ActualDbPool = Pool; @@ -536,9 +536,9 @@ impl Queries { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use pretty_assertions::assert_eq; diff --git a/crates/db_views/src/comment_report_view.rs b/crates/db_views/src/comment_report_view.rs index 1aa3bb6e7..0da5b3cff 100644 --- a/crates/db_views/src/comment_report_view.rs +++ b/crates/db_views/src/comment_report_view.rs @@ -258,9 +258,9 @@ impl CommentReportQuery { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ comment_report_view::{CommentReportQuery, CommentReportView}, @@ -308,7 +308,9 @@ mod tests { .person_id(inserted_timmy.id) .password_encrypted("123".to_string()) .build(); - let timmy_local_user = LocalUser::create(pool, &new_local_user).await.unwrap(); + let timmy_local_user = LocalUser::create(pool, &new_local_user, vec![]) + .await + .unwrap(); let timmy_view = LocalUserView { local_user: timmy_local_user, local_user_vote_display_mode: LocalUserVoteDisplayMode::default(), diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 40065672c..01ff394eb 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -53,6 +53,16 @@ fn queries<'a>() -> Queries< ), ); + let is_local_user_banned_from_community = |person_id| { + exists( + community_person_ban::table.filter( + community::id + .eq(community_person_ban::community_id) + .and(community_person_ban::person_id.eq(person_id)), + ), + ) + }; + let is_saved = |person_id| { comment_saved::table .filter( @@ -113,6 +123,14 @@ fn queries<'a>() -> Queries< ); let all_joins = move |query: comment::BoxedQuery<'a, Pg>, my_person_id: Option| { + let is_local_user_banned_from_community_selection: Box< + dyn BoxableExpression<_, Pg, SqlType = sql_types::Bool>, + > = if let Some(person_id) = my_person_id { + Box::new(is_local_user_banned_from_community(person_id)) + } else { + Box::new(false.into_sql::()) + }; + let score_selection: Box< dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable>, > = if let Some(person_id) = my_person_id { @@ -156,6 +174,7 @@ fn queries<'a>() -> Queries< community::all_columns, comment_aggregates::all_columns, is_creator_banned_from_community, + is_local_user_banned_from_community_selection, creator_is_moderator, creator_is_admin, subscribed_type_selection, @@ -407,9 +426,9 @@ impl<'a> CommentQuery<'a> { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ comment_view::{CommentQuery, CommentSortType, CommentView, DbPool}, @@ -436,6 +455,8 @@ mod tests { CommunityInsertForm, CommunityModerator, CommunityModeratorForm, + CommunityPersonBan, + CommunityPersonBanForm, CommunityUpdateForm, }, instance::Instance, @@ -446,11 +467,12 @@ mod tests { person_block::{PersonBlock, PersonBlockForm}, post::{Post, PostInsertForm}, }, - traits::{Blockable, Crud, Joinable, Likeable, Saveable}, + traits::{Bannable, Blockable, Crud, Joinable, Likeable, Saveable}, utils::{build_db_pool_for_tests, RANK_DEFAULT}, CommunityVisibility, SubscribedType, }; + use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; use serial_test::serial; @@ -481,7 +503,7 @@ mod tests { .admin(Some(true)) .password_encrypted(String::new()) .build(); - let inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form) + let inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form, vec![]) .await .unwrap(); @@ -633,12 +655,12 @@ mod tests { #[tokio::test] #[serial] - async fn test_crud() { + async fn test_crud() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; - let expected_comment_view_no_person = expected_comment_view(&data, pool).await; + let expected_comment_view_no_person = expected_comment_view(&data, pool).await?; let mut expected_comment_view_with_person = expected_comment_view_no_person.clone(); expected_comment_view_with_person.my_vote = Some(1); @@ -649,8 +671,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_eq!( expected_comment_view_no_person, @@ -664,8 +685,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_eq!( expected_comment_view_with_person, @@ -680,8 +700,7 @@ mod tests { data.inserted_comment_1.id, Some(data.timmy_local_user_view.person.id), ) - .await - .unwrap(); + .await?; // Make sure block set the creator blocked assert!(read_comment_from_blocked_person.creator_blocked); @@ -692,8 +711,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_eq!( expected_comment_view_with_person, @@ -708,17 +726,16 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert!(read_disliked_comment_views.is_empty()); - cleanup(data, pool).await; + cleanup(data, pool).await } #[tokio::test] #[serial] - async fn test_comment_tree() { + async fn test_comment_tree() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; @@ -730,8 +747,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; let child_path = data.inserted_comment_1.path.clone(); let read_comment_views_child_path = CommentQuery { @@ -740,8 +756,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; // Make sure the comment parent-limited fetch is correct assert_length!(6, read_comment_views_top_path); @@ -761,12 +776,11 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; // Make sure a depth limited one only has the top comment assert_eq!( - expected_comment_view(&data, pool).await, + expected_comment_view(&data, pool).await?, read_comment_views_top_max_depth[0] ); assert_length!(1, read_comment_views_top_max_depth); @@ -780,8 +794,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; // Make sure a depth limited one, and given child comment 1, has 3 assert!(read_comment_views_parent_max_depth[2] @@ -790,12 +803,12 @@ mod tests { .eq("Comment 3")); assert_length!(3, read_comment_views_parent_max_depth); - cleanup(data, pool).await; + cleanup(data, pool).await } #[tokio::test] #[serial] - async fn test_languages() { + async fn test_languages() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; @@ -807,29 +820,25 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_length!(5, all_languages); // change user lang to finnish, should only show one post in finnish and one undetermined let finnish_id = Language::read_id_from_code(pool, Some("fi")) - .await - .unwrap() + .await? .unwrap(); LocalUserLanguage::update( pool, vec![finnish_id], data.timmy_local_user_view.local_user.id, ) - .await - .unwrap(); + .await?; let finnish_comments = CommentQuery { local_user: (Some(&data.timmy_local_user_view)), ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_length!(2, finnish_comments); let finnish_comment = finnish_comments .iter() @@ -846,23 +855,21 @@ mod tests { vec![UNDETERMINED_ID], data.timmy_local_user_view.local_user.id, ) - .await - .unwrap(); + .await?; let undetermined_comment = CommentQuery { local_user: (Some(&data.timmy_local_user_view)), ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_length!(1, undetermined_comment); - cleanup(data, pool).await; + cleanup(data, pool).await } #[tokio::test] #[serial] - async fn test_distinguished_first() { + async fn test_distinguished_first() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; @@ -871,26 +878,23 @@ mod tests { distinguished: Some(true), ..Default::default() }; - Comment::update(pool, data.inserted_comment_2.id, &form) - .await - .unwrap(); + Comment::update(pool, data.inserted_comment_2.id, &form).await?; let comments = CommentQuery { post_id: Some(data.inserted_comment_2.post_id), ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_eq!(comments[0].comment.id, data.inserted_comment_2.id); assert!(comments[0].comment.distinguished); - cleanup(data, pool).await; + cleanup(data, pool).await } #[tokio::test] #[serial] - async fn test_creator_is_moderator() { + async fn test_creator_is_moderator() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; @@ -902,7 +906,7 @@ mod tests { community_id, person_id, }; - CommunityModerator::join(pool, &form).await.unwrap(); + CommunityModerator::join(pool, &form).await?; // Make sure that they come back as a mod in the list let comments = CommentQuery { @@ -910,19 +914,18 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_eq!(comments[1].creator.name, "sara"); assert!(comments[1].creator_is_moderator); assert!(!comments[0].creator_is_moderator); - cleanup(data, pool).await; + cleanup(data, pool).await } #[tokio::test] #[serial] - async fn test_creator_is_admin() { + async fn test_creator_is_admin() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; @@ -932,8 +935,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; // Timmy is an admin, and make sure that field is true assert_eq!(comments[0].creator.name, "timmy"); @@ -943,12 +945,12 @@ mod tests { assert_eq!(comments[1].creator.name, "sara"); assert!(!comments[1].creator_is_admin); - cleanup(data, pool).await; + cleanup(data, pool).await } #[tokio::test] #[serial] - async fn test_saved_order() { + async fn test_saved_order() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; @@ -958,17 +960,13 @@ mod tests { person_id: data.timmy_local_user_view.person.id, comment_id: data.inserted_comment_0.id, }; - CommentSaved::save(pool, &save_comment_0_form) - .await - .unwrap(); + CommentSaved::save(pool, &save_comment_0_form).await?; let save_comment_2_form = CommentSavedForm { person_id: data.timmy_local_user_view.person.id, comment_id: data.inserted_comment_2.id, }; - CommentSaved::save(pool, &save_comment_2_form) - .await - .unwrap(); + CommentSaved::save(pool, &save_comment_2_form).await?; // Fetch the saved comments let comments = CommentQuery { @@ -977,8 +975,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; // There should only be two comments assert_eq!(2, comments.len()); @@ -989,47 +986,33 @@ mod tests { // The second comment, should be the first one saved assert_eq!(comments[1].comment.id, data.inserted_comment_0.id); - cleanup(data, pool).await; + cleanup(data, pool).await } - async fn cleanup(data: Data, pool: &mut DbPool<'_>) { + async fn cleanup(data: Data, pool: &mut DbPool<'_>) -> LemmyResult<()> { CommentLike::remove( pool, data.timmy_local_user_view.person.id, data.inserted_comment_0.id, ) - .await - .unwrap(); - Comment::delete(pool, data.inserted_comment_0.id) - .await - .unwrap(); - Comment::delete(pool, data.inserted_comment_1.id) - .await - .unwrap(); - Post::delete(pool, data.inserted_post.id).await.unwrap(); - Community::delete(pool, data.inserted_community.id) - .await - .unwrap(); - Person::delete(pool, data.timmy_local_user_view.person.id) - .await - .unwrap(); - LocalUser::delete(pool, data.timmy_local_user_view.local_user.id) - .await - .unwrap(); - Person::delete(pool, data.inserted_sara_person.id) - .await - .unwrap(); - Instance::delete(pool, data.inserted_instance.id) - .await - .unwrap(); + .await?; + Comment::delete(pool, data.inserted_comment_0.id).await?; + Comment::delete(pool, data.inserted_comment_1.id).await?; + Post::delete(pool, data.inserted_post.id).await?; + Community::delete(pool, data.inserted_community.id).await?; + Person::delete(pool, data.timmy_local_user_view.person.id).await?; + LocalUser::delete(pool, data.timmy_local_user_view.local_user.id).await?; + Person::delete(pool, data.inserted_sara_person.id).await?; + Instance::delete(pool, data.inserted_instance.id).await?; + + Ok(()) } - async fn expected_comment_view(data: &Data, pool: &mut DbPool<'_>) -> CommentView { - let agg = CommentAggregates::read(pool, data.inserted_comment_0.id) - .await - .unwrap(); - CommentView { + async fn expected_comment_view(data: &Data, pool: &mut DbPool<'_>) -> LemmyResult { + let agg = CommentAggregates::read(pool, data.inserted_comment_0.id).await?; + Ok(CommentView { creator_banned_from_community: false, + banned_from_community: false, creator_is_moderator: false, creator_is_admin: true, my_vote: None, @@ -1136,12 +1119,12 @@ mod tests { hot_rank: RANK_DEFAULT, controversy_rank: 0.0, }, - } + }) } #[tokio::test] #[serial] - async fn local_only_instance() { + async fn local_only_instance() -> LemmyResult<()> { let pool = &build_db_pool_for_tests().await; let pool = &mut pool.into(); let data = init_data(pool).await; @@ -1154,15 +1137,13 @@ mod tests { ..Default::default() }, ) - .await - .unwrap(); + .await?; let unauthenticated_query = CommentQuery { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_eq!(0, unauthenticated_query.len()); let authenticated_query = CommentQuery { @@ -1170,8 +1151,7 @@ mod tests { ..Default::default() } .list(pool) - .await - .unwrap(); + .await?; assert_eq!(5, authenticated_query.len()); let unauthenticated_comment = CommentView::read(pool, data.inserted_comment_0.id, None).await; @@ -1185,6 +1165,67 @@ mod tests { .await; assert!(authenticated_comment.is_ok()); - cleanup(data, pool).await; + cleanup(data, pool).await + } + + #[tokio::test] + #[serial] + async fn comment_listing_local_user_banned_from_community() -> LemmyResult<()> { + let pool = &build_db_pool_for_tests().await; + let pool = &mut pool.into(); + let data = init_data(pool).await; + + // Test that comment view shows if local user is blocked from community + let banned_from_comm_person = PersonInsertForm::test_form(data.inserted_instance.id, "jill"); + + let inserted_banned_from_comm_person = Person::create(pool, &banned_from_comm_person).await?; + + let inserted_banned_from_comm_local_user = LocalUser::create( + pool, + &LocalUserInsertForm::test_form(inserted_banned_from_comm_person.id), + vec![], + ) + .await?; + + CommunityPersonBan::ban( + pool, + &CommunityPersonBanForm { + community_id: data.inserted_community.id, + person_id: inserted_banned_from_comm_person.id, + expires: None, + }, + ) + .await?; + + let comment_view = CommentView::read( + pool, + data.inserted_comment_0.id, + Some(inserted_banned_from_comm_local_user.person_id), + ) + .await?; + + assert!(comment_view.banned_from_community); + + Person::delete(pool, inserted_banned_from_comm_person.id).await?; + cleanup(data, pool).await + } + + #[tokio::test] + #[serial] + async fn comment_listing_local_user_not_banned_from_community() -> LemmyResult<()> { + let pool = &build_db_pool_for_tests().await; + let pool = &mut pool.into(); + let data = init_data(pool).await; + + let comment_view = CommentView::read( + pool, + data.inserted_comment_0.id, + Some(data.timmy_local_user_view.person.id), + ) + .await?; + + assert!(!comment_view.banned_from_community); + + cleanup(data, pool).await } } diff --git a/crates/db_views/src/custom_emoji_view.rs b/crates/db_views/src/custom_emoji_view.rs index d83fa9912..4d2f1fd85 100644 --- a/crates/db_views/src/custom_emoji_view.rs +++ b/crates/db_views/src/custom_emoji_view.rs @@ -77,7 +77,7 @@ impl CustomEmojiView { } for emoji in &mut result { if let Some(keywords) = hash.get_mut(&emoji.custom_emoji.id) { - emoji.keywords = keywords.clone(); + emoji.keywords.clone_from(keywords); } } result diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/post_report_view.rs index 0f1f3639c..878937d01 100644 --- a/crates/db_views/src/post_report_view.rs +++ b/crates/db_views/src/post_report_view.rs @@ -283,9 +283,9 @@ impl PostReportQuery { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ post_report_view::{PostReportQuery, PostReportView}, @@ -330,7 +330,9 @@ mod tests { .person_id(inserted_timmy.id) .password_encrypted("123".to_string()) .build(); - let timmy_local_user = LocalUser::create(pool, &new_local_user).await.unwrap(); + let timmy_local_user = LocalUser::create(pool, &new_local_user, vec![]) + .await + .unwrap(); let timmy_view = LocalUserView { local_user: timmy_local_user, local_user_vote_display_mode: LocalUserVoteDisplayMode::default(), diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index b9522d47b..b323437d5 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -73,6 +73,17 @@ fn queries<'a>() -> Queries< .and(community_person_ban::person_id.eq(post_aggregates::creator_id)), ), ); + + let is_local_user_banned_from_community = |person_id| { + exists( + community_person_ban::table.filter( + post_aggregates::community_id + .eq(community_person_ban::community_id) + .and(community_person_ban::person_id.eq(person_id)), + ), + ) + }; + let creator_is_moderator = exists( community_moderator::table.filter( post_aggregates::community_id @@ -143,6 +154,14 @@ fn queries<'a>() -> Queries< let all_joins = move |query: post_aggregates::BoxedQuery<'a, Pg>, my_person_id: Option| { + let is_local_user_banned_from_community_selection: Box< + dyn BoxableExpression<_, Pg, SqlType = sql_types::Bool>, + > = if let Some(person_id) = my_person_id { + Box::new(is_local_user_banned_from_community(person_id)) + } else { + Box::new(false.into_sql::()) + }; + let is_saved_selection: Box< dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable>, > = if let Some(person_id) = my_person_id { @@ -223,6 +242,7 @@ fn queries<'a>() -> Queries< person::all_columns, community::all_columns, is_creator_banned_from_community, + is_local_user_banned_from_community_selection, creator_is_moderator, creator_is_admin, post_aggregates::all_columns, @@ -742,6 +762,8 @@ mod tests { CommunityInsertForm, CommunityModerator, CommunityModeratorForm, + CommunityPersonBan, + CommunityPersonBanForm, CommunityUpdateForm, }, community_block::{CommunityBlock, CommunityBlockForm}, @@ -755,7 +777,7 @@ mod tests { post::{Post, PostHide, PostInsertForm, PostLike, PostLikeForm, PostRead, PostUpdateForm}, site::Site, }, - traits::{Blockable, Crud, Joinable, Likeable}, + traits::{Bannable, Blockable, Crud, Joinable, Likeable}, utils::{build_db_pool, build_db_pool_for_tests, DbPool, RANK_DEFAULT}, CommunityVisibility, SortType, @@ -807,7 +829,7 @@ mod tests { admin: Some(true), ..LocalUserInsertForm::test_form(inserted_person.id) }; - let inserted_local_user = LocalUser::create(pool, &local_user_form).await?; + let inserted_local_user = LocalUser::create(pool, &local_user_form, vec![]).await?; let new_bot = PersonInsertForm { bot_account: Some(true), @@ -833,6 +855,7 @@ mod tests { let inserted_blocked_local_user = LocalUser::create( pool, &LocalUserInsertForm::test_form(inserted_blocked_person.id), + vec![], ) .await?; @@ -1604,6 +1627,7 @@ mod tests { last_refreshed_at: inserted_person.last_refreshed_at, }, creator_banned_from_community: false, + banned_from_community: false, creator_is_moderator: false, creator_is_admin: true, community: Community { @@ -1707,4 +1731,67 @@ mod tests { cleanup(data, pool).await?; Ok(()) } + + #[tokio::test] + #[serial] + async fn post_listing_local_user_banned_from_community() -> LemmyResult<()> { + let pool = &build_db_pool().await?; + let pool = &mut pool.into(); + let data = init_data(pool).await?; + + // Test that post view shows if local user is blocked from community + let banned_from_comm_person = PersonInsertForm::test_form(data.inserted_instance.id, "jill"); + + let inserted_banned_from_comm_person = Person::create(pool, &banned_from_comm_person).await?; + + let inserted_banned_from_comm_local_user = LocalUser::create( + pool, + &LocalUserInsertForm::test_form(inserted_banned_from_comm_person.id), + vec![], + ) + .await?; + + CommunityPersonBan::ban( + pool, + &CommunityPersonBanForm { + community_id: data.inserted_community.id, + person_id: inserted_banned_from_comm_person.id, + expires: None, + }, + ) + .await?; + + let post_view = PostView::read( + pool, + data.inserted_post.id, + Some(inserted_banned_from_comm_local_user.person_id), + false, + ) + .await?; + + assert!(post_view.banned_from_community); + + Person::delete(pool, inserted_banned_from_comm_person.id).await?; + cleanup(data, pool).await + } + + #[tokio::test] + #[serial] + async fn post_listing_local_user_not_banned_from_community() -> LemmyResult<()> { + let pool = &build_db_pool().await?; + let pool = &mut pool.into(); + let data = init_data(pool).await?; + + let post_view = PostView::read( + pool, + data.inserted_post.id, + Some(data.local_user_view.person.id), + false, + ) + .await?; + + assert!(!post_view.banned_from_community); + + cleanup(data, pool).await + } } diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index 2c6919542..091071b16 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -106,9 +106,9 @@ impl PrivateMessageReportQuery { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::private_message_report_view::PrivateMessageReportQuery; use lemmy_db_schema::{ diff --git a/crates/db_views/src/private_message_view.rs b/crates/db_views/src/private_message_view.rs index a3e2469c9..466f3bdf0 100644 --- a/crates/db_views/src/private_message_view.rs +++ b/crates/db_views/src/private_message_view.rs @@ -173,9 +173,9 @@ impl PrivateMessageQuery { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{private_message_view::PrivateMessageQuery, structs::PrivateMessageView}; use lemmy_db_schema::{ diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index a59158318..85916bb90 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -127,9 +127,9 @@ impl RegistrationApplicationQuery { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::registration_application_view::{ RegistrationApplicationQuery, @@ -176,7 +176,7 @@ mod tests { .admin(Some(true)) .build(); - let _inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form) + let _inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form, vec![]) .await .unwrap(); @@ -193,7 +193,7 @@ mod tests { .password_encrypted("nada".to_string()) .build(); - let inserted_sara_local_user = LocalUser::create(pool, &sara_local_user_form) + let inserted_sara_local_user = LocalUser::create(pool, &sara_local_user_form, vec![]) .await .unwrap(); @@ -224,7 +224,7 @@ mod tests { .password_encrypted("nada".to_string()) .build(); - let inserted_jess_local_user = LocalUser::create(pool, &jess_local_user_form) + let inserted_jess_local_user = LocalUser::create(pool, &jess_local_user_form, vec![]) .await .unwrap(); diff --git a/crates/db_views/src/structs.rs b/crates/db_views/src/structs.rs index 18fa7efa9..cfaee591d 100644 --- a/crates/db_views/src/structs.rs +++ b/crates/db_views/src/structs.rs @@ -64,6 +64,7 @@ pub struct CommentView { pub community: Community, pub counts: CommentAggregates, pub creator_banned_from_community: bool, + pub banned_from_community: bool, pub creator_is_moderator: bool, pub creator_is_admin: bool, pub subscribed: SubscribedType, @@ -129,6 +130,7 @@ pub struct PostView { pub creator: Person, pub community: Community, pub creator_banned_from_community: bool, + pub banned_from_community: bool, pub creator_is_moderator: bool, pub creator_is_admin: bool, pub counts: PostAggregates, diff --git a/crates/db_views/src/vote_view.rs b/crates/db_views/src/vote_view.rs index 723c188f5..26df3bdbb 100644 --- a/crates/db_views/src/vote_view.rs +++ b/crates/db_views/src/vote_view.rs @@ -50,9 +50,9 @@ impl VoteView { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::structs::VoteView; use lemmy_db_schema::{ diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index c1cb6eee1..3107478dc 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -250,9 +250,9 @@ impl<'a> CommunityQuery<'a> { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{community_view::CommunityQuery, structs::CommunityView}; use lemmy_db_schema::{ @@ -296,7 +296,9 @@ mod tests { .person_id(inserted_person.id) .password_encrypted(String::new()) .build(); - let local_user = LocalUser::create(pool, &local_user_form).await.unwrap(); + let local_user = LocalUser::create(pool, &local_user_form, vec![]) + .await + .unwrap(); let new_community = CommunityInsertForm::builder() .name("test_community_3".to_string()) diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index aee56748e..b3eac296d 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -163,9 +163,9 @@ impl PersonQuery { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use diesel::NotFound; @@ -204,7 +204,7 @@ mod tests { .person_id(alice.id) .password_encrypted(String::new()) .build(); - let alice_local_user = LocalUser::create(pool, &alice_local_user_form).await?; + let alice_local_user = LocalUser::create(pool, &alice_local_user_form, vec![]).await?; let bob_form = PersonInsertForm::builder() .name("bob".to_string()) @@ -218,7 +218,7 @@ mod tests { .person_id(bob.id) .password_encrypted(String::new()) .build(); - let bob_local_user = LocalUser::create(pool, &bob_local_user_form).await?; + let bob_local_user = LocalUser::create(pool, &bob_local_user_form, vec![]).await?; Ok(Data { alice, diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index eb209fd50..ff2a68e3c 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -46,17 +46,17 @@ static SAVE_STATE_EVERY_TIME: Duration = Duration::from_secs(60); /// this delay limits the maximum time until the follow actually results in activities from that community id being sent to that inbox url. /// This delay currently needs to not be too small because the DB load is currently fairly high because of the current structure of storing inboxes for every person, not having a separate list of shared_inboxes, and the architecture of having every instance queue be fully separate. /// (see https://github.com/LemmyNet/lemmy/issues/3958) -static FOLLOW_ADDITIONS_RECHECK_DELAY: Lazy = Lazy::new(|| { +static FOLLOW_ADDITIONS_RECHECK_DELAY: Lazy = Lazy::new(|| { if *LEMMY_TEST_FAST_FEDERATION { - chrono::Duration::seconds(1) + chrono::TimeDelta::try_seconds(1).expect("TimeDelta out of bounds") } else { - chrono::Duration::minutes(2) + chrono::TimeDelta::try_minutes(2).expect("TimeDelta out of bounds") } }); /// The same as FOLLOW_ADDITIONS_RECHECK_DELAY, but triggering when the last person on an instance unfollows a specific remote community. /// This is expected to happen pretty rarely and updating it in a timely manner is not too important. -static FOLLOW_REMOVALS_RECHECK_DELAY: Lazy = - Lazy::new(|| chrono::Duration::hours(1)); +static FOLLOW_REMOVALS_RECHECK_DELAY: Lazy = + Lazy::new(|| chrono::TimeDelta::try_hours(1).expect("TimeDelta out of bounds")); pub(crate) struct InstanceWorker { instance: Instance, // load site lazily because if an instance is first seen due to being on allowlist, @@ -332,7 +332,8 @@ impl InstanceWorker { instance_id: InstanceId, last_fetch: DateTime, ) -> Result<(HashMap>, DateTime)> { - let new_last_fetch = Utc::now() - chrono::Duration::seconds(10); // update to time before fetch to ensure overlap. subtract 10s to ensure overlap even if published date is not exact + let new_last_fetch = + Utc::now() - chrono::TimeDelta::try_seconds(10).expect("TimeDelta out of bounds"); // update to time before fetch to ensure overlap. subtract 10s to ensure overlap even if published date is not exact Ok(( CommunityFollowerView::get_instance_followed_community_inboxes(pool, instance_id, last_fetch) .await? diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 2a832bec0..0a1b22c32 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -74,11 +74,11 @@ uuid = { workspace = true, features = ["serde", "v4"], optional = true } rosetta-i18n = { workspace = true, optional = true } tokio = { workspace = true, optional = true } urlencoding = { workspace = true, optional = true } -openssl = { version = "0.10.63", optional = true } +openssl = { version = "0.10.64", optional = true } html2text = { version = "0.6.0", optional = true } deser-hjson = { version = "2.2.4", optional = true } smart-default = { version = "0.7.1", optional = true } -lettre = { version = "0.11.3", features = [ +lettre = { version = "0.11.4", features = [ "tokio1", "tokio1-native-tls", ], optional = true } diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 9da018960..d25845894 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -135,6 +135,7 @@ pub enum LemmyErrorType { CouldntSetAllRegistrationsAccepted, CouldntSetAllEmailVerified, Banned, + BlockedUrl, CouldntGetComments, CouldntGetPosts, InvalidUrl, diff --git a/crates/utils/src/rate_limit/mod.rs b/crates/utils/src/rate_limit/mod.rs index b2efbe2c9..de64bac46 100644 --- a/crates/utils/src/rate_limit/mod.rs +++ b/crates/utils/src/rate_limit/mod.rs @@ -221,9 +221,9 @@ fn parse_ip(addr: &str) -> Option { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] #[test] fn test_parse_ip() { diff --git a/crates/utils/src/rate_limit/rate_limiter.rs b/crates/utils/src/rate_limit/rate_limiter.rs index d452fcbb3..3f89aee7e 100644 --- a/crates/utils/src/rate_limit/rate_limiter.rs +++ b/crates/utils/src/rate_limit/rate_limiter.rs @@ -158,7 +158,7 @@ impl MapLevel for Map { // Evaluated if `some_children_remaining` is false let total_has_refill_in_future = || { - group.total.into_iter().all(|(action_type, bucket)| { + group.total.into_iter().any(|(action_type, bucket)| { #[allow(clippy::indexing_slicing)] let config = configs[action_type]; bucket.update(now, config).tokens != config.capacity @@ -306,9 +306,9 @@ fn split_ipv6(ip: Ipv6Addr) -> ([u8; 6], u8, u8) { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::{ActionType, BucketConfig, InstantSecs, RateLimitState, RateLimitedGroup}; use pretty_assertions::assert_eq; @@ -416,5 +416,23 @@ mod tests { rate_limiter.remove_full_buckets(now); assert!(rate_limiter.ipv4_buckets.is_empty()); assert!(rate_limiter.ipv6_buckets.is_empty()); + + // `remove full buckets` should not remove empty buckets + let ip = "1.1.1.1".parse().unwrap(); + // empty the bucket with 2 requests + assert!(rate_limiter.check(ActionType::Post, ip, now)); + assert!(rate_limiter.check(ActionType::Post, ip, now)); + + rate_limiter.remove_full_buckets(now); + assert!(!rate_limiter.ipv4_buckets.is_empty()); + + // `remove full buckets` should not remove partial buckets + now.secs += 2; + let ip = "1.1.1.1".parse().unwrap(); + // Only make one request, so bucket still has 1 token + assert!(rate_limiter.check(ActionType::Post, ip, now)); + + rate_limiter.remove_full_buckets(now); + assert!(!rate_limiter.ipv4_buckets.is_empty()); } } diff --git a/crates/utils/src/utils/markdown/mod.rs b/crates/utils/src/utils/markdown/mod.rs index bee2dcb94..87e2cb3a2 100644 --- a/crates/utils/src/utils/markdown/mod.rs +++ b/crates/utils/src/utils/markdown/mod.rs @@ -1,6 +1,7 @@ -use crate::settings::SETTINGS; +use crate::{error::LemmyResult, settings::SETTINGS, LemmyErrorType}; use markdown_it::{plugins::cmark::inline::image::Image, MarkdownIt}; use once_cell::sync::Lazy; +use regex::RegexSet; use url::Url; use urlencoding::encode; @@ -98,10 +99,17 @@ pub fn markdown_rewrite_image_links(mut src: String) -> (String, Vec) { (src, links) } +pub fn markdown_check_for_blocked_urls(text: &str, blocklist: &RegexSet) -> LemmyResult<()> { + if blocklist.is_match(text) { + Err(LemmyErrorType::BlockedUrl)? + } + Ok(()) +} + #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use pretty_assertions::assert_eq; @@ -109,65 +117,65 @@ mod tests { #[test] fn test_basic_markdown() { let tests: Vec<_> = vec![ - ( - "headings", - "# h1\n## h2\n### h3\n#### h4\n##### h5\n###### h6", - "

h1

\n

h2

\n

h3

\n

h4

\n
h5
\n
h6
\n" - ), - ( - "line breaks", - "First\rSecond", - "

First\nSecond

\n"), - ( - "emphasis", - "__bold__ **bold** *italic* ***bold+italic***", - "

bold bold italic bold+italic

\n" - ), - ( - "blockquotes", - "> #### Hello\n > \n > - Hola\n > - 안영 \n>> Goodbye\n", - "
\n

Hello

\n
    \n
  • Hola
  • \n
  • 안영
  • \n
\n
\n

Goodbye

\n
\n
\n" - ), - ( - "lists (ordered, unordered)", - "1. pen\n2. apple\n3. apple pen\n- pen\n- pineapple\n- pineapple pen", - "
    \n
  1. pen
  2. \n
  3. apple
  4. \n
  5. apple pen
  6. \n
\n
    \n
  • pen
  • \n
  • pineapple
  • \n
  • pineapple pen
  • \n
\n" - ), - ( - "code and code blocks", - "this is my amazing `code snippet` and my amazing ```code block```", - "

this is my amazing code snippet and my amazing code block

\n" - ), - // Links with added nofollow attribute - ( - "links", - "[Lemmy](https://join-lemmy.org/ \"Join Lemmy!\")", - "

Lemmy

\n" - ), - // Remote images with proxy - ( - "images", - "![My linked image](https://example.com/image.png \"image alt text\")", - "

\"My

\n" - ), - // Local images without proxy - ( - "images", - "![My linked image](https://lemmy-alpha/image.png \"image alt text\")", - "

\"My

\n" - ), - // Ensure spoiler plugin is added - ( - "basic spoiler", - "::: spoiler click to see more\nhow spicy!\n:::\n", - "
click to see more

how spicy!\n

\n" - ), - ( - "escape html special chars", - " hello &\"", - "

<script>alert(‘xss’);</script> hello &"

\n" - ) - ]; + ( + "headings", + "# h1\n## h2\n### h3\n#### h4\n##### h5\n###### h6", + "

h1

\n

h2

\n

h3

\n

h4

\n
h5
\n
h6
\n" + ), + ( + "line breaks", + "First\rSecond", + "

First\nSecond

\n"), + ( + "emphasis", + "__bold__ **bold** *italic* ***bold+italic***", + "

bold bold italic bold+italic

\n" + ), + ( + "blockquotes", + "> #### Hello\n > \n > - Hola\n > - 안영 \n>> Goodbye\n", + "
\n

Hello

\n
    \n
  • Hola
  • \n
  • 안영
  • \n
\n
\n

Goodbye

\n
\n
\n" + ), + ( + "lists (ordered, unordered)", + "1. pen\n2. apple\n3. apple pen\n- pen\n- pineapple\n- pineapple pen", + "
    \n
  1. pen
  2. \n
  3. apple
  4. \n
  5. apple pen
  6. \n
\n
    \n
  • pen
  • \n
  • pineapple
  • \n
  • pineapple pen
  • \n
\n" + ), + ( + "code and code blocks", + "this is my amazing `code snippet` and my amazing ```code block```", + "

this is my amazing code snippet and my amazing code block

\n" + ), + // Links with added nofollow attribute + ( + "links", + "[Lemmy](https://join-lemmy.org/ \"Join Lemmy!\")", + "

Lemmy

\n" + ), + // Remote images with proxy + ( + "images", + "![My linked image](https://example.com/image.png \"image alt text\")", + "

\"My

\n" + ), + // Local images without proxy + ( + "images", + "![My linked image](https://lemmy-alpha/image.png \"image alt text\")", + "

\"My

\n" + ), + // Ensure spoiler plugin is added + ( + "basic spoiler", + "::: spoiler click to see more\nhow spicy!\n:::\n", + "
click to see more

how spicy!\n

\n" + ), + ( + "escape html special chars", + " hello &\"", + "

<script>alert(‘xss’);</script> hello &"

\n" + ) + ]; tests.iter().for_each(|&(msg, input, expected)| { let result = markdown_to_html(input); @@ -184,46 +192,46 @@ mod tests { fn test_markdown_proxy_images() { let tests: Vec<_> = vec![ - ( - "remote image proxied", - "![link](http://example.com/image.jpg)", - "![link](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage.jpg)", - ), - ( - "local image unproxied", - "![link](http://lemmy-alpha/image.jpg)", - "![link](http://lemmy-alpha/image.jpg)", - ), - ( - "multiple image links", - "![link](http://example.com/image1.jpg) ![link](http://example.com/image2.jpg)", - "![link](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage1.jpg) ![link](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage2.jpg)", - ), - ( - "empty link handled", - "![image]()", - "![image]()" - ), - ( - "empty label handled", - "![](http://example.com/image.jpg)", - "![](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage.jpg)" - ), - ( - "invalid image link removed", - "![image](http-not-a-link)", - "![image]()" - ), - ( - "label with nested markdown handled", - "![a *b* c](http://example.com/image.jpg)", - "![a *b* c](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage.jpg)" - ), - ( - "custom emoji support", - r#"![party-blob](https://www.hexbear.net/pictrs/image/83405746-0620-4728-9358-5f51b040ffee.gif "emoji party-blob")"#, - r#"![party-blob](https://lemmy-alpha/api/v3/image_proxy?url=https%3A%2F%2Fwww.hexbear.net%2Fpictrs%2Fimage%2F83405746-0620-4728-9358-5f51b040ffee.gif "emoji party-blob")"# - ) + ( + "remote image proxied", + "![link](http://example.com/image.jpg)", + "![link](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage.jpg)", + ), + ( + "local image unproxied", + "![link](http://lemmy-alpha/image.jpg)", + "![link](http://lemmy-alpha/image.jpg)", + ), + ( + "multiple image links", + "![link](http://example.com/image1.jpg) ![link](http://example.com/image2.jpg)", + "![link](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage1.jpg) ![link](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage2.jpg)", + ), + ( + "empty link handled", + "![image]()", + "![image]()" + ), + ( + "empty label handled", + "![](http://example.com/image.jpg)", + "![](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage.jpg)" + ), + ( + "invalid image link removed", + "![image](http-not-a-link)", + "![image]()" + ), + ( + "label with nested markdown handled", + "![a *b* c](http://example.com/image.jpg)", + "![a *b* c](https://lemmy-alpha/api/v3/image_proxy?url=http%3A%2F%2Fexample.com%2Fimage.jpg)" + ), + ( + "custom emoji support", + r#"![party-blob](https://www.hexbear.net/pictrs/image/83405746-0620-4728-9358-5f51b040ffee.gif "emoji party-blob")"#, + r#"![party-blob](https://lemmy-alpha/api/v3/image_proxy?url=https%3A%2F%2Fwww.hexbear.net%2Fpictrs%2Fimage%2F83405746-0620-4728-9358-5f51b040ffee.gif "emoji party-blob")"# + ) ]; tests.iter().for_each(|&(msg, input, expected)| { @@ -237,6 +245,69 @@ mod tests { }); } + #[test] + fn test_url_blocking() { + let set = RegexSet::new(vec![r"(https://)?example\.com/?"]).unwrap(); + + assert!( + markdown_check_for_blocked_urls(&String::from("[](https://example.com)"), &set).is_err() + ); + + assert!(markdown_check_for_blocked_urls( + &String::from("Go to https://example.com to get free Robux"), + &set + ) + .is_err()); + + assert!( + markdown_check_for_blocked_urls(&String::from("[](https://example.blog)"), &set).is_ok() + ); + + assert!(markdown_check_for_blocked_urls(&String::from("example.com"), &set).is_err()); + + assert!(markdown_check_for_blocked_urls( + "Odio exercitationem culpa sed sunt + et. Sit et similique tempora deserunt doloremque. Cupiditate iusto + repellat et quis qui. Cum veritatis facere quasi repellendus sunt + eveniet nemo sint. Cumque sit unde est. https://example.com Alias + repellendus at quos.", + &set + ) + .is_err()); + + let set = RegexSet::new(vec![r"(https://)?example\.com/spam\.jpg"]).unwrap(); + assert!(markdown_check_for_blocked_urls( + &String::from("![](https://example.com/spam.jpg)"), + &set + ) + .is_err()); + + let set = RegexSet::new(vec![ + r"(https://)?quo\.example\.com/?", + r"(https://)?foo\.example\.com/?", + r"(https://)?bar\.example\.com/?", + ]) + .unwrap(); + + assert!( + markdown_check_for_blocked_urls(&String::from("https://baz.example.com"), &set).is_ok() + ); + + assert!( + markdown_check_for_blocked_urls(&String::from("https://bar.example.com"), &set).is_err() + ); + + let set = RegexSet::new(vec![r"(https://)?example\.com/banned_page"]).unwrap(); + + assert!( + markdown_check_for_blocked_urls(&String::from("https://example.com/page"), &set).is_ok() + ); + + let set = RegexSet::new(vec![r"(https://)?ex\.mple\.com/?"]).unwrap(); + + assert!(markdown_check_for_blocked_urls("example.com", &set).is_ok()); + } + #[test] fn test_sanitize_html() { let sanitized = sanitize_html(" hello &\"'"); diff --git a/crates/utils/src/utils/markdown/spoiler_rule.rs b/crates/utils/src/utils/markdown/spoiler_rule.rs index e41ea436f..3f12807fd 100644 --- a/crates/utils/src/utils/markdown/spoiler_rule.rs +++ b/crates/utils/src/utils/markdown/spoiler_rule.rs @@ -134,9 +134,9 @@ pub fn add(markdown_parser: &mut MarkdownIt) { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::utils::markdown::spoiler_rule::add; use markdown_it::MarkdownIt; diff --git a/crates/utils/src/utils/mention.rs b/crates/utils/src/utils/mention.rs index 9e9ee64a2..7e5e5f27c 100644 --- a/crates/utils/src/utils/mention.rs +++ b/crates/utils/src/utils/mention.rs @@ -34,9 +34,9 @@ pub fn scrape_text_for_mentions(text: &str) -> Vec { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod test { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::utils::mention::scrape_text_for_mentions; use pretty_assertions::assert_eq; diff --git a/crates/utils/src/utils/slurs.rs b/crates/utils/src/utils/slurs.rs index fba43d706..e379ae439 100644 --- a/crates/utils/src/utils/slurs.rs +++ b/crates/utils/src/utils/slurs.rs @@ -64,9 +64,9 @@ pub(crate) fn slurs_vec_to_str(slurs: &[&str]) -> String { } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod test { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::utils::slurs::{remove_slurs, slur_check, slurs_vec_to_str}; use pretty_assertions::assert_eq; diff --git a/crates/utils/src/utils/validation.rs b/crates/utils/src/utils/validation.rs index 23ef9744a..93d581327 100644 --- a/crates/utils/src/utils/validation.rs +++ b/crates/utils/src/utils/validation.rs @@ -1,8 +1,8 @@ use crate::error::{LemmyErrorExt, LemmyErrorType, LemmyResult}; use itertools::Itertools; use once_cell::sync::Lazy; -use regex::{Regex, RegexBuilder}; -use url::Url; +use regex::{Regex, RegexBuilder, RegexSet}; +use url::{ParseError, Url}; // From here: https://github.com/vector-im/element-android/blob/develop/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt#L35 static VALID_MATRIX_ID_REGEX: Lazy = Lazy::new(|| { @@ -299,10 +299,37 @@ pub fn check_url_scheme(url: &Option) -> LemmyResult<()> { } } +pub fn is_url_blocked(url: &Option, blocklist: &RegexSet) -> LemmyResult<()> { + if let Some(url) = url { + if blocklist.is_match(url.as_str()) { + Err(LemmyErrorType::BlockedUrl)? + } + } + + Ok(()) +} + +pub fn check_urls_are_valid(urls: &Vec) -> LemmyResult> { + let mut parsed_urls = vec![]; + for url in urls { + let url = Url::parse(url).or_else(|e| { + if e == ParseError::RelativeUrlWithoutBase { + Url::parse(&format!("https://{url}")) + } else { + Err(e) + } + })?; + + parsed_urls.push(url.to_string()); + } + + Ok(parsed_urls) +} + #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use crate::{ error::LemmyErrorType, @@ -310,7 +337,9 @@ mod tests { build_and_check_regex, check_site_visibility_valid, check_url_scheme, + check_urls_are_valid, clean_url_params, + is_url_blocked, is_valid_actor_name, is_valid_bio_field, is_valid_display_name, @@ -550,4 +579,38 @@ mod tests { let magnet_link="magnet:?xt=urn:btih:4b390af3891e323778959d5abfff4b726510f14c&dn=Ravel%20Complete%20Piano%20Sheet%20Music%20-%20Public%20Domain&tr=udp%3A%2F%2Fopen.tracker.cl%3A1337%2Fannounce"; assert!(check_url_scheme(&Some(Url::parse(magnet_link).unwrap())).is_ok()); } + + #[test] + fn test_url_block() { + let set = regex::RegexSet::new(vec![ + r"(https://)?example\.org/page/to/article", + r"(https://)?example\.net/?", + r"(https://)?example\.com/?", + ]) + .unwrap(); + + assert!(is_url_blocked(&Some(Url::parse("https://example.blog").unwrap()), &set).is_ok()); + + assert!(is_url_blocked(&Some(Url::parse("https://example.org").unwrap()), &set).is_ok()); + + assert!(is_url_blocked(&None, &set).is_ok()); + + assert!(is_url_blocked(&Some(Url::parse("https://example.com").unwrap()), &set).is_err()); + } + + #[test] + fn test_url_parsed() { + assert_eq!( + vec![String::from("https://example.com/")], + check_urls_are_valid(&vec![String::from("example.com")]).unwrap() + ); + + assert!(check_urls_are_valid(&vec![ + String::from("example.com"), + String::from("https://example.blog") + ]) + .is_ok()); + + assert!(check_urls_are_valid(&vec![String::from("https://example .com"),]).is_err()); + } } diff --git a/docker/Dockerfile b/docker/Dockerfile index 0630b6e50..39804ee82 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -19,6 +19,7 @@ FROM --platform=${BUILDPLATFORM} ${AMD_BUILDER_IMAGE} AS build-amd64 ARG CARGO_BUILD_FEATURES ARG RUST_RELEASE_MODE +ARG RUSTFLAGS WORKDIR /lemmy @@ -48,6 +49,7 @@ FROM --platform=linux/amd64 ${ARM_BUILDER_IMAGE} AS build-arm64 ARG RUST_RELEASE_MODE ARG CARGO_BUILD_FEATURES +ARG RUSTFLAGS WORKDIR /home/lemmy/src USER 10001:10001 diff --git a/migrations/2024-03-06-201637_url_blocklist/down.sql b/migrations/2024-03-06-201637_url_blocklist/down.sql new file mode 100644 index 000000000..442f3c922 --- /dev/null +++ b/migrations/2024-03-06-201637_url_blocklist/down.sql @@ -0,0 +1,3 @@ +-- This file should undo anything in `up.sql` +DROP TABLE local_site_url_blocklist; + diff --git a/migrations/2024-03-06-201637_url_blocklist/up.sql b/migrations/2024-03-06-201637_url_blocklist/up.sql new file mode 100644 index 000000000..bb9b704b4 --- /dev/null +++ b/migrations/2024-03-06-201637_url_blocklist/up.sql @@ -0,0 +1,7 @@ +CREATE TABLE local_site_url_blocklist ( + id serial NOT NULL PRIMARY KEY, + url text NOT NULL UNIQUE, + published timestamp with time zone NOT NULL DEFAULT now(), + updated timestamp with time zone +); + diff --git a/src/code_migrations.rs b/src/code_migrations.rs index 8e17b8a8c..cee02075c 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -475,7 +475,7 @@ async fn initialize_local_site_2022_10_10( .email(setup.admin_email.clone()) .admin(Some(true)) .build(); - LocalUser::create(pool, &local_user_form).await?; + LocalUser::create(pool, &local_user_form, vec![]).await?; }; // Add an entry for the site table diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index 38eb4ece2..491902fb3 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -517,9 +517,9 @@ async fn update_instance_software( } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use lemmy_routes::nodeinfo::NodeInfo; use pretty_assertions::assert_eq; diff --git a/src/session_middleware.rs b/src/session_middleware.rs index 2c4e36913..2bee64ca0 100644 --- a/src/session_middleware.rs +++ b/src/session_middleware.rs @@ -98,9 +98,9 @@ where } #[cfg(test)] +#[allow(clippy::unwrap_used)] +#[allow(clippy::indexing_slicing)] mod tests { - #![allow(clippy::unwrap_used)] - #![allow(clippy::indexing_slicing)] use super::*; use actix_web::test::TestRequest; @@ -155,7 +155,9 @@ mod tests { .password_encrypted("123456".to_string()) .build(); - let inserted_local_user = LocalUser::create(pool, &local_user_form).await.unwrap(); + let inserted_local_user = LocalUser::create(pool, &local_user_form, vec![]) + .await + .unwrap(); let req = TestRequest::default().to_http_request(); let jwt = Claims::generate(inserted_local_user.id, req, &context)