From 51970ffc8146cf8ad90ca8373b7715f2133f1649 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Wed, 29 May 2024 00:47:21 +0000 Subject: [PATCH 01/74] Update dependencies to alleviate cargo audit peer dependency vulnerability (#4750) --- Cargo.lock | 93 ++++++------------------------------------------------ Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d926aebe3..b358fc82d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,11 +250,9 @@ dependencies = [ "pin-project-lite", "rustls-pki-types", "tokio", - "tokio-rustls 0.23.4", "tokio-rustls 0.26.0", "tokio-util", "tracing", - "webpki-roots 0.22.6", ] [[package]] @@ -2711,7 +2709,7 @@ dependencies = [ "base64 0.21.7", "js-sys", "pem", - "ring 0.17.8", + "ring", "serde", "serde_json", "simple_asn1", @@ -4075,7 +4073,7 @@ dependencies = [ "tracing-subscriber", "url", "uuid", - "webpki-roots 0.26.1", + "webpki-roots", ] [[package]] @@ -4677,7 +4675,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.26.1", + "webpki-roots", "winreg 0.52.0", ] @@ -4766,21 +4764,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9b1a3d5f46d53f4a3478e2be4a5a5ce5108ea58b100dcd139830eae7f79a3a1" -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.8" @@ -4791,7 +4774,7 @@ dependencies = [ "cfg-if", "getrandom", "libc", - "spin 0.9.8", + "spin", "untrusted 0.9.0", "windows-sys 0.52.0", ] @@ -4874,18 +4857,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.20.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" -dependencies = [ - "log", - "ring 0.16.20", - "sct", - "webpki", -] - [[package]] name = "rustls" version = "0.22.4" @@ -4893,7 +4864,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", - "ring 0.17.8", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", @@ -4909,7 +4880,7 @@ dependencies = [ "aws-lc-rs", "log", "once_cell", - "ring 0.17.8", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", @@ -4958,7 +4929,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ "aws-lc-rs", - "ring 0.17.8", + "ring", "rustls-pki-types", "untrusted 0.9.0", ] @@ -5037,16 +5008,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", -] - [[package]] name = "sdd" version = "0.2.0" @@ -5372,12 +5333,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -5821,7 +5776,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04fb792ccd6bbcd4bba408eb8a292f70fc4a3589e5d793626f45190e6454b6ab" dependencies = [ - "ring 0.17.8", + "ring", "rustls 0.23.8", "tokio", "tokio-postgres", @@ -5829,17 +5784,6 @@ dependencies = [ "x509-certificate", ] -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls 0.20.9", - "tokio", - "webpki", -] - [[package]] name = "tokio-rustls" version = "0.25.0" @@ -6627,25 +6571,6 @@ dependencies = [ "url", ] -[[package]] -name = "webpki" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" -dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", -] - -[[package]] -name = "webpki-roots" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] - [[package]] name = "webpki-roots" version = "0.26.1" @@ -6929,7 +6854,7 @@ dependencies = [ "der", "hex", "pem", - "ring 0.17.8", + "ring", "signature", "spki", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 21ca80069..d03d195cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,7 +109,7 @@ serde = { version = "1.0.202", features = ["derive"] } serde_with = "3.8.1" actix-web = { version = "4.6.0", default-features = false, features = [ "macros", - "rustls", + "rustls-0_23", "compress-brotli", "compress-gzip", "compress-zstd", From abcfa266af61bc0c9781e8b7156ac19541844fac Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 29 May 2024 17:03:42 -0400 Subject: [PATCH 02/74] Fixing slowness in saved post fetching. #4756 (#4758) * Fixing slowness in saved post fetching. #4756 * Also fix comment_view.rs --- crates/db_views/src/comment_view.rs | 33 +++++++++------------------ crates/db_views/src/post_view.rs | 35 +++++++++-------------------- crates/federate/src/util.rs | 4 ++-- docker/docker-compose.yml | 2 +- 4 files changed, 24 insertions(+), 50 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 7588943b9..e021578f8 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -1,5 +1,4 @@ use crate::structs::{CommentView, LocalUserView}; -use chrono::{DateTime, Utc}; use diesel::{ dsl::{exists, not}, pg::Pg, @@ -63,17 +62,6 @@ fn queries<'a>() -> Queries< ) }; - let is_saved = |person_id| { - comment_saved::table - .filter( - comment::id - .eq(comment_saved::comment_id) - .and(comment_saved::person_id.eq(person_id)), - ) - .select(comment_saved::published.nullable()) - .single_value() - }; - let is_community_followed = |person_id| { community_follower::table .filter( @@ -147,14 +135,6 @@ fn queries<'a>() -> Queries< Box::new(None::.into_sql::>()) }; - let is_saved_selection: Box< - dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable>, - > = if let Some(person_id) = my_person_id { - Box::new(is_saved(person_id)) - } else { - Box::new(None::>.into_sql::>()) - }; - let is_creator_blocked_selection: Box> = if let Some(person_id) = my_person_id { Box::new(is_creator_blocked(person_id)) @@ -167,6 +147,13 @@ fn queries<'a>() -> Queries< .inner_join(post::table) .inner_join(community::table.on(post::community_id.eq(community::id))) .inner_join(comment_aggregates::table) + .left_join( + comment_saved::table.on( + comment::id + .eq(comment_saved::comment_id) + .and(comment_saved::person_id.eq(my_person_id.unwrap_or(PersonId(-1)))), + ), + ) .select(( comment::all_columns, person::all_columns, @@ -178,7 +165,7 @@ fn queries<'a>() -> Queries< creator_is_moderator, creator_is_admin, subscribed_type_selection, - is_saved_selection.is_not_null(), + comment_saved::person_id.nullable().is_not_null(), is_creator_blocked_selection, score_selection, )) @@ -260,8 +247,8 @@ fn queries<'a>() -> Queries< // If its saved only, then filter, and order by the saved time, not the comment creation time. if options.saved_only { query = query - .filter(is_saved(person_id_join).is_not_null()) - .then_order_by(is_saved(person_id_join).desc()); + .filter(comment_saved::person_id.is_not_null()) + .then_order_by(comment_saved::published.desc()); } if let Some(my_id) = my_person_id { diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index afb0f435f..eac44bb39 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -1,5 +1,4 @@ use crate::structs::{LocalUserView, PaginationCursor, PostView}; -use chrono::{DateTime, Utc}; use diesel::{ debug_query, dsl::{exists, not, IntervalDsl}, @@ -100,17 +99,6 @@ fn queries<'a>() -> Queries< ), ); - let is_saved = |person_id| { - post_saved::table - .filter( - post_aggregates::post_id - .eq(post_saved::post_id) - .and(post_saved::person_id.eq(person_id)), - ) - .select(post_saved::published.nullable()) - .single_value() - }; - let is_read = |person_id| { exists( post_read::table.filter( @@ -162,14 +150,6 @@ fn queries<'a>() -> Queries< 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 { - Box::new(is_saved(person_id)) - } else { - Box::new(None::>.into_sql::>()) - }; - let is_read_selection: Box> = if let Some(person_id) = my_person_id { Box::new(is_read(person_id)) @@ -237,6 +217,13 @@ fn queries<'a>() -> Queries< .inner_join(person::table) .inner_join(community::table) .inner_join(post::table) + .left_join( + post_saved::table.on( + post_aggregates::post_id + .eq(post_saved::post_id) + .and(post_saved::person_id.eq(my_person_id.unwrap_or(PersonId(-1)))), + ), + ) .select(( post::all_columns, person::all_columns, @@ -247,7 +234,7 @@ fn queries<'a>() -> Queries< creator_is_admin, post_aggregates::all_columns, subscribed_type_selection, - is_saved_selection.is_not_null(), + post_saved::person_id.nullable().is_not_null(), is_read_selection, is_hidden_selection, is_creator_blocked_selection, @@ -426,10 +413,10 @@ fn queries<'a>() -> Queries< }; // If its saved only, then filter, and order by the saved time, not the comment creation time. - if let (true, Some(person_id)) = (options.saved_only, my_person_id) { + if let (true, Some(_person_id)) = (options.saved_only, my_person_id) { query = query - .filter(is_saved(person_id).is_not_null()) - .then_order_by(is_saved(person_id).desc()); + .filter(post_saved::person_id.is_not_null()) + .then_order_by(post_saved::published.desc()); } // Only hide the read posts, if the saved_only is false. Otherwise ppl with the hide_read // setting wont be able to see saved posts. diff --git a/crates/federate/src/util.rs b/crates/federate/src/util.rs index 02a90dee9..818e5b072 100644 --- a/crates/federate/src/util.rs +++ b/crates/federate/src/util.rs @@ -59,13 +59,13 @@ pub struct CancellableTask { impl CancellableTask { /// spawn a task but with graceful shutdown - pub fn spawn( + pub fn spawn( timeout: Duration, task: impl FnOnce(CancellationToken) -> F + Send + 'static, ) -> CancellableTask where F: Future> + Send + 'static, - R: Send + 'static, + R: Send + Debug + 'static, { let stop = CancellationToken::new(); let stop2 = stop.clone(); diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index c690a5f48..493b9c205 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -53,7 +53,7 @@ services: lemmy-ui: # use "image" to pull down an already compiled lemmy-ui. make sure to comment out "build". - image: dessalines/lemmy-ui:0.19.3 + image: dessalines/lemmy-ui:0.19.4-rc.3 # platform: linux/x86_64 # no arm64 support. uncomment platform if using m1. # use "build" to build your local lemmy ui image for development. make sure to comment out "image". # run: docker compose up --build From 7d80a3c7d6ead28851cae5b9e19021f1bc4706b6 Mon Sep 17 00:00:00 2001 From: phiresky Date: Wed, 29 May 2024 23:10:25 +0200 Subject: [PATCH 03/74] replace instanceid with domain (#4753) --- crates/federate/src/lib.rs | 10 ++++----- crates/federate/src/stats.rs | 38 +++++++++++------------------------ crates/federate/src/util.rs | 8 ++++++++ crates/federate/src/worker.rs | 12 ++++++----- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/crates/federate/src/lib.rs b/crates/federate/src/lib.rs index d3876226f..0e87b12de 100644 --- a/crates/federate/src/lib.rs +++ b/crates/federate/src/lib.rs @@ -1,10 +1,7 @@ use crate::{util::CancellableTask, worker::InstanceWorker}; use activitypub_federation::config::FederationConfig; use lemmy_api_common::context::LemmyContext; -use lemmy_db_schema::{ - newtypes::InstanceId, - source::{federation_queue_state::FederationQueueState, instance::Instance}, -}; +use lemmy_db_schema::{newtypes::InstanceId, source::instance::Instance}; use lemmy_utils::error::LemmyResult; use stats::receive_print_stats; use std::{collections::HashMap, time::Duration}; @@ -15,6 +12,7 @@ use tokio::{ }; use tokio_util::sync::CancellationToken; use tracing::info; +use util::FederationQueueStateWithDomain; mod stats; mod util; @@ -38,7 +36,7 @@ pub struct SendManager { opts: Opts, workers: HashMap, context: FederationConfig, - stats_sender: UnboundedSender<(InstanceId, FederationQueueState)>, + stats_sender: UnboundedSender, exit_print: JoinHandle<()>, } @@ -171,7 +169,7 @@ mod test { collections::HashSet, sync::{Arc, Mutex}, }; - use tokio::{spawn, time::sleep}; + use tokio::spawn; struct TestData { send_manager: SendManager, diff --git a/crates/federate/src/stats.rs b/crates/federate/src/stats.rs index bb6510263..f927f6ddf 100644 --- a/crates/federate/src/stats.rs +++ b/crates/federate/src/stats.rs @@ -1,15 +1,11 @@ -use crate::util::get_latest_activity_id; +use crate::util::{get_latest_activity_id, FederationQueueStateWithDomain}; use chrono::Local; -use diesel::result::Error::NotFound; use lemmy_api_common::federate_retry_sleep_duration; use lemmy_db_schema::{ newtypes::InstanceId, - source::{federation_queue_state::FederationQueueState, instance::Instance}, utils::{ActualDbPool, DbPool}, }; -use lemmy_utils::{error::LemmyResult, CACHE_DURATION_FEDERATION}; -use moka::future::Cache; -use once_cell::sync::Lazy; +use lemmy_utils::error::LemmyResult; use std::{collections::HashMap, time::Duration}; use tokio::{sync::mpsc::UnboundedReceiver, time::interval}; use tracing::{debug, info, warn}; @@ -18,7 +14,7 @@ use tracing::{debug, info, warn}; /// dropped) pub(crate) async fn receive_print_stats( pool: ActualDbPool, - mut receiver: UnboundedReceiver<(InstanceId, FederationQueueState)>, + mut receiver: UnboundedReceiver, ) { let pool = &mut DbPool::Pool(&pool); let mut printerval = interval(Duration::from_secs(60)); @@ -28,7 +24,7 @@ pub(crate) async fn receive_print_stats( ele = receiver.recv() => { match ele { // update stats for instance - Some((instance_id, ele)) => {stats.insert(instance_id, ele);}, + Some(ele) => {stats.insert(ele.state.instance_id, ele);}, // receiver closed, print stats and exit None => { print_stats(pool, &stats).await; @@ -43,7 +39,10 @@ pub(crate) async fn receive_print_stats( } } -async fn print_stats(pool: &mut DbPool<'_>, stats: &HashMap) { +async fn print_stats( + pool: &mut DbPool<'_>, + stats: &HashMap, +) { let res = print_stats_with_error(pool, stats).await; if let Err(e) = res { warn!("Failed to print stats: {e}"); @@ -52,18 +51,8 @@ async fn print_stats(pool: &mut DbPool<'_>, stats: &HashMap, - stats: &HashMap, + stats: &HashMap, ) -> LemmyResult<()> { - static INSTANCE_CACHE: Lazy>> = Lazy::new(|| { - Cache::builder() - .max_capacity(1) - .time_to_live(CACHE_DURATION_FEDERATION) - .build() - }); - let instances = INSTANCE_CACHE - .try_get_with((), async { Instance::read_all(pool).await }) - .await?; - let last_id = get_latest_activity_id(pool).await?; // it's expected that the values are a bit out of date, everything < SAVE_STATE_EVERY should be @@ -72,12 +61,9 @@ async fn print_stats_with_error( // todo: more stats (act/sec, avg http req duration) let mut ok_count = 0; let mut behind_count = 0; - for (instance_id, stat) in stats { - let domain = &instances - .iter() - .find(|i| &i.id == instance_id) - .ok_or(NotFound)? - .domain; + for ele in stats.values() { + let stat = &ele.state; + let domain = &ele.domain; let behind = last_id.0 - stat.last_successful_id.map(|e| e.0).unwrap_or(0); if stat.fail_count > 0 { info!( diff --git a/crates/federate/src/util.rs b/crates/federate/src/util.rs index 818e5b072..b3d080385 100644 --- a/crates/federate/src/util.rs +++ b/crates/federate/src/util.rs @@ -11,6 +11,7 @@ use lemmy_db_schema::{ source::{ activity::{ActorType, SentActivity}, community::Community, + federation_queue_state::FederationQueueState, person::Person, site::Site, }, @@ -183,3 +184,10 @@ pub(crate) async fn get_latest_activity_id(pool: &mut DbPool<'_>) -> Result>, stop: CancellationToken, context: Data, - stats_sender: UnboundedSender<(InstanceId, FederationQueueState)>, + stats_sender: UnboundedSender, last_full_communities_fetch: DateTime, last_incremental_communities_fetch: DateTime, state: FederationQueueState, @@ -87,7 +88,7 @@ impl InstanceWorker { instance: Instance, context: Data, stop: CancellationToken, - stats_sender: UnboundedSender<(InstanceId, FederationQueueState)>, + stats_sender: UnboundedSender, ) -> Result<(), anyhow::Error> { let mut pool = context.pool(); let state = FederationQueueState::load(&mut pool, instance.id).await?; @@ -350,9 +351,10 @@ impl InstanceWorker { async fn save_and_send_state(&mut self) -> Result<()> { self.last_state_insert = Utc::now(); FederationQueueState::upsert(&mut self.context.pool(), &self.state).await?; - self - .stats_sender - .send((self.instance.id, self.state.clone()))?; + self.stats_sender.send(FederationQueueStateWithDomain { + state: self.state.clone(), + domain: self.instance.domain.clone(), + })?; Ok(()) } } From 91e57ff9541891ea6f7f8e133b1babdfeda1a103 Mon Sep 17 00:00:00 2001 From: Richard Schwab Date: Wed, 29 May 2024 23:55:15 +0200 Subject: [PATCH 04/74] Prevent bot replies from increasing unread reply count when bot accounts are not shown (#4747) * Prevent bot replies from increasing unread reply count when bot accounts are not shown * Pass LocalUser for unread replies count query * Prevent bot mentions from increasing unread reply count when bot accounts are not shown --- Cargo.lock | 1 + api_tests/src/comment.spec.ts | 56 ++++++++++++++- api_tests/src/shared.ts | 7 +- .../local_user/notifications/unread_count.rs | 7 +- crates/db_views_actor/Cargo.toml | 1 + .../db_views_actor/src/comment_reply_view.rs | 71 ++++++++++++++++--- .../db_views_actor/src/person_mention_view.rs | 71 ++++++++++++++++--- 7 files changed, 189 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b358fc82d..d0fc78c43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2946,6 +2946,7 @@ dependencies = [ "diesel", "diesel-async", "lemmy_db_schema", + "lemmy_db_views", "lemmy_utils", "pretty_assertions", "serde", diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index dfab4109c..8c3a23ab5 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -37,8 +37,9 @@ import { followCommunity, blockCommunity, delay, + saveUserSettings, } from "./shared"; -import { CommentView, CommunityView } from "lemmy-js-client"; +import { CommentView, CommunityView, SaveUserSettings } from "lemmy-js-client"; let betaCommunity: CommunityView | undefined; let postOnAlphaRes: PostResponse; @@ -443,6 +444,59 @@ test("Reply to a comment from another instance, get notification", async () => { assertCommentFederation(alphaReply, replyRes.comment_view); }); +test("Bot reply notifications are filtered when bots are hidden", async () => { + const newAlphaBot = await registerUser(alpha, alphaUrl); + let form: SaveUserSettings = { + bot_account: true, + }; + await saveUserSettings(newAlphaBot, form); + + const alphaCommunity = ( + await resolveCommunity(alpha, "!main@lemmy-alpha:8541") + ).community; + + if (!alphaCommunity) { + throw "Missing alpha community"; + } + + await alpha.markAllAsRead(); + form = { + show_bot_accounts: false, + }; + await saveUserSettings(alpha, form); + const postOnAlphaRes = await createPost(alpha, alphaCommunity.community.id); + + // Bot reply to alpha's post + let commentRes = await createComment( + newAlphaBot, + postOnAlphaRes.post_view.post.id, + ); + expect(commentRes).toBeDefined(); + + let alphaUnreadCountRes = await getUnreadCount(alpha); + expect(alphaUnreadCountRes.replies).toBe(0); + + let alphaUnreadRepliesRes = await getReplies(alpha, true); + expect(alphaUnreadRepliesRes.replies.length).toBe(0); + + // This both restores the original state that may be expected by other tests + // implicitly and is used by the next steps to ensure replies are still + // returned when a user later decides to show bot accounts again. + form = { + show_bot_accounts: true, + }; + await saveUserSettings(alpha, form); + + alphaUnreadCountRes = await getUnreadCount(alpha); + expect(alphaUnreadCountRes.replies).toBe(1); + + alphaUnreadRepliesRes = await getReplies(alpha, true); + expect(alphaUnreadRepliesRes.replies.length).toBe(1); + expect(alphaUnreadRepliesRes.replies[0].comment.id).toBe( + commentRes.comment_view.comment.id, + ); +}); + test("Mention beta from alpha", async () => { if (!betaCommunity) throw Error("no community"); const postOnAlphaRes = await createPost(alpha, betaCommunity.community.id); diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 056f25538..2ae3d9e21 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -364,10 +364,13 @@ export async function getUnreadCount( return api.getUnreadCount(); } -export async function getReplies(api: LemmyHttp): Promise { +export async function getReplies( + api: LemmyHttp, + unread_only: boolean = false, +): Promise { let form: GetReplies = { sort: "New", - unread_only: false, + unread_only, }; return api.getReplies(form); } diff --git a/crates/api/src/local_user/notifications/unread_count.rs b/crates/api/src/local_user/notifications/unread_count.rs index 9d06f7c62..4c6c65263 100644 --- a/crates/api/src/local_user/notifications/unread_count.rs +++ b/crates/api/src/local_user/notifications/unread_count.rs @@ -11,9 +11,12 @@ pub async fn unread_count( ) -> LemmyResult> { let person_id = local_user_view.person.id; - let replies = CommentReplyView::get_unread_replies(&mut context.pool(), person_id).await?; + let replies = + CommentReplyView::get_unread_replies(&mut context.pool(), &local_user_view.local_user).await?; - let mentions = PersonMentionView::get_unread_mentions(&mut context.pool(), person_id).await?; + let mentions = + PersonMentionView::get_unread_mentions(&mut context.pool(), &local_user_view.local_user) + .await?; let private_messages = PrivateMessageView::get_unread_messages(&mut context.pool(), person_id).await?; diff --git a/crates/db_views_actor/Cargo.toml b/crates/db_views_actor/Cargo.toml index 1892055d1..d9e6a3352 100644 --- a/crates/db_views_actor/Cargo.toml +++ b/crates/db_views_actor/Cargo.toml @@ -40,6 +40,7 @@ serial_test = { workspace = true } tokio = { workspace = true } pretty_assertions = { workspace = true } url.workspace = true +lemmy_db_views.workspace = true lemmy_utils.workspace = true [package.metadata.cargo-machete] diff --git a/crates/db_views_actor/src/comment_reply_view.rs b/crates/db_views_actor/src/comment_reply_view.rs index 547c00e53..a5939d2e9 100644 --- a/crates/db_views_actor/src/comment_reply_view.rs +++ b/crates/db_views_actor/src/comment_reply_view.rs @@ -31,6 +31,7 @@ use lemmy_db_schema::{ person_block, post, }, + source::local_user::LocalUser, utils::{get_conn, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn}, CommentSortType, }; @@ -193,6 +194,8 @@ fn queries<'a>() -> Queries< }; let list = move |mut conn: DbConn<'a>, options: CommentReplyQuery| async move { + // These filters need to be kept in sync with the filters in + // CommentReplyView::get_unread_replies() let mut query = all_joins(comment_reply::table.into_boxed(), options.my_person_id); if let Some(recipient_id) = options.recipient_id { @@ -204,7 +207,7 @@ fn queries<'a>() -> Queries< } if !options.show_bot_accounts { - query = query.filter(person::bot_account.eq(false)); + query = query.filter(not(person::bot_account)); }; query = match options.sort.unwrap_or(CommentSortType::New) { @@ -246,24 +249,33 @@ impl CommentReplyView { /// Gets the number of unread replies pub async fn get_unread_replies( pool: &mut DbPool<'_>, - my_person_id: PersonId, + local_user: &LocalUser, ) -> Result { use diesel::dsl::count; let conn = &mut get_conn(pool).await?; - comment_reply::table + let mut query = comment_reply::table .inner_join(comment::table) .left_join( person_block::table.on( comment::creator_id .eq(person_block::target_id) - .and(person_block::person_id.eq(my_person_id)), + .and(person_block::person_id.eq(local_user.person_id)), ), ) - // Dont count replies from blocked users + .inner_join(person::table.on(comment::creator_id.eq(person::id))) + .into_boxed(); + + // These filters need to be kept in sync with the filters in queries().list() + if !local_user.show_bot_accounts { + query = query.filter(not(person::bot_account)); + } + + query + // Don't count replies from blocked users .filter(person_block::person_id.is_null()) - .filter(comment_reply::recipient_id.eq(my_person_id)) + .filter(comment_reply::recipient_id.eq(local_user.person_id)) .filter(comment_reply::read.eq(false)) .filter(comment::deleted.eq(false)) .filter(comment::removed.eq(false)) @@ -301,13 +313,15 @@ mod tests { comment_reply::{CommentReply, CommentReplyInsertForm, CommentReplyUpdateForm}, community::{Community, CommunityInsertForm}, instance::Instance, - person::{Person, PersonInsertForm}, + local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm}, + person::{Person, PersonInsertForm, PersonUpdateForm}, person_block::{PersonBlock, PersonBlockForm}, post::{Post, PostInsertForm}, }, traits::{Blockable, Crud}, utils::build_db_pool_for_tests, }; + use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{error::LemmyResult, LemmyErrorType}; use pretty_assertions::assert_eq; use serial_test::serial; @@ -331,11 +345,15 @@ mod tests { .name("terrylakes recipient".into()) .public_key("pubkey".to_string()) .instance_id(inserted_instance.id) + .local(Some(true)) .build(); let inserted_recipient = Person::create(pool, &recipient_form).await?; let recipient_id = inserted_recipient.id; + let recipient_local_user = + LocalUser::create(pool, &LocalUserInsertForm::test_form(recipient_id), vec![]).await?; + let new_community = CommunityInsertForm::builder() .name("test community lake".to_string()) .title("nada".to_owned()) @@ -386,7 +404,7 @@ mod tests { CommentReply::update(pool, inserted_reply.id, &comment_reply_update_form).await?; // Test to make sure counts and blocks work correctly - let unread_replies = CommentReplyView::get_unread_replies(pool, recipient_id).await?; + let unread_replies = CommentReplyView::get_unread_replies(pool, &recipient_local_user).await?; let query = CommentReplyQuery { recipient_id: Some(recipient_id), @@ -409,11 +427,44 @@ mod tests { PersonBlock::block(pool, &block_form).await?; let unread_replies_after_block = - CommentReplyView::get_unread_replies(pool, recipient_id).await?; - let replies_after_block = query.list(pool).await?; + CommentReplyView::get_unread_replies(pool, &recipient_local_user).await?; + let replies_after_block = query.clone().list(pool).await?; assert_eq!(0, unread_replies_after_block); assert_eq!(0, replies_after_block.len()); + // Unblock user so we can reuse the same person + PersonBlock::unblock(pool, &block_form).await?; + + // Turn Terry into a bot account + let person_update_form = PersonUpdateForm { + bot_account: Some(true), + ..Default::default() + }; + Person::update(pool, inserted_terry.id, &person_update_form).await?; + + let recipient_local_user_update_form = LocalUserUpdateForm { + show_bot_accounts: Some(false), + ..Default::default() + }; + LocalUser::update( + pool, + recipient_local_user.id, + &recipient_local_user_update_form, + ) + .await?; + let recipient_local_user_view = LocalUserView::read(pool, recipient_local_user.id) + .await? + .ok_or(LemmyErrorType::CouldntFindLocalUser)?; + + let unread_replies_after_hide_bots = + CommentReplyView::get_unread_replies(pool, &recipient_local_user_view.local_user).await?; + + let mut query_without_bots = query.clone(); + query_without_bots.show_bot_accounts = false; + let replies_after_hide_bots = query_without_bots.list(pool).await?; + assert_eq!(0, unread_replies_after_hide_bots); + assert_eq!(0, replies_after_hide_bots.len()); + Comment::delete(pool, inserted_comment.id).await?; Post::delete(pool, inserted_post.id).await?; Community::delete(pool, inserted_community.id).await?; diff --git a/crates/db_views_actor/src/person_mention_view.rs b/crates/db_views_actor/src/person_mention_view.rs index d42987a68..58ddb011b 100644 --- a/crates/db_views_actor/src/person_mention_view.rs +++ b/crates/db_views_actor/src/person_mention_view.rs @@ -31,6 +31,7 @@ use lemmy_db_schema::{ person_mention, post, }, + source::local_user::LocalUser, utils::{get_conn, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn}, CommentSortType, }; @@ -192,6 +193,8 @@ fn queries<'a>() -> Queries< }; let list = move |mut conn: DbConn<'a>, options: PersonMentionQuery| async move { + // These filters need to be kept in sync with the filters in + // PersonMentionView::get_unread_mentions() let mut query = all_joins(person_mention::table.into_boxed(), options.my_person_id); if let Some(recipient_id) = options.recipient_id { @@ -203,7 +206,7 @@ fn queries<'a>() -> Queries< } if !options.show_bot_accounts { - query = query.filter(person::bot_account.eq(false)); + query = query.filter(not(person::bot_account)); }; query = match options.sort.unwrap_or(CommentSortType::Hot) { @@ -247,23 +250,32 @@ impl PersonMentionView { /// Gets the number of unread mentions pub async fn get_unread_mentions( pool: &mut DbPool<'_>, - my_person_id: PersonId, + local_user: &LocalUser, ) -> Result { use diesel::dsl::count; let conn = &mut get_conn(pool).await?; - person_mention::table + let mut query = person_mention::table .inner_join(comment::table) .left_join( person_block::table.on( comment::creator_id .eq(person_block::target_id) - .and(person_block::person_id.eq(my_person_id)), + .and(person_block::person_id.eq(local_user.person_id)), ), ) - // Dont count replies from blocked users + .inner_join(person::table.on(comment::creator_id.eq(person::id))) + .into_boxed(); + + // These filters need to be kept in sync with the filters in queries().list() + if !local_user.show_bot_accounts { + query = query.filter(not(person::bot_account)); + } + + query + // Don't count replies from blocked users .filter(person_block::person_id.is_null()) - .filter(person_mention::recipient_id.eq(my_person_id)) + .filter(person_mention::recipient_id.eq(local_user.person_id)) .filter(person_mention::read.eq(false)) .filter(comment::deleted.eq(false)) .filter(comment::removed.eq(false)) @@ -300,7 +312,8 @@ mod tests { comment::{Comment, CommentInsertForm}, community::{Community, CommunityInsertForm}, instance::Instance, - person::{Person, PersonInsertForm}, + local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm}, + person::{Person, PersonInsertForm, PersonUpdateForm}, person_block::{PersonBlock, PersonBlockForm}, person_mention::{PersonMention, PersonMentionInsertForm, PersonMentionUpdateForm}, post::{Post, PostInsertForm}, @@ -308,6 +321,7 @@ mod tests { traits::{Blockable, Crud}, utils::build_db_pool_for_tests, }; + use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{error::LemmyResult, LemmyErrorType}; use pretty_assertions::assert_eq; use serial_test::serial; @@ -337,6 +351,9 @@ mod tests { let inserted_recipient = Person::create(pool, &recipient_form).await?; let recipient_id = inserted_recipient.id; + let recipient_local_user = + LocalUser::create(pool, &LocalUserInsertForm::test_form(recipient_id), vec![]).await?; + let new_community = CommunityInsertForm::builder() .name("test community lake".to_string()) .title("nada".to_owned()) @@ -387,7 +404,8 @@ mod tests { PersonMention::update(pool, inserted_mention.id, &person_mention_update_form).await?; // Test to make sure counts and blocks work correctly - let unread_mentions = PersonMentionView::get_unread_mentions(pool, recipient_id).await?; + let unread_mentions = + PersonMentionView::get_unread_mentions(pool, &recipient_local_user).await?; let query = PersonMentionQuery { recipient_id: Some(recipient_id), @@ -410,11 +428,44 @@ mod tests { PersonBlock::block(pool, &block_form).await?; let unread_mentions_after_block = - PersonMentionView::get_unread_mentions(pool, recipient_id).await?; - let mentions_after_block = query.list(pool).await?; + PersonMentionView::get_unread_mentions(pool, &recipient_local_user).await?; + let mentions_after_block = query.clone().list(pool).await?; assert_eq!(0, unread_mentions_after_block); assert_eq!(0, mentions_after_block.len()); + // Unblock user so we can reuse the same person + PersonBlock::unblock(pool, &block_form).await?; + + // Turn Terry into a bot account + let person_update_form = PersonUpdateForm { + bot_account: Some(true), + ..Default::default() + }; + Person::update(pool, inserted_person.id, &person_update_form).await?; + + let recipient_local_user_update_form = LocalUserUpdateForm { + show_bot_accounts: Some(false), + ..Default::default() + }; + LocalUser::update( + pool, + recipient_local_user.id, + &recipient_local_user_update_form, + ) + .await?; + let recipient_local_user_view = LocalUserView::read(pool, recipient_local_user.id) + .await? + .ok_or(LemmyErrorType::CouldntFindLocalUser)?; + + let unread_mentions_after_hide_bots = + PersonMentionView::get_unread_mentions(pool, &recipient_local_user_view.local_user).await?; + + let mut query_without_bots = query.clone(); + query_without_bots.show_bot_accounts = false; + let replies_after_hide_bots = query_without_bots.list(pool).await?; + assert_eq!(0, unread_mentions_after_hide_bots); + assert_eq!(0, replies_after_hide_bots.len()); + Comment::delete(pool, inserted_comment.id).await?; Post::delete(pool, inserted_post.id).await?; Community::delete(pool, inserted_community.id).await?; From e8a7bb07a30a95b922548e69847103b42c18263d Mon Sep 17 00:00:00 2001 From: phiresky Date: Thu, 30 May 2024 11:08:27 +0200 Subject: [PATCH 05/74] fix both permanent stopping of federation queues and multiple creation of the same federation queues (#4754) Co-authored-by: Nutomic --- crates/federate/src/lib.rs | 48 ++++++++++++++++++++++++++++--------- crates/federate/src/util.rs | 21 +++++++++------- src/lib.rs | 5 ++-- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/crates/federate/src/lib.rs b/crates/federate/src/lib.rs index 0e87b12de..21b9229b5 100644 --- a/crates/federate/src/lib.rs +++ b/crates/federate/src/lib.rs @@ -41,7 +41,7 @@ pub struct SendManager { } impl SendManager { - pub fn new(opts: Opts, context: FederationConfig) -> Self { + fn new(opts: Opts, context: FederationConfig) -> Self { assert!(opts.process_count > 0); assert!(opts.process_index > 0); assert!(opts.process_index <= opts.process_count); @@ -59,11 +59,27 @@ impl SendManager { } } - pub fn run(mut self) -> CancellableTask { - CancellableTask::spawn(WORKER_EXIT_TIMEOUT, move |cancel| async move { - self.do_loop(cancel).await?; - self.cancel().await?; - Ok(()) + pub fn run(opts: Opts, context: FederationConfig) -> CancellableTask { + CancellableTask::spawn(WORKER_EXIT_TIMEOUT, move |cancel| { + let opts = opts.clone(); + let context = context.clone(); + let mut manager = Self::new(opts, context); + async move { + let result = manager.do_loop(cancel).await; + // the loop function will only return if there is (a) an internal error (e.g. db connection + // failure) or (b) it was cancelled from outside. + if let Err(e) = result { + // don't let this error bubble up, just log it, so the below cancel function will run + // regardless + tracing::error!("SendManager failed: {e}"); + } + // cancel all the dependent workers as well to ensure they don't get orphaned and keep + // running. + manager.cancel().await?; + LemmyResult::Ok(()) + // if the task was not intentionally cancelled, then this whole lambda will be run again by + // CancellableTask after this + } }) } @@ -102,14 +118,24 @@ impl SendManager { continue; } // create new worker - let instance = instance.clone(); - let req_data = self.context.to_request_data(); + let context = self.context.clone(); let stats_sender = self.stats_sender.clone(); self.workers.insert( instance.id, - CancellableTask::spawn(WORKER_EXIT_TIMEOUT, move |stop| async move { - InstanceWorker::init_and_loop(instance, req_data, stop, stats_sender).await?; - Ok(()) + CancellableTask::spawn(WORKER_EXIT_TIMEOUT, move |stop| { + // if the instance worker ends unexpectedly due to internal/db errors, this lambda is rerun by cancellabletask. + let instance = instance.clone(); + let req_data = context.to_request_data(); + let stats_sender = stats_sender.clone(); + async move { + InstanceWorker::init_and_loop( + instance, + req_data, + stop, + stats_sender, + ) + .await + } }), ); } else if !should_federate { diff --git a/crates/federate/src/util.rs b/crates/federate/src/util.rs index b3d080385..60361c3c9 100644 --- a/crates/federate/src/util.rs +++ b/crates/federate/src/util.rs @@ -18,7 +18,6 @@ use lemmy_db_schema::{ traits::ApubActor, utils::{get_conn, DbPool}, }; -use lemmy_utils::error::LemmyResult; use moka::future::Cache; use once_cell::sync::Lazy; use reqwest::Url; @@ -26,7 +25,6 @@ use serde_json::Value; use std::{fmt::Debug, future::Future, pin::Pin, sync::Arc, time::Duration}; use tokio::{task::JoinHandle, time::sleep}; use tokio_util::sync::CancellationToken; -use tracing::error; /// Decrease the delays of the federation queue. /// Should only be used for federation tests since it significantly increases CPU and DB load of the @@ -62,24 +60,31 @@ impl CancellableTask { /// spawn a task but with graceful shutdown pub fn spawn( timeout: Duration, - task: impl FnOnce(CancellationToken) -> F + Send + 'static, + task: impl Fn(CancellationToken) -> F + Send + 'static, ) -> CancellableTask where - F: Future> + Send + 'static, + F: Future + Send + 'static, R: Send + Debug + 'static, { let stop = CancellationToken::new(); let stop2 = stop.clone(); - let task: JoinHandle> = tokio::spawn(task(stop2)); + let task: JoinHandle<()> = tokio::spawn(async move { + loop { + let res = task(stop2.clone()).await; + if stop2.is_cancelled() { + return; + } else { + tracing::warn!("task exited, restarting: {res:?}"); + } + } + }); let abort = task.abort_handle(); CancellableTask { f: Box::pin(async move { stop.cancel(); tokio::select! { r = task => { - if let Err(ref e) = r? { - error!("CancellableTask threw error: {e}"); - } + r.context("CancellableTask failed to cancel cleanly, returned error")?; Ok(()) }, _ = sleep(timeout) => { diff --git a/src/lib.rs b/src/lib.rs index c2b5e57c2..26740a444 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -210,14 +210,13 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> { None }; let federate = (!args.disable_activity_sending).then(|| { - let task = SendManager::new( + SendManager::run( Opts { process_index: args.federate_process_index, process_count: args.federate_process_count, }, federation_config, - ); - task.run() + ) }); let mut interrupt = tokio::signal::unix::signal(SignalKind::interrupt())?; let mut terminate = tokio::signal::unix::signal(SignalKind::terminate())?; From d2083f79d9a9b33a29139f82a638e61e76bb05f0 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 30 May 2024 11:55:34 +0200 Subject: [PATCH 06/74] Version 0.19.4-rc.4 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0fc78c43..72bdab6a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2735,7 +2735,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2764,7 +2764,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2802,7 +2802,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "accept-language", "activitypub_federation", @@ -2825,7 +2825,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2863,7 +2863,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "anyhow", "clap", @@ -2878,7 +2878,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "activitypub_federation", "anyhow", @@ -2918,7 +2918,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "actix-web", "chrono", @@ -2940,7 +2940,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "chrono", "diesel", @@ -2961,7 +2961,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "diesel", "diesel-async", @@ -2973,7 +2973,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "activitypub_federation", "anyhow", @@ -2998,7 +2998,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "activitypub_federation", "actix-web", @@ -3023,7 +3023,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "activitypub_federation", "actix-cors", @@ -3066,7 +3066,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index d03d195cb..16940d3ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.3" +version = "0.19.4-rc.4" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.3", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.3", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.3", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.3", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.3", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.3", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.3", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.3", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.3", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.3", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.3", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.4", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.4", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.4", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.4", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.4", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.4", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.4", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.4", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.4", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.4", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.4", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } From 96b7afc0b1a96462c7654836a43f1f57a6f3c1aa Mon Sep 17 00:00:00 2001 From: phiresky Date: Fri, 31 May 2024 14:39:45 +0200 Subject: [PATCH 07/74] upgrade rust to 1.78 to fix diesel cli (#4761) --- .woodpecker.yml | 2 +- docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index f8f4eb5f3..b77fd6615 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -2,7 +2,7 @@ # See https://github.com/woodpecker-ci/woodpecker/issues/1677 variables: - - &rust_image "rust:1.77" + - &rust_image "rust:1.78" - &rust_nightly_image "rustlang/rust:nightly" - &install_pnpm "corepack enable pnpm" - &slow_check_paths diff --git a/docker/Dockerfile b/docker/Dockerfile index 25761d3c1..c252204d4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.7 -ARG RUST_VERSION=1.77 +ARG RUST_VERSION=1.78 ARG CARGO_BUILD_FEATURES=default ARG RUST_RELEASE_MODE=debug From 6a6c9150141404c4c307b95040e30d1ce16e34e7 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 31 May 2024 16:38:46 -0400 Subject: [PATCH 08/74] Changing NodeInfo metadata to HashMap from vector. Fixes #4762 (#4764) --- crates/routes/src/nodeinfo.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/routes/src/nodeinfo.rs b/crates/routes/src/nodeinfo.rs index f64bb72c5..17ea20948 100644 --- a/crates/routes/src/nodeinfo.rs +++ b/crates/routes/src/nodeinfo.rs @@ -9,6 +9,7 @@ use lemmy_utils::{ VERSION, }; use serde::{Deserialize, Serialize}; +use std::collections::HashMap; use url::Url; pub fn config(cfg: &mut web::ServiceConfig) { @@ -71,7 +72,7 @@ async fn node_info(context: web::Data) -> Result, /// These fields are required by the spec for no reason pub services: Option, - pub metadata: Option>, + pub metadata: Option>, } #[derive(Serialize, Deserialize, Debug, Default)] From 4d9e38d875307893c33ed47ed3eb5edfb93d1fe3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 21:13:39 -0400 Subject: [PATCH 09/74] Update asonix/pictrs Docker tag to v0.5.14 (#4767) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- docker/docker-compose.yml | 2 +- docker/federation/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 493b9c205..2a04debdd 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -75,7 +75,7 @@ services: init: true pictrs: - image: asonix/pictrs:0.5.13 + image: asonix/pictrs:0.5.14 # this needs to match the pictrs url in lemmy.hjson hostname: pictrs # we can set options to pictrs like this, here we set max. image size and forced format for conversion diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index ac4ef4649..ec131a2b8 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -49,7 +49,7 @@ services: pictrs: restart: always - image: asonix/pictrs:0.5.13 + image: asonix/pictrs:0.5.14 user: 991:991 volumes: - ./volumes/pictrs_alpha:/mnt:Z From 6031709fcf18f9eaf0aac550b2eb186ea1afa100 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 21:14:05 -0400 Subject: [PATCH 10/74] Update Rust crate serde to v1.0.203 (#4766) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72bdab6a7..6a9bf7d03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5057,9 +5057,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -5075,9 +5075,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", From 6db878f7614aa8b7dbf03608c67fbc8d728b6a35 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 21:34:29 -0400 Subject: [PATCH 11/74] Update dependency typescript to v5.4.5 (#4769) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- api_tests/pnpm-lock.yaml | 77 +++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index 42eb612e5..fbf33c90f 100644 --- a/api_tests/pnpm-lock.yaml +++ b/api_tests/pnpm-lock.yaml @@ -16,10 +16,10 @@ importers: version: 20.12.4 '@typescript-eslint/eslint-plugin': specifier: ^7.5.0 - version: 7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.4.4) + version: 7.5.0(@typescript-eslint/parser@7.5.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/parser': specifier: ^7.5.0 - version: 7.5.0(eslint@8.57.0)(typescript@5.4.4) + version: 7.5.0(eslint@8.57.0)(typescript@5.4.5) download-file-sync: specifier: ^1.0.4 version: 1.0.4 @@ -40,10 +40,10 @@ importers: 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.4.4) + version: 29.1.2(@babel/core@7.23.9)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@20.12.4))(typescript@5.4.5) typescript: specifier: ^5.4.4 - version: 5.4.4 + version: 5.4.5 packages: @@ -865,6 +865,7 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} @@ -922,6 +923,7 @@ packages: inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -1380,6 +1382,7 @@ packages: rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true run-parallel@1.2.0: @@ -1539,8 +1542,8 @@ packages: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} - typescript@5.4.4: - resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==} + typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} engines: {node: '>=14.17'} hasBin: true @@ -2113,13 +2116,13 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@typescript-eslint/eslint-plugin@7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.4.4)': + '@typescript-eslint/eslint-plugin@7.5.0(@typescript-eslint/parser@7.5.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)': dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.5.0(eslint@8.57.0)(typescript@5.4.4) + '@typescript-eslint/parser': 7.5.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/scope-manager': 7.5.0 - '@typescript-eslint/type-utils': 7.5.0(eslint@8.57.0)(typescript@5.4.4) - '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.4) + '@typescript-eslint/type-utils': 7.5.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/visitor-keys': 7.5.0 debug: 4.3.4 eslint: 8.57.0 @@ -2127,20 +2130,22 @@ snapshots: ignore: 5.3.1 natural-compare: 1.4.0 semver: 7.6.0 - ts-api-utils: 1.3.0(typescript@5.4.4) - typescript: 5.4.4 + ts-api-utils: 1.3.0(typescript@5.4.5) + optionalDependencies: + typescript: 5.4.5 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@7.5.0(eslint@8.57.0)(typescript@5.4.4)': + '@typescript-eslint/parser@7.5.0(eslint@8.57.0)(typescript@5.4.5)': dependencies: '@typescript-eslint/scope-manager': 7.5.0 '@typescript-eslint/types': 7.5.0 - '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4) + '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.5) '@typescript-eslint/visitor-keys': 7.5.0 debug: 4.3.4 eslint: 8.57.0 - typescript: 5.4.4 + optionalDependencies: + typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -2149,20 +2154,21 @@ snapshots: '@typescript-eslint/types': 7.5.0 '@typescript-eslint/visitor-keys': 7.5.0 - '@typescript-eslint/type-utils@7.5.0(eslint@8.57.0)(typescript@5.4.4)': + '@typescript-eslint/type-utils@7.5.0(eslint@8.57.0)(typescript@5.4.5)': dependencies: - '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4) - '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.4) + '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.5) + '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.5) debug: 4.3.4 eslint: 8.57.0 - ts-api-utils: 1.3.0(typescript@5.4.4) - typescript: 5.4.4 + ts-api-utils: 1.3.0(typescript@5.4.5) + optionalDependencies: + typescript: 5.4.5 transitivePeerDependencies: - supports-color '@typescript-eslint/types@7.5.0': {} - '@typescript-eslint/typescript-estree@7.5.0(typescript@5.4.4)': + '@typescript-eslint/typescript-estree@7.5.0(typescript@5.4.5)': dependencies: '@typescript-eslint/types': 7.5.0 '@typescript-eslint/visitor-keys': 7.5.0 @@ -2171,19 +2177,20 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.3 semver: 7.6.0 - ts-api-utils: 1.3.0(typescript@5.4.4) - typescript: 5.4.4 + ts-api-utils: 1.3.0(typescript@5.4.5) + optionalDependencies: + typescript: 5.4.5 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@7.5.0(eslint@8.57.0)(typescript@5.4.4)': + '@typescript-eslint/utils@7.5.0(eslint@8.57.0)(typescript@5.4.5)': dependencies: '@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.5.0 '@typescript-eslint/types': 7.5.0 - '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4) + '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.5) eslint: 8.57.0 semver: 7.6.0 transitivePeerDependencies: @@ -2791,7 +2798,6 @@ snapshots: '@babel/core': 7.23.9 '@jest/test-sequencer': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.4 babel-jest: 29.7.0(@babel/core@7.23.9) chalk: 4.1.2 ci-info: 3.9.0 @@ -2811,6 +2817,8 @@ snapshots: pretty-format: 29.7.0 slash: 3.0.0 strip-json-comments: 3.1.1 + optionalDependencies: + '@types/node': 20.12.4 transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -2892,7 +2900,7 @@ snapshots: jest-util: 29.7.0 jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): - dependencies: + optionalDependencies: jest-resolve: 29.7.0 jest-regex-util@29.6.3: {} @@ -3357,13 +3365,12 @@ snapshots: dependencies: is-number: 7.0.0 - ts-api-utils@1.3.0(typescript@5.4.4): + ts-api-utils@1.3.0(typescript@5.4.5): dependencies: - typescript: 5.4.4 + typescript: 5.4.5 - ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.4.4): + ts-jest@29.1.2(@babel/core@7.23.9)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@20.12.4))(typescript@5.4.5): dependencies: - '@babel/core': 7.23.9 bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 jest: 29.7.0(@types/node@20.12.4) @@ -3372,8 +3379,12 @@ snapshots: lodash.memoize: 4.1.2 make-error: 1.3.6 semver: 7.5.4 - typescript: 5.4.4 + typescript: 5.4.5 yargs-parser: 21.1.1 + optionalDependencies: + '@babel/core': 7.23.9 + '@jest/types': 29.6.3 + babel-jest: 29.7.0(@babel/core@7.23.9) tslib@2.6.2: {} @@ -3387,7 +3398,7 @@ snapshots: type-fest@0.21.3: {} - typescript@5.4.4: {} + typescript@5.4.5: {} undici-types@5.26.5: {} From 44666a34a223296e60a7a19013608f8bf58eebbf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 22:04:44 -0400 Subject: [PATCH 12/74] Update dependency ts-jest to v29.1.4 (#4768) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- api_tests/pnpm-lock.yaml | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index fbf33c90f..a10c03298 100644 --- a/api_tests/pnpm-lock.yaml +++ b/api_tests/pnpm-lock.yaml @@ -40,7 +40,7 @@ importers: version: 3.2.5 ts-jest: specifier: ^29.1.0 - version: 29.1.2(@babel/core@7.23.9)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@20.12.4))(typescript@5.4.5) + version: 29.1.4(@babel/core@7.23.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@20.12.4))(typescript@5.4.5) typescript: specifier: ^5.4.4 version: 5.4.5 @@ -1392,13 +1392,13 @@ packages: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true - semver@7.5.4: - resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} + semver@7.6.0: + resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} engines: {node: '>=10'} hasBin: true - semver@7.6.0: - resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} + semver@7.6.2: + resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==} engines: {node: '>=10'} hasBin: true @@ -1502,12 +1502,13 @@ packages: peerDependencies: typescript: '>=4.2.0' - ts-jest@29.1.2: - resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==} - engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0} + ts-jest@29.1.4: + resolution: {integrity: sha512-YiHwDhSvCiItoAgsKtoLFCuakDzDsJ1DLDnSouTaTmdOcOwIkSzbLXduaQ6M5DRVhuZC/NYaaZ/mtHbWMv/S6Q==} + engines: {node: ^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: '@babel/core': '>=7.0.0-beta.0 <8' + '@jest/transform': ^29.0.0 '@jest/types': ^29.0.0 babel-jest: ^29.0.0 esbuild: '*' @@ -1516,6 +1517,8 @@ packages: peerDependenciesMeta: '@babel/core': optional: true + '@jest/transform': + optional: true '@jest/types': optional: true babel-jest: @@ -2176,7 +2179,7 @@ snapshots: globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 - semver: 7.6.0 + semver: 7.6.2 ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: typescript: 5.4.5 @@ -2719,7 +2722,7 @@ snapshots: '@babel/parser': 7.23.9 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 - semver: 7.5.4 + semver: 7.6.2 transitivePeerDependencies: - supports-color @@ -2998,7 +3001,7 @@ snapshots: jest-util: 29.7.0 natural-compare: 1.4.0 pretty-format: 29.7.0 - semver: 7.5.4 + semver: 7.6.2 transitivePeerDependencies: - supports-color @@ -3112,7 +3115,7 @@ snapshots: make-dir@4.0.0: dependencies: - semver: 7.5.4 + semver: 7.6.2 make-error@1.3.6: {} @@ -3276,14 +3279,12 @@ snapshots: semver@6.3.1: {} - semver@7.5.4: - dependencies: - lru-cache: 6.0.0 - semver@7.6.0: dependencies: lru-cache: 6.0.0 + semver@7.6.2: {} + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 @@ -3369,7 +3370,7 @@ snapshots: dependencies: typescript: 5.4.5 - ts-jest@29.1.2(@babel/core@7.23.9)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@20.12.4))(typescript@5.4.5): + ts-jest@29.1.4(@babel/core@7.23.9)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(jest@29.7.0(@types/node@20.12.4))(typescript@5.4.5): dependencies: bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 @@ -3378,11 +3379,12 @@ snapshots: json5: 2.2.3 lodash.memoize: 4.1.2 make-error: 1.3.6 - semver: 7.5.4 + semver: 7.6.2 typescript: 5.4.5 yargs-parser: 21.1.1 optionalDependencies: '@babel/core': 7.23.9 + '@jest/transform': 29.7.0 '@jest/types': 29.6.3 babel-jest: 29.7.0(@babel/core@7.23.9) From 609a6411a7514ddcdd9b732470cca628f7408934 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 22:24:17 -0400 Subject: [PATCH 13/74] Update pnpm to v9.1.4 (#4770) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- api_tests/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_tests/package.json b/api_tests/package.json index b194dae30..31fbe2161 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -6,7 +6,7 @@ "repository": "https://github.com/LemmyNet/lemmy", "author": "Dessalines", "license": "AGPL-3.0", - "packageManager": "pnpm@9.1.1+sha256.9551e803dcb7a1839fdf5416153a844060c7bce013218ce823410532504ac10b", + "packageManager": "pnpm@9.1.4", "scripts": { "lint": "tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx src && prettier --check 'src/**/*.ts'", "fix": "prettier --write src && eslint --fix src", From f7fe0d46fcd0c1cd81c0d526c1699dc5fc463d07 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 22:35:34 -0400 Subject: [PATCH 14/74] Update Rust crate console-subscriber to 0.2.0 (#4771) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 83 ++++-------------------------------------------------- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a9bf7d03..7b9668f47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,18 +1108,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "console-api" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" -dependencies = [ - "prost 0.11.9", - "prost-types 0.11.9", - "tonic 0.9.2", - "tracing-core", -] - [[package]] name = "console-api" version = "0.6.0" @@ -1128,48 +1116,24 @@ checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" dependencies = [ "futures-core", "prost 0.12.6", - "prost-types 0.12.6", + "prost-types", "tonic 0.10.2", "tracing-core", ] -[[package]] -name = "console-subscriber" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4cf42660ac07fcebed809cfe561dd8730bcd35b075215e6479c516bcd0d11cb" -dependencies = [ - "console-api 0.5.0", - "crossbeam-channel", - "crossbeam-utils", - "futures", - "hdrhistogram", - "humantime", - "prost-types 0.11.9", - "serde", - "serde_json", - "thread_local", - "tokio", - "tokio-stream", - "tonic 0.9.2", - "tracing", - "tracing-core", - "tracing-subscriber", -] - [[package]] name = "console-subscriber" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e" dependencies = [ - "console-api 0.6.0", + "console-api", "crossbeam-channel", "crossbeam-utils", "futures-task", "hdrhistogram", "humantime", - "prost-types 0.12.6", + "prost-types", "serde", "serde_json", "thread_local", @@ -3032,7 +2996,7 @@ dependencies = [ "chrono", "clap", "clokwerk", - "console-subscriber 0.1.10", + "console-subscriber", "diesel", "diesel-async", "futures-util", @@ -4028,7 +3992,7 @@ dependencies = [ "clap", "color-eyre", "config", - "console-subscriber 0.2.0", + "console-subscriber", "dashmap", "diesel", "diesel-async", @@ -4337,15 +4301,6 @@ dependencies = [ "syn 2.0.65", ] -[[package]] -name = "prost-types" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" -dependencies = [ - "prost 0.11.9", -] - [[package]] name = "prost-types" version = "0.12.6" @@ -5922,34 +5877,6 @@ dependencies = [ "tracing-futures", ] -[[package]] -name = "tonic" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" -dependencies = [ - "async-trait", - "axum", - "base64 0.21.7", - "bytes", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost 0.11.9", - "tokio", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tonic" version = "0.10.2" diff --git a/Cargo.toml b/Cargo.toml index 16940d3ff..bb8b44888 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -194,7 +194,7 @@ clokwerk = { workspace = true } serde_json = { workspace = true } tracing-opentelemetry = { workspace = true, optional = true } opentelemetry = { workspace = true, optional = true } -console-subscriber = { version = "0.1.10", optional = true } +console-subscriber = { version = "0.2.0", optional = true } opentelemetry-otlp = { version = "0.12.0", optional = true } pict-rs = { version = "0.5.14", optional = true } tokio.workspace = true From 69b4c6647b0688753bffa83f1c74d7df992bf7b2 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 1 Jun 2024 13:30:00 -0400 Subject: [PATCH 15/74] Version 0.19.4-rc.5 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ crates/utils/translations | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b9668f47..18b6b3082 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2699,7 +2699,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "activitypub_federation", "actix-web", @@ -2728,7 +2728,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "activitypub_federation", "actix-web", @@ -2766,7 +2766,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "accept-language", "activitypub_federation", @@ -2789,7 +2789,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "activitypub_federation", "actix-web", @@ -2827,7 +2827,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "anyhow", "clap", @@ -2842,7 +2842,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "activitypub_federation", "anyhow", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "actix-web", "chrono", @@ -2904,7 +2904,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "chrono", "diesel", @@ -2925,7 +2925,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "diesel", "diesel-async", @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "activitypub_federation", "anyhow", @@ -2962,7 +2962,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "activitypub_federation", "actix-web", @@ -2987,7 +2987,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "activitypub_federation", "actix-cors", @@ -3030,7 +3030,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index bb8b44888..60babeb1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.4" +version = "0.19.4-rc.5" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.4", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.4", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.4", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.4", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.4", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.4", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.4", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.4", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.4", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.4", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.4", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.5", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.5", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.5", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.5", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.5", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.5", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.5", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.5", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.5", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.5", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.5", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } diff --git a/crates/utils/translations b/crates/utils/translations index e9b3b25fa..dca5d8ca0 160000 --- a/crates/utils/translations +++ b/crates/utils/translations @@ -1 +1 @@ -Subproject commit e9b3b25fa1af7e06c4ffab86624d95da0836ef36 +Subproject commit dca5d8ca0309d7cb07eaca821140e4525e75ee57 From 4195a9b5a1501bffd2c7e9f1bfd8dba76959e013 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 3 Jun 2024 17:30:00 -0400 Subject: [PATCH 16/74] Fetch nodeinfo href from .well-known/nodeinfo . Fixes #4757 (#4765) * Fetch nodeinfo href from .well-known/nodeinfo . Fixes #4757 * Addressing PR comments. * Fixing clippy. * Adding tests. --- crates/routes/src/nodeinfo.rs | 4 +- src/scheduled_tasks.rs | 162 ++++++++++++++++++++++------------ 2 files changed, 108 insertions(+), 58 deletions(-) diff --git a/crates/routes/src/nodeinfo.rs b/crates/routes/src/nodeinfo.rs index 17ea20948..88cf3b4ad 100644 --- a/crates/routes/src/nodeinfo.rs +++ b/crates/routes/src/nodeinfo.rs @@ -79,12 +79,12 @@ async fn node_info(context: web::Data) -> Result, } #[derive(Serialize, Deserialize, Debug)] -struct NodeInfoWellKnownLinks { +pub struct NodeInfoWellKnownLinks { pub rel: Url, pub href: Url, } diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index e591842c6..87a2cdfb8 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -28,7 +28,7 @@ use lemmy_db_schema::{ }, utils::{get_conn, naive_now, now, DbPool, DELETED_REPLACEMENT_TEXT}, }; -use lemmy_routes::nodeinfo::NodeInfo; +use lemmy_routes::nodeinfo::{NodeInfo, NodeInfoWellKnown}; use lemmy_utils::error::LemmyResult; use reqwest_middleware::ClientWithMiddleware; use std::time::Duration; @@ -450,7 +450,10 @@ async fn update_banned_when_expired(pool: &mut DbPool<'_>) { } } -/// Updates the instance software and version +/// Updates the instance software and version. +/// +/// Does so using the /.well-known/nodeinfo protocol described here: +/// https://github.com/jhass/nodeinfo/blob/main/PROTOCOL.md /// /// TODO: if instance has been dead for a long time, it should be checked less frequently async fn update_instance_software( @@ -465,46 +468,7 @@ async fn update_instance_software( let instances = instance::table.get_results::(&mut conn).await?; for instance in instances { - let node_info_url = format!("https://{}/nodeinfo/2.0.json", instance.domain); - - // The `updated` column is used to check if instances are alive. If it is more than three - // days in the past, no outgoing activities will be sent to that instance. However - // not every Fediverse instance has a valid Nodeinfo endpoint (its not required for - // Activitypub). That's why we always need to mark instances as updated if they are - // alive. - let default_form = InstanceForm::builder() - .domain(instance.domain.clone()) - .updated(Some(naive_now())) - .build(); - let form = match client.get(&node_info_url).send().await { - Ok(res) if res.status().is_client_error() => { - // Instance doesn't have nodeinfo but sent a response, consider it alive - Some(default_form) - } - Ok(res) => match res.json::().await { - Ok(node_info) => { - // Instance sent valid nodeinfo, write it to db - let software = node_info.software.as_ref(); - Some( - InstanceForm::builder() - .domain(instance.domain) - .updated(Some(naive_now())) - .software(software.and_then(|s| s.name.clone())) - .version(software.and_then(|s| s.version.clone())) - .build(), - ) - } - Err(_) => { - // No valid nodeinfo but valid HTTP response, consider instance alive - Some(default_form) - } - }, - Err(_) => { - // dead instance, do nothing - None - } - }; - if let Some(form) = form { + if let Some(form) = build_update_instance_form(&instance.domain, client).await { Instance::update(pool, instance.id, form).await?; } } @@ -517,28 +481,114 @@ async fn update_instance_software( Ok(()) } +/// This builds an instance update form, for a given domain. +/// If the instance sends a response, but doesn't have a well-known or nodeinfo, +/// Then return a default form with only the updated field. +/// +/// TODO This function is a bit of a nightmare with its embedded matches, but the only other way +/// would be to extract the fetches into functions which return the default_form on errors. +async fn build_update_instance_form( + domain: &str, + client: &ClientWithMiddleware, +) -> Option { + // The `updated` column is used to check if instances are alive. If it is more than three + // days in the past, no outgoing activities will be sent to that instance. However + // not every Fediverse instance has a valid Nodeinfo endpoint (its not required for + // Activitypub). That's why we always need to mark instances as updated if they are + // alive. + let mut instance_form = InstanceForm::builder() + .domain(domain.to_string()) + .updated(Some(naive_now())) + .build(); + + // First, fetch their /.well-known/nodeinfo, then extract the correct nodeinfo link from it + let well_known_url = format!("https://{}/.well-known/nodeinfo", domain); + + match client.get(&well_known_url).send().await { + Ok(res) if res.status().is_client_error() => { + // Instance doesn't have well-known but sent a response, consider it alive + Some(instance_form) + } + Ok(res) => match res.json::().await { + Ok(well_known) => { + // Find the first link where the rel contains the allowed rels above + match well_known.links.into_iter().find(|links| { + links + .rel + .as_str() + .starts_with("http://nodeinfo.diaspora.software/ns/schema/2.") + }) { + Some(well_known_link) => { + let node_info_url = well_known_link.href; + + // Fetch the node_info from the well known href + match client.get(node_info_url).send().await { + Ok(node_info_res) => match node_info_res.json::().await { + Ok(node_info) => { + // Instance sent valid nodeinfo, write it to db + // Set the instance form fields. + if let Some(software) = node_info.software.as_ref() { + instance_form.software.clone_from(&software.name); + instance_form.version.clone_from(&software.version); + } + Some(instance_form) + } + Err(_) => Some(instance_form), + }, + Err(_) => Some(instance_form), + } + } + // If none is found, use the default form above + None => Some(instance_form), + } + } + Err(_) => { + // No valid nodeinfo but valid HTTP response, consider instance alive + Some(instance_form) + } + }, + Err(_) => { + // dead instance, do nothing + None + } + } +} #[cfg(test)] -#[allow(clippy::unwrap_used)] #[allow(clippy::indexing_slicing)] mod tests { - use lemmy_routes::nodeinfo::NodeInfo; + use crate::scheduled_tasks::build_update_instance_form; + use lemmy_api_common::request::client_builder; + use lemmy_utils::{error::LemmyResult, settings::structs::Settings, LemmyErrorType}; use pretty_assertions::assert_eq; - use reqwest::Client; + use reqwest_middleware::ClientBuilder; + use serial_test::serial; #[tokio::test] - #[ignore] - async fn test_nodeinfo() { - let client = Client::builder().build().unwrap(); - let lemmy_ml_nodeinfo = client - .get("https://lemmy.ml/nodeinfo/2.0.json") - .send() + #[serial] + async fn test_nodeinfo_voyager_lemmy_ml() -> LemmyResult<()> { + let client = ClientBuilder::new(client_builder(&Settings::default()).build()?).build(); + let form = build_update_instance_form("voyager.lemmy.ml", &client) .await - .unwrap() - .json::() - .await - .unwrap(); + .ok_or(LemmyErrorType::CouldntFindObject)?; + assert_eq!( + form.software.ok_or(LemmyErrorType::CouldntFindObject)?, + "lemmy" + ); + Ok(()) + } - assert_eq!(lemmy_ml_nodeinfo.software.unwrap().name.unwrap(), "lemmy"); + #[tokio::test] + #[serial] + async fn test_nodeinfo_mastodon_social() -> LemmyResult<()> { + let client = ClientBuilder::new(client_builder(&Settings::default()).build()?).build(); + let form = build_update_instance_form("mastodon.social", &client) + .await + .ok_or(LemmyErrorType::CouldntFindObject)?; + assert_eq!( + form.software.ok_or(LemmyErrorType::CouldntFindObject)?, + "mastodon" + ); + Ok(()) } } From aefb41b551f81da4874c6198c17b0d877670a6f3 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 3 Jun 2024 17:30:16 -0400 Subject: [PATCH 17/74] Remove .json from nodeinfo urls, according to spec. (#4773) --- crates/routes/src/nodeinfo.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/routes/src/nodeinfo.rs b/crates/routes/src/nodeinfo.rs index 88cf3b4ad..bcb835309 100644 --- a/crates/routes/src/nodeinfo.rs +++ b/crates/routes/src/nodeinfo.rs @@ -12,15 +12,18 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use url::Url; +/// A description of the nodeinfo endpoint is here: +/// https://github.com/jhass/nodeinfo/blob/main/PROTOCOL.md pub fn config(cfg: &mut web::ServiceConfig) { cfg .route( - "/nodeinfo/2.1.json", + "/nodeinfo/2.1", web::get().to(node_info).wrap(cache_1hour()), ) - .service(web::redirect("/version", "/nodeinfo/2.1.json")) + .service(web::redirect("/version", "/nodeinfo/2.1")) // For backwards compatibility, can be removed after Lemmy 0.20 - .service(web::redirect("/nodeinfo/2.0.json", "/nodeinfo/2.1.json")) + .service(web::redirect("/nodeinfo/2.0.json", "/nodeinfo/2.1")) + .service(web::redirect("/nodeinfo/2.1.json", "/nodeinfo/2.1")) .route( "/.well-known/nodeinfo", web::get().to(node_info_well_known).wrap(cache_3days()), @@ -32,7 +35,7 @@ async fn node_info_well_known(context: web::Data) -> LemmyResult Date: Tue, 4 Jun 2024 05:04:16 -0700 Subject: [PATCH 18/74] Clean up build_update_instance_form in scheduled_tasks.rs (#4775) * Clean up build_update_instance_form in scheduled_tasks.rs * remove unused import --- src/scheduled_tasks.rs | 89 +++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 48 deletions(-) diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index 87a2cdfb8..2885b5f74 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -484,9 +484,6 @@ async fn update_instance_software( /// This builds an instance update form, for a given domain. /// If the instance sends a response, but doesn't have a well-known or nodeinfo, /// Then return a default form with only the updated field. -/// -/// TODO This function is a bit of a nightmare with its embedded matches, but the only other way -/// would be to extract the fetches into functions which return the default_form on errors. async fn build_update_instance_form( domain: &str, client: &ClientWithMiddleware, @@ -504,55 +501,51 @@ async fn build_update_instance_form( // First, fetch their /.well-known/nodeinfo, then extract the correct nodeinfo link from it let well_known_url = format!("https://{}/.well-known/nodeinfo", domain); - match client.get(&well_known_url).send().await { - Ok(res) if res.status().is_client_error() => { - // Instance doesn't have well-known but sent a response, consider it alive - Some(instance_form) - } - Ok(res) => match res.json::().await { - Ok(well_known) => { - // Find the first link where the rel contains the allowed rels above - match well_known.links.into_iter().find(|links| { - links - .rel - .as_str() - .starts_with("http://nodeinfo.diaspora.software/ns/schema/2.") - }) { - Some(well_known_link) => { - let node_info_url = well_known_link.href; + let Ok(res) = client.get(&well_known_url).send().await else { + // This is the only kind of error that means the instance is dead + return None; + }; - // Fetch the node_info from the well known href - match client.get(node_info_url).send().await { - Ok(node_info_res) => match node_info_res.json::().await { - Ok(node_info) => { - // Instance sent valid nodeinfo, write it to db - // Set the instance form fields. - if let Some(software) = node_info.software.as_ref() { - instance_form.software.clone_from(&software.name); - instance_form.version.clone_from(&software.version); - } - Some(instance_form) - } - Err(_) => Some(instance_form), - }, - Err(_) => Some(instance_form), - } - } - // If none is found, use the default form above - None => Some(instance_form), - } - } - Err(_) => { - // No valid nodeinfo but valid HTTP response, consider instance alive - Some(instance_form) - } - }, - Err(_) => { - // dead instance, do nothing - None + // In this block, returning `None` is ignored, and only means not writing nodeinfo to db + async { + if res.status().is_client_error() { + return None; } + + let node_info_url = res + .json::() + .await + .ok()? + .links + .into_iter() + .find(|links| { + links + .rel + .as_str() + .starts_with("http://nodeinfo.diaspora.software/ns/schema/2.") + })? + .href; + + let software = client + .get(node_info_url) + .send() + .await + .ok()? + .json::() + .await + .ok()? + .software?; + + instance_form.software = software.name; + instance_form.version = software.version; + + Some(()) } + .await; + + Some(instance_form) } + #[cfg(test)] #[allow(clippy::indexing_slicing)] mod tests { From 8bf17946bd8dc1223e1d2c0a48cad1afb15e8413 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 4 Jun 2024 08:28:22 -0400 Subject: [PATCH 19/74] Fix issue with avatar / icon deletion when saving settings. (#4774) * Fix issue with avatar / icon deletion when saving settings. - Fixes #4763 * Update crates/api_common/src/request.rs Co-authored-by: dullbananas * Fixing an existing test, and adding another for replace images. --------- Co-authored-by: dullbananas --- api_tests/src/user.spec.ts | 8 +++++++- crates/api_common/src/request.rs | 13 ++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index f44f3cc0a..4f91cbd87 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -186,10 +186,16 @@ test("Set a new avatar, old avatar is deleted", async () => { expect(upload2.url).toBeDefined(); let form2 = { - avatar: upload1.url, + avatar: upload2.url, }; await saveUserSettings(alpha, form2); // make sure only the new avatar is kept const listMediaRes2 = await alphaImage.listMedia(); expect(listMediaRes2.images.length).toBe(1); + + // Upload that same form2 avatar, make sure it isn't replaced / deleted + await saveUserSettings(alpha, form2); + // make sure only the new avatar is kept + const listMediaRes3 = await alphaImage.listMedia(); + expect(listMediaRes3.images.length).toBe(1); }); diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index c304bcba7..9bfb97b72 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -338,16 +338,19 @@ async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Lemm } } -/// When adding a new avatar or similar image, delete the old one. +/// When adding a new avatar, banner or similar image, delete the old one. pub async fn replace_image( new_image: &Option, old_image: &Option, context: &Data, ) -> LemmyResult<()> { - if new_image.is_some() { - // Ignore errors because image may be stored externally. - if let Some(avatar) = &old_image { - let image = LocalImage::delete_by_url(&mut context.pool(), avatar) + if let (Some(new_image), Some(old_image)) = (new_image, old_image) { + // Note: Oftentimes front ends will include the current image in the form. + // In this case, deleting `old_image` would also be deletion of `new_image`, + // so the deletion must be skipped for the image to be kept. + if new_image != old_image.as_str() { + // Ignore errors because image may be stored externally. + let image = LocalImage::delete_by_url(&mut context.pool(), old_image) .await .ok(); if let Some(image) = image { From a947474c6425532cf2188111b96c5b4ba5177494 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 4 Jun 2024 08:32:08 -0400 Subject: [PATCH 20/74] Version 0.19.4-rc.6 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18b6b3082..154c684a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2699,7 +2699,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "activitypub_federation", "actix-web", @@ -2728,7 +2728,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "activitypub_federation", "actix-web", @@ -2766,7 +2766,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "accept-language", "activitypub_federation", @@ -2789,7 +2789,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "activitypub_federation", "actix-web", @@ -2827,7 +2827,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "anyhow", "clap", @@ -2842,7 +2842,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "activitypub_federation", "anyhow", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "actix-web", "chrono", @@ -2904,7 +2904,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "chrono", "diesel", @@ -2925,7 +2925,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "diesel", "diesel-async", @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "activitypub_federation", "anyhow", @@ -2962,7 +2962,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "activitypub_federation", "actix-web", @@ -2987,7 +2987,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "activitypub_federation", "actix-cors", @@ -3030,7 +3030,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 60babeb1d..472b61692 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.5" +version = "0.19.4-rc.6" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.5", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.5", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.5", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.5", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.5", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.5", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.5", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.5", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.5", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.5", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.5", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.6", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.6", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.6", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.6", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.6", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.6", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.6", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.6", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.6", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.6", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.6", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } From 78ae874b89e0ab51e407b9daaed8e28f452960cb Mon Sep 17 00:00:00 2001 From: Nutomic Date: Wed, 5 Jun 2024 23:28:33 +0200 Subject: [PATCH 21/74] Apub library 0.5.7 (#4781) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 154c684a6..805850b6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ checksum = "8f27d075294830fcab6f66e320dab524bc6d048f4a151698e153205559113772" [[package]] name = "activitypub_federation" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8ff2d0151ce9ac02eb29e4a58b41d28693f141f7963d4bfabd2f9d402ecec7" +checksum = "69876675c80e73ab5e15e07b414cd3aa7c4c4e91f81fa43b52ea3ef28cbc225c" dependencies = [ "activitystreams-kinds", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 472b61692..6bdfc2023 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,7 +99,7 @@ lemmy_db_views = { version = "=0.19.4-rc.6", path = "./crates/db_views" } lemmy_db_views_actor = { version = "=0.19.4-rc.6", path = "./crates/db_views_actor" } lemmy_db_views_moderator = { version = "=0.19.4-rc.6", path = "./crates/db_views_moderator" } lemmy_federate = { version = "=0.19.4-rc.6", path = "./crates/federate" } -activitypub_federation = { version = "0.5.6", default-features = false, features = [ +activitypub_federation = { version = "0.5.7", default-features = false, features = [ "actix-web", ] } diesel = "2.1.6" From 92214a9364481de81bbc62dbbd526eaf2ad85270 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 5 Jun 2024 17:30:43 -0400 Subject: [PATCH 22/74] Version 0.19.4-rc.7 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ crates/utils/translations | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 805850b6e..41eba51fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2699,7 +2699,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "activitypub_federation", "actix-web", @@ -2728,7 +2728,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "activitypub_federation", "actix-web", @@ -2766,7 +2766,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "accept-language", "activitypub_federation", @@ -2789,7 +2789,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "activitypub_federation", "actix-web", @@ -2827,7 +2827,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "anyhow", "clap", @@ -2842,7 +2842,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "activitypub_federation", "anyhow", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "actix-web", "chrono", @@ -2904,7 +2904,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "chrono", "diesel", @@ -2925,7 +2925,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "diesel", "diesel-async", @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "activitypub_federation", "anyhow", @@ -2962,7 +2962,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "activitypub_federation", "actix-web", @@ -2987,7 +2987,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "activitypub_federation", "actix-cors", @@ -3030,7 +3030,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 6bdfc2023..01f3ce40d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.6" +version = "0.19.4-rc.7" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.6", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.6", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.6", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.6", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.6", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.6", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.6", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.6", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.6", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.6", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.6", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.7", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.7", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.7", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.7", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.7", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.7", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.7", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.7", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.7", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.7", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.7", path = "./crates/federate" } activitypub_federation = { version = "0.5.7", default-features = false, features = [ "actix-web", ] } diff --git a/crates/utils/translations b/crates/utils/translations index dca5d8ca0..3b43a3bb5 160000 --- a/crates/utils/translations +++ b/crates/utils/translations @@ -1 +1 @@ -Subproject commit dca5d8ca0309d7cb07eaca821140e4525e75ee57 +Subproject commit 3b43a3bb56af0cde6712594e4dce78038e186185 From bb94fb1c79000f72c0a029dcd4dd81799e7f6116 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 6 Jun 2024 00:04:02 +0200 Subject: [PATCH 23/74] Revert apub library 0.5.7 (#4783) Wasnt necessary after all --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 01f3ce40d..cf81680e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,7 +99,7 @@ lemmy_db_views = { version = "=0.19.4-rc.7", path = "./crates/db_views" } lemmy_db_views_actor = { version = "=0.19.4-rc.7", path = "./crates/db_views_actor" } lemmy_db_views_moderator = { version = "=0.19.4-rc.7", path = "./crates/db_views_moderator" } lemmy_federate = { version = "=0.19.4-rc.7", path = "./crates/federate" } -activitypub_federation = { version = "0.5.7", default-features = false, features = [ +activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } diesel = "2.1.6" From e8cfb5665fa8ee2eedf6842f0e0c58fc3cb87b59 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 5 Jun 2024 18:59:46 -0400 Subject: [PATCH 24/74] When banning from local communities, make sure they aren't deleted or removed. (#4784) - This is causing some federation issues. - Context: #4782 --- crates/db_schema/src/impls/person.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index 0255785d6..c2ede1bb3 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -12,7 +12,14 @@ use crate::{ traits::{ApubActor, Crud, Followable}, utils::{functions::lower, get_conn, naive_now, DbPool}, }; -use diesel::{dsl::insert_into, result::Error, CombineDsl, ExpressionMethods, JoinOnDsl, QueryDsl}; +use diesel::{ + dsl::{insert_into, not}, + result::Error, + CombineDsl, + ExpressionMethods, + JoinOnDsl, + QueryDsl, +}; use diesel_async::RunQueryDsl; #[async_trait] @@ -100,6 +107,8 @@ impl Person { .inner_join(post::table) .inner_join(community::table.on(post::community_id.eq(community::id))) .filter(community::local.eq(true)) + .filter(not(community::deleted)) + .filter(not(community::removed)) .filter(comment::creator_id.eq(for_creator_id)) .select(community::id) .union( From fda5ce4482920e626b3f4e484891a8dcc31b39af Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 5 Jun 2024 19:01:37 -0400 Subject: [PATCH 25/74] Version 0.19.4-rc.8 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41eba51fb..d0c8e999f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2699,7 +2699,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "activitypub_federation", "actix-web", @@ -2728,7 +2728,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "activitypub_federation", "actix-web", @@ -2766,7 +2766,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "accept-language", "activitypub_federation", @@ -2789,7 +2789,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "activitypub_federation", "actix-web", @@ -2827,7 +2827,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "anyhow", "clap", @@ -2842,7 +2842,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "activitypub_federation", "anyhow", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "actix-web", "chrono", @@ -2904,7 +2904,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "chrono", "diesel", @@ -2925,7 +2925,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "diesel", "diesel-async", @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "activitypub_federation", "anyhow", @@ -2962,7 +2962,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "activitypub_federation", "actix-web", @@ -2987,7 +2987,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "activitypub_federation", "actix-cors", @@ -3030,7 +3030,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index cf81680e6..16fb92620 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.7" +version = "0.19.4-rc.8" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.7", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.7", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.7", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.7", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.7", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.7", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.7", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.7", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.7", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.7", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.7", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.8", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.8", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.8", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.8", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.8", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.8", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.8", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.8", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.8", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.8", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.8", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } From 79e6dbf0debbc7a904916cd6c97cf8dc1e78cad2 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Thu, 6 Jun 2024 05:29:18 -0700 Subject: [PATCH 26/74] Remove PersonInsertForm builder (#4779) * Update session_middleware.rs * Update private_message_report_view.rs * Update session_middleware.rs * Update private_message_view.rs * Update private_message.rs * Update registration_application_view.rs * Update actor_language.rs * Update vote_view.rs * Update code_migrations.rs * Update comment_aggregates.rs * Update person_view.rs * Update user_settings_backup.rs * Update person.rs * Update create.rs * Update comment_view.rs * Update moderator.rs * Update site_aggregates.rs * Update claims.rs * Update community_aggregates.rs * Update post_report.rs * Update person_mention_view.rs * Update community_view.rs * Update comment_report_view.rs * Update post_report_view.rs * Update community_moderators.rs * Update comment.rs * Update person_aggregates.rs * Update comment_reply_view.rs * Update password_reset_request.rs * Update post_aggregates.rs * Update community.rs * Update main.rs * Update post.rs * Update person.rs * Update person.rs * Update claims.rs * Update person.rs * Update create.rs * Update user_settings_backup.rs * Update community_moderators.rs * Update main.rs * Update comment_aggregates.rs * Update community_aggregates.rs * Update person.rs * Update Cargo.toml * Update Cargo.toml * Update person.rs * fix * Update code_migrations.rs * fix submodule * Update person.rs --- Cargo.lock | 12 +++++++++ Cargo.toml | 1 + crates/api_common/src/claims.rs | 6 +---- crates/api_crud/src/user/create.rs | 20 +++++++------- crates/apub/src/api/user_settings_backup.rs | 12 ++++----- .../src/collections/community_moderators.rs | 6 +---- crates/db_perf/src/main.rs | 6 +---- crates/db_schema/Cargo.toml | 1 + .../src/aggregates/comment_aggregates.rs | 12 ++------- .../src/aggregates/community_aggregates.rs | 12 ++------- .../src/aggregates/person_aggregates.rs | 12 ++------- .../src/aggregates/post_aggregates.rs | 18 +++---------- .../src/aggregates/site_aggregates.rs | 6 +---- crates/db_schema/src/impls/actor_language.rs | 12 ++------- crates/db_schema/src/impls/comment.rs | 6 +---- crates/db_schema/src/impls/community.rs | 6 +---- crates/db_schema/src/impls/moderator.rs | 12 ++------- .../src/impls/password_reset_request.rs | 6 +---- crates/db_schema/src/impls/person.rs | 26 ++++--------------- crates/db_schema/src/impls/post.rs | 6 +---- crates/db_schema/src/impls/post_report.rs | 6 +---- crates/db_schema/src/impls/private_message.rs | 12 ++------- crates/db_schema/src/source/person.rs | 24 ++++++++++++----- crates/db_views/src/comment_report_view.rs | 18 +++---------- crates/db_views/src/comment_view.rs | 12 ++------- crates/db_views/src/post_report_view.rs | 18 +++---------- .../src/private_message_report_view.rs | 18 +++---------- crates/db_views/src/private_message_view.rs | 18 +++---------- .../src/registration_application_view.rs | 18 +++---------- crates/db_views/src/vote_view.rs | 12 ++------- .../db_views_actor/src/comment_reply_view.rs | 16 ++++-------- crates/db_views_actor/src/community_view.rs | 6 +---- .../db_views_actor/src/person_mention_view.rs | 12 ++------- crates/db_views_actor/src/person_view.rs | 22 +++++++--------- src/code_migrations.rs | 20 +++++++------- src/session_middleware.rs | 6 +---- 36 files changed, 125 insertions(+), 311 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0c8e999f..647e8e915 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1423,6 +1423,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-new" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d150dea618e920167e5973d70ae6ece4385b7164e0d799fe7c122dd0a5d912ad" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + [[package]] name = "derive_builder" version = "0.20.0" @@ -2850,6 +2861,7 @@ dependencies = [ "bcrypt", "chrono", "deadpool 0.12.1", + "derive-new", "diesel", "diesel-async", "diesel-derive-enum", diff --git a/Cargo.toml b/Cargo.toml index 16fb92620..9b9958725 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,6 +167,7 @@ moka = { version = "0.12.7", features = ["future"] } i-love-jesus = { version = "0.1.0" } clap = { version = "4.5.4", features = ["derive", "env"] } pretty_assertions = "1.4.0" +derive-new = "0.6.0" [dependencies] lemmy_api = { workspace = true } diff --git a/crates/api_common/src/claims.rs b/crates/api_common/src/claims.rs index 160c581cd..6c17d4e6a 100644 --- a/crates/api_common/src/claims.rs +++ b/crates/api_common/src/claims.rs @@ -112,11 +112,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("Gerry9812".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "Gerry9812"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index bf064fb2e..c84bd0a50 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -112,15 +112,17 @@ pub async fn register( // We have to create both a person, and local_user // Register the new person - let person_form = PersonInsertForm::builder() - .name(data.username.clone()) - .actor_id(Some(actor_id.clone())) - .private_key(Some(actor_keypair.private_key)) - .public_key(actor_keypair.public_key) - .inbox_url(Some(generate_inbox_url(&actor_id)?)) - .shared_inbox_url(Some(generate_shared_inbox_url(context.settings())?)) - .instance_id(site_view.site.instance_id) - .build(); + let person_form = PersonInsertForm { + actor_id: Some(actor_id.clone()), + inbox_url: Some(generate_inbox_url(&actor_id)?), + shared_inbox_url: Some(generate_shared_inbox_url(context.settings())?), + private_key: Some(actor_keypair.private_key), + ..PersonInsertForm::new( + data.username.clone(), + actor_keypair.public_key, + site_view.site.instance_id, + ) + }; // insert the person let inserted_person = Person::create(&mut context.pool(), &person_form) diff --git a/crates/apub/src/api/user_settings_backup.rs b/crates/apub/src/api/user_settings_backup.rs index 558551632..9f2cb58c5 100644 --- a/crates/apub/src/api/user_settings_backup.rs +++ b/crates/apub/src/api/user_settings_backup.rs @@ -338,13 +338,11 @@ mod tests { context: &Data, ) -> LemmyResult { let instance = Instance::read_or_create(&mut context.pool(), "example.com".to_string()).await?; - let person_form = PersonInsertForm::builder() - .name(name.clone()) - .display_name(Some(name.clone())) - .bio(bio) - .public_key("asd".to_string()) - .instance_id(instance.id) - .build(); + let person_form = PersonInsertForm { + display_name: Some(name.clone()), + bio, + ..PersonInsertForm::test_form(instance.id, &name) + }; let person = Person::create(&mut context.pool(), &person_form).await?; let user_form = LocalUserInsertForm::builder() diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index 02b912f44..8e5419c7e 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -129,11 +129,7 @@ mod tests { let inserted_instance = Instance::read_or_create(&mut context.pool(), "my_domain.tld".to_string()).await?; - let old_mod = PersonInsertForm::builder() - .name("holly".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let old_mod = PersonInsertForm::test_form(inserted_instance.id, "holly"); let old_mod = Person::create(&mut context.pool(), &old_mod).await?; let community_moderator_form = CommunityModeratorForm { diff --git a/crates/db_perf/src/main.rs b/crates/db_perf/src/main.rs index 9092d7514..8e03a0a1d 100644 --- a/crates/db_perf/src/main.rs +++ b/crates/db_perf/src/main.rs @@ -72,11 +72,7 @@ async fn try_main() -> LemmyResult<()> { println!("🫃 creating {} people", args.people); let mut person_ids = vec![]; for i in 0..args.people.get() { - let form = PersonInsertForm::builder() - .name(format!("p{i}")) - .public_key("pubkey".to_owned()) - .instance_id(instance.id) - .build(); + let form = PersonInsertForm::test_form(instance.id, &format!("p{i}")); person_ids.push(Person::create(&mut conn.into(), &form).await?.id); } diff --git a/crates/db_schema/Cargo.toml b/crates/db_schema/Cargo.toml index cc6b7d8f6..dc924fa91 100644 --- a/crates/db_schema/Cargo.toml +++ b/crates/db_schema/Cargo.toml @@ -81,6 +81,7 @@ uuid = { workspace = true, features = ["v4"] } i-love-jesus = { workspace = true, optional = true } anyhow = { workspace = true } moka.workspace = true +derive-new.workspace = true [dev-dependencies] serial_test = { workspace = true } diff --git a/crates/db_schema/src/aggregates/comment_aggregates.rs b/crates/db_schema/src/aggregates/comment_aggregates.rs index 915d17b1d..92b24beb5 100644 --- a/crates/db_schema/src/aggregates/comment_aggregates.rs +++ b/crates/db_schema/src/aggregates/comment_aggregates.rs @@ -64,19 +64,11 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("thommy_comment_agg".into()) - .public_key("pubkey".into()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_comment_agg"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); - let another_person = PersonInsertForm::builder() - .name("jerry_comment_agg".into()) - .public_key("pubkey".into()) - .instance_id(inserted_instance.id) - .build(); + let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_comment_agg"); let another_inserted_person = Person::create(pool, &another_person).await.unwrap(); diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index 0cf63809d..fe9de62bb 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -65,19 +65,11 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("thommy_community_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_community_agg"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); - let another_person = PersonInsertForm::builder() - .name("jerry_community_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_community_agg"); let another_inserted_person = Person::create(pool, &another_person).await.unwrap(); diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index 03295173f..a8767895c 100644 --- a/crates/db_schema/src/aggregates/person_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_aggregates.rs @@ -49,19 +49,11 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("thommy_user_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_user_agg"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); - let another_person = PersonInsertForm::builder() - .name("jerry_user_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_user_agg"); let another_inserted_person = Person::create(pool, &another_person).await.unwrap(); diff --git a/crates/db_schema/src/aggregates/post_aggregates.rs b/crates/db_schema/src/aggregates/post_aggregates.rs index cb8227795..eba3a02a3 100644 --- a/crates/db_schema/src/aggregates/post_aggregates.rs +++ b/crates/db_schema/src/aggregates/post_aggregates.rs @@ -83,19 +83,11 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("thommy_community_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_community_agg"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); - let another_person = PersonInsertForm::builder() - .name("jerry_community_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let another_person = PersonInsertForm::test_form(inserted_instance.id, "jerry_community_agg"); let another_inserted_person = Person::create(pool, &another_person).await.unwrap(); @@ -229,11 +221,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("thommy_community_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_community_agg"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/db_schema/src/aggregates/site_aggregates.rs b/crates/db_schema/src/aggregates/site_aggregates.rs index 268a37aac..ee9a1be9c 100644 --- a/crates/db_schema/src/aggregates/site_aggregates.rs +++ b/crates/db_schema/src/aggregates/site_aggregates.rs @@ -42,11 +42,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("thommy_site_agg".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy_site_agg"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index 682be2ed0..8483d6c20 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -531,11 +531,7 @@ mod tests { let (site, instance) = create_test_site(pool).await; - let person_form = PersonInsertForm::builder() - .name("my test person".to_string()) - .public_key("pubkey".to_string()) - .instance_id(instance.id) - .build(); + let person_form = PersonInsertForm::test_form(instance.id, "my test person"); let person = Person::create(pool, &person_form).await.unwrap(); let local_user_form = LocalUserInsertForm::builder() .person_id(person.id) @@ -647,11 +643,7 @@ mod tests { .await .unwrap(); - let person_form = PersonInsertForm::builder() - .name("my test person".to_string()) - .public_key("pubkey".to_string()) - .instance_id(instance.id) - .build(); + let person_form = PersonInsertForm::test_form(instance.id, "my test person"); let person = Person::create(pool, &person_form).await.unwrap(); let local_user_form = LocalUserInsertForm::builder() .person_id(person.id) diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index eff7da26f..6cdb54e4a 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -233,11 +233,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("terry".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "terry"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 02b65e6fc..6cd90cc66 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -434,11 +434,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("bobbee".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "bobbee"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/db_schema/src/impls/moderator.rs b/crates/db_schema/src/impls/moderator.rs index 125bbcd51..c10d818f8 100644 --- a/crates/db_schema/src/impls/moderator.rs +++ b/crates/db_schema/src/impls/moderator.rs @@ -513,19 +513,11 @@ mod tests { .await .unwrap(); - let new_mod = PersonInsertForm::builder() - .name("the mod".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_mod = PersonInsertForm::test_form(inserted_instance.id, "the mod"); let inserted_mod = Person::create(pool, &new_mod).await.unwrap(); - let new_person = PersonInsertForm::builder() - .name("jim2".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "jim2"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index c92cb0867..0b1351af1 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -70,11 +70,7 @@ mod tests { // Setup let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?; - let new_person = PersonInsertForm::builder() - .name("thommy prw".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "thommy prw"); let inserted_person = Person::create(pool, &new_person).await?; let new_local_user = LocalUserInsertForm::builder() .person_id(inserted_person.id) diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index c2ede1bb3..f318a503a 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -125,11 +125,7 @@ impl Person { impl PersonInsertForm { pub fn test_form(instance_id: InstanceId, name: &str) -> Self { - Self::builder() - .name(name.to_owned()) - .public_key("pubkey".to_string()) - .instance_id(instance_id) - .build() + Self::new(name.to_owned(), "pubkey".to_string(), instance_id) } } @@ -249,11 +245,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("holly".into()) - .public_key("nada".to_owned()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "holly"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); @@ -272,7 +264,7 @@ mod tests { local: true, bot_account: false, private_key: None, - public_key: "nada".to_owned(), + public_key: "pubkey".to_owned(), last_refreshed_at: inserted_person.published, inbox_url: inserted_person.inbox_url.clone(), shared_inbox_url: None, @@ -312,17 +304,9 @@ mod tests { .await .unwrap(); - let person_form_1 = PersonInsertForm::builder() - .name("erich".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let person_form_1 = PersonInsertForm::test_form(inserted_instance.id, "erich"); let person_1 = Person::create(pool, &person_form_1).await.unwrap(); - let person_form_2 = PersonInsertForm::builder() - .name("michele".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let person_form_2 = PersonInsertForm::test_form(inserted_instance.id, "michele"); let person_2 = Person::create(pool, &person_form_2).await.unwrap(); let follow_form = PersonFollowerForm { diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index d5f1cba98..ac6cf76aa 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -401,11 +401,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("jim".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "jim"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index 260574bd2..7218ef468 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -101,11 +101,7 @@ mod tests { let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()) .await .unwrap(); - let person_form = PersonInsertForm::builder() - .name("jim".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let person_form = PersonInsertForm::test_form(inserted_instance.id, "jim"); let person = Person::create(pool, &person_form).await.unwrap(); let community_form = CommunityInsertForm::builder() diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index 75c7ce9bc..3cbfd052d 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -111,19 +111,11 @@ mod tests { .await .unwrap(); - let creator_form = PersonInsertForm::builder() - .name("creator_pm".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let creator_form = PersonInsertForm::test_form(inserted_instance.id, "creator_pm"); let inserted_creator = Person::create(pool, &creator_form).await.unwrap(); - let recipient_form = PersonInsertForm::builder() - .name("recipient_pm".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let recipient_form = PersonInsertForm::test_form(inserted_instance.id, "recipient_pm"); let inserted_recipient = Person::create(pool, &recipient_form).await.unwrap(); diff --git a/crates/db_schema/src/source/person.rs b/crates/db_schema/src/source/person.rs index 45eacd4fc..332b46eb5 100644 --- a/crates/db_schema/src/source/person.rs +++ b/crates/db_schema/src/source/person.rs @@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; #[cfg(feature = "full")] use ts_rs::TS; -use typed_builder::TypedBuilder; #[skip_serializing_none] #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] @@ -60,33 +59,46 @@ pub struct Person { pub instance_id: InstanceId, } -#[derive(Clone, TypedBuilder)] -#[builder(field_defaults(default))] +#[derive(Clone, derive_new::new)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] #[cfg_attr(feature = "full", diesel(table_name = person))] pub struct PersonInsertForm { - #[builder(!default)] pub name: String, - #[builder(!default)] pub public_key: String, - #[builder(!default)] pub instance_id: InstanceId, + #[new(default)] pub display_name: Option, + #[new(default)] pub avatar: Option, + #[new(default)] pub banned: Option, + #[new(default)] pub published: Option>, + #[new(default)] pub updated: Option>, + #[new(default)] pub actor_id: Option, + #[new(default)] pub bio: Option, + #[new(default)] pub local: Option, + #[new(default)] pub private_key: Option, + #[new(default)] pub last_refreshed_at: Option>, + #[new(default)] pub banner: Option, + #[new(default)] pub deleted: Option, + #[new(default)] pub inbox_url: Option, + #[new(default)] pub shared_inbox_url: Option, + #[new(default)] pub matrix_user_id: Option, + #[new(default)] pub bot_account: Option, + #[new(default)] pub ban_expires: Option>, } diff --git a/crates/db_views/src/comment_report_view.rs b/crates/db_views/src/comment_report_view.rs index ebea1a5f4..950d061ba 100644 --- a/crates/db_views/src/comment_report_view.rs +++ b/crates/db_views/src/comment_report_view.rs @@ -297,11 +297,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("timmy_crv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "timmy_crv"); let inserted_timmy = Person::create(pool, &new_person).await.unwrap(); @@ -319,20 +315,12 @@ mod tests { counts: Default::default(), }; - let new_person_2 = PersonInsertForm::builder() - .name("sara_crv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "sara_crv"); let inserted_sara = Person::create(pool, &new_person_2).await.unwrap(); // Add a third person, since new ppl can only report something once. - let new_person_3 = PersonInsertForm::builder() - .name("jessica_crv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_3 = PersonInsertForm::test_form(inserted_instance.id, "jessica_crv"); let inserted_jessica = Person::create(pool, &new_person_3).await.unwrap(); diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index e021578f8..247dea9fc 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -488,11 +488,7 @@ mod tests { async fn init_data(pool: &mut DbPool<'_>) -> LemmyResult { let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?; - let timmy_person_form = PersonInsertForm::builder() - .name("timmy".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let timmy_person_form = PersonInsertForm::test_form(inserted_instance.id, "timmy"); let inserted_timmy_person = Person::create(pool, &timmy_person_form).await?; let timmy_local_user_form = LocalUserInsertForm::builder() .person_id(inserted_timmy_person.id) @@ -501,11 +497,7 @@ mod tests { .build(); let inserted_timmy_local_user = LocalUser::create(pool, &timmy_local_user_form, vec![]).await?; - let sara_person_form = PersonInsertForm::builder() - .name("sara".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let sara_person_form = PersonInsertForm::test_form(inserted_instance.id, "sara"); let inserted_sara_person = Person::create(pool, &sara_person_form).await?; let new_community = CommunityInsertForm::builder() diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/post_report_view.rs index ac60deff9..e89b7d545 100644 --- a/crates/db_views/src/post_report_view.rs +++ b/crates/db_views/src/post_report_view.rs @@ -319,11 +319,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("timmy_prv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "timmy_prv"); let inserted_timmy = Person::create(pool, &new_person).await.unwrap(); @@ -341,20 +337,12 @@ mod tests { counts: Default::default(), }; - let new_person_2 = PersonInsertForm::builder() - .name("sara_prv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "sara_prv"); let inserted_sara = Person::create(pool, &new_person_2).await.unwrap(); // Add a third person, since new ppl can only report something once. - let new_person_3 = PersonInsertForm::builder() - .name("jessica_prv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_3 = PersonInsertForm::test_form(inserted_instance.id, "jessica_prv"); let inserted_jessica = Person::create(pool, &new_person_3).await.unwrap(); diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index 6011574e6..f5e70fb3e 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -140,18 +140,10 @@ mod tests { .await .unwrap(); - let new_person_1 = PersonInsertForm::builder() - .name("timmy_mrv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_1 = PersonInsertForm::test_form(inserted_instance.id, "timmy_mrv"); let inserted_timmy = Person::create(pool, &new_person_1).await.unwrap(); - let new_person_2 = PersonInsertForm::builder() - .name("jessica_mrv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "jessica_mrv"); let inserted_jessica = Person::create(pool, &new_person_2).await.unwrap(); // timmy sends private message to jessica @@ -184,11 +176,7 @@ mod tests { assert_eq!(pm_report.reason, reports[0].private_message_report.reason); assert_eq!(pm.content, reports[0].private_message.content); - let new_person_3 = PersonInsertForm::builder() - .name("admin_mrv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_3 = PersonInsertForm::test_form(inserted_instance.id, "admin_mrv"); let inserted_admin = Person::create(pool, &new_person_3).await.unwrap(); // admin resolves the report (after taking appropriate action) diff --git a/crates/db_views/src/private_message_view.rs b/crates/db_views/src/private_message_view.rs index 764ef1dcb..79224d86f 100644 --- a/crates/db_views/src/private_message_view.rs +++ b/crates/db_views/src/private_message_view.rs @@ -209,27 +209,15 @@ mod tests { .await .unwrap(); - let timmy_form = PersonInsertForm::builder() - .name("timmy_rav".into()) - .public_key("pubkey".to_string()) - .instance_id(instance.id) - .build(); + let timmy_form = PersonInsertForm::test_form(instance.id, "timmy_rav"); let timmy = Person::create(pool, &timmy_form).await.unwrap(); - let sara_form = PersonInsertForm::builder() - .name("sara_rav".into()) - .public_key("pubkey".to_string()) - .instance_id(instance.id) - .build(); + let sara_form = PersonInsertForm::test_form(instance.id, "sara_rav"); let sara = Person::create(pool, &sara_form).await.unwrap(); - let jess_form = PersonInsertForm::builder() - .name("jess_rav".into()) - .public_key("pubkey".to_string()) - .instance_id(instance.id) - .build(); + let jess_form = PersonInsertForm::test_form(instance.id, "jess_rav"); let jess = Person::create(pool, &jess_form).await.unwrap(); diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index 65629d65c..cd63859af 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -163,11 +163,7 @@ mod tests { .await .unwrap(); - let timmy_person_form = PersonInsertForm::builder() - .name("timmy_rav".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let timmy_person_form = PersonInsertForm::test_form(inserted_instance.id, "timmy_rav"); let inserted_timmy_person = Person::create(pool, &timmy_person_form).await.unwrap(); @@ -181,11 +177,7 @@ mod tests { .await .unwrap(); - let sara_person_form = PersonInsertForm::builder() - .name("sara_rav".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let sara_person_form = PersonInsertForm::test_form(inserted_instance.id, "sara_rav"); let inserted_sara_person = Person::create(pool, &sara_person_form).await.unwrap(); @@ -213,11 +205,7 @@ mod tests { .unwrap() .unwrap(); - let jess_person_form = PersonInsertForm::builder() - .name("jess_rav".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let jess_person_form = PersonInsertForm::test_form(inserted_instance.id, "jess_rav"); let inserted_jess_person = Person::create(pool, &jess_person_form).await.unwrap(); diff --git a/crates/db_views/src/vote_view.rs b/crates/db_views/src/vote_view.rs index a0441ff4e..5daa072c3 100644 --- a/crates/db_views/src/vote_view.rs +++ b/crates/db_views/src/vote_view.rs @@ -112,19 +112,11 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("timmy_vv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "timmy_vv"); let inserted_timmy = Person::create(pool, &new_person).await.unwrap(); - let new_person_2 = PersonInsertForm::builder() - .name("sara_vv".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person_2 = PersonInsertForm::test_form(inserted_instance.id, "sara_vv"); let inserted_sara = Person::create(pool, &new_person_2).await.unwrap(); diff --git a/crates/db_views_actor/src/comment_reply_view.rs b/crates/db_views_actor/src/comment_reply_view.rs index a5939d2e9..b1d95e719 100644 --- a/crates/db_views_actor/src/comment_reply_view.rs +++ b/crates/db_views_actor/src/comment_reply_view.rs @@ -334,19 +334,13 @@ mod tests { let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?; - let terry_form = PersonInsertForm::builder() - .name("terrylake".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let terry_form = PersonInsertForm::test_form(inserted_instance.id, "terrylake"); let inserted_terry = Person::create(pool, &terry_form).await?; - let recipient_form = PersonInsertForm::builder() - .name("terrylakes recipient".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .local(Some(true)) - .build(); + let recipient_form = PersonInsertForm { + local: Some(true), + ..PersonInsertForm::test_form(inserted_instance.id, "terrylakes recipient") + }; let inserted_recipient = Person::create(pool, &recipient_form).await?; let recipient_id = inserted_recipient.id; diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index 0ff421540..c5b28c7ce 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -286,11 +286,7 @@ mod tests { let person_name = "tegan".to_string(); - let new_person = PersonInsertForm::builder() - .name(person_name.clone()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, &person_name); let inserted_person = Person::create(pool, &new_person).await.unwrap(); diff --git a/crates/db_views_actor/src/person_mention_view.rs b/crates/db_views_actor/src/person_mention_view.rs index 58ddb011b..d6fd7363d 100644 --- a/crates/db_views_actor/src/person_mention_view.rs +++ b/crates/db_views_actor/src/person_mention_view.rs @@ -334,19 +334,11 @@ mod tests { let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?; - let new_person = PersonInsertForm::builder() - .name("terrylake".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "terrylake"); let inserted_person = Person::create(pool, &new_person).await?; - let recipient_form = PersonInsertForm::builder() - .name("terrylakes recipient".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let recipient_form = PersonInsertForm::test_form(inserted_instance.id, "terrylakes recipient"); let inserted_recipient = Person::create(pool, &recipient_form).await?; let recipient_id = inserted_recipient.id; diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index 5734bc812..98a0ca38d 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -191,12 +191,10 @@ mod tests { async fn init_data(pool: &mut DbPool<'_>) -> LemmyResult { let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?; - let alice_form = PersonInsertForm::builder() - .name("alice".to_string()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .local(Some(true)) - .build(); + let alice_form = PersonInsertForm { + local: Some(true), + ..PersonInsertForm::test_form(inserted_instance.id, "alice") + }; let alice = Person::create(pool, &alice_form).await?; let alice_local_user_form = LocalUserInsertForm::builder() .person_id(alice.id) @@ -204,13 +202,11 @@ mod tests { .build(); let alice_local_user = LocalUser::create(pool, &alice_local_user_form, vec![]).await?; - let bob_form = PersonInsertForm::builder() - .name("bob".to_string()) - .bot_account(Some(true)) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .local(Some(false)) - .build(); + let bob_form = PersonInsertForm { + bot_account: Some(true), + local: Some(false), + ..PersonInsertForm::test_form(inserted_instance.id, "bob") + }; let bob = Person::create(pool, &bob_form).await?; let bob_local_user_form = LocalUserInsertForm::builder() .person_id(bob.id) diff --git a/src/code_migrations.rs b/src/code_migrations.rs index 05b564f47..fd4ef66de 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -455,15 +455,17 @@ async fn initialize_local_site_2022_10_10( )?; // Register the user if there's a site setup - let person_form = PersonInsertForm::builder() - .name(setup.admin_username.clone()) - .instance_id(instance.id) - .actor_id(Some(person_actor_id.clone())) - .private_key(Some(person_keypair.private_key)) - .public_key(person_keypair.public_key) - .inbox_url(Some(generate_inbox_url(&person_actor_id)?)) - .shared_inbox_url(Some(generate_shared_inbox_url(settings)?)) - .build(); + let person_form = PersonInsertForm { + actor_id: Some(person_actor_id.clone()), + inbox_url: Some(generate_inbox_url(&person_actor_id)?), + shared_inbox_url: Some(generate_shared_inbox_url(settings)?), + private_key: Some(person_keypair.private_key), + ..PersonInsertForm::new( + setup.admin_username.clone(), + person_keypair.public_key, + instance.id, + ) + }; let person_inserted = Person::create(pool, &person_form).await?; let local_user_form = LocalUserInsertForm::builder() diff --git a/src/session_middleware.rs b/src/session_middleware.rs index f4535249c..8b3090a47 100644 --- a/src/session_middleware.rs +++ b/src/session_middleware.rs @@ -142,11 +142,7 @@ mod tests { .await .unwrap(); - let new_person = PersonInsertForm::builder() - .name("Gerry9812".into()) - .public_key("pubkey".to_string()) - .instance_id(inserted_instance.id) - .build(); + let new_person = PersonInsertForm::test_form(inserted_instance.id, "Gerry9812"); let inserted_person = Person::create(pool, &new_person).await.unwrap(); From 16a82862b834bed0a3a7e430057ece8216c26295 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 6 Jun 2024 09:55:08 -0400 Subject: [PATCH 27/74] Allow empty string to clear URL-type DB fields. (#4780) * Allow empty string to clear URL-type DB fields. - To address difficulties with clearing URL-type fields like avatars, banners, site icons, this PR turns the URL type form fields into strings. - This allows an empty string to be used as a "clear data", as in the case with the regular text form fields. - Also includes various cleanups. - Fixes #4777 - Context: #2287 * Fixing comment. * Use Option<&str> and deref. --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> --- api_tests/src/user.spec.ts | 11 ++ crates/api/src/community/ban.rs | 5 +- crates/api/src/local_user/ban_person.rs | 4 +- crates/api/src/local_user/save_settings.rs | 26 ++-- crates/api/src/post/get_link_metadata.rs | 9 +- .../site/registration_applications/approve.rs | 4 +- crates/api_common/src/post.rs | 16 +-- crates/api_common/src/request.rs | 6 +- crates/api_common/src/utils.rs | 50 ++------ crates/api_crud/src/comment/create.rs | 2 +- crates/api_crud/src/comment/update.rs | 4 +- crates/api_crud/src/community/create.rs | 14 +- crates/api_crud/src/community/update.rs | 28 ++-- crates/api_crud/src/post/create.rs | 31 +++-- crates/api_crud/src/post/update.rs | 52 +++++--- crates/api_crud/src/private_message/create.rs | 2 +- crates/api_crud/src/private_message/update.rs | 2 +- crates/api_crud/src/site/create.rs | 32 +++-- crates/api_crud/src/site/update.rs | 37 ++++-- crates/apub/src/objects/post.rs | 5 +- crates/db_schema/src/utils.rs | 54 ++++---- crates/utils/src/utils/validation.rs | 120 ++++++++---------- 22 files changed, 279 insertions(+), 235 deletions(-) diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index 4f91cbd87..d008dcdc3 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -21,6 +21,7 @@ import { fetchFunction, alphaImage, unfollows, + saveUserSettingsBio, } from "./shared"; import { LemmyHttp, SaveUserSettings, UploadImage } from "lemmy-js-client"; import { GetPosts } from "lemmy-js-client/dist/types/GetPosts"; @@ -198,4 +199,14 @@ test("Set a new avatar, old avatar is deleted", async () => { // make sure only the new avatar is kept const listMediaRes3 = await alphaImage.listMedia(); expect(listMediaRes3.images.length).toBe(1); + + // Now try to save a user settings, with the icon missing, + // and make sure it doesn't clear the data, or delete the image + await saveUserSettingsBio(alpha); + let site = await getSite(alpha); + expect(site.my_user?.local_user_view.person.avatar).toBe(upload2.url); + + // make sure only the new avatar is kept + const listMediaRes4 = await alphaImage.listMedia(); + expect(listMediaRes4.images.length).toBe(1); }); diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index 93cf00415..877d9464f 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -43,7 +43,10 @@ pub async fn ban_from_community( &mut context.pool(), ) .await?; - is_valid_body_field(&data.reason, false)?; + + if let Some(reason) = &data.reason { + is_valid_body_field(reason, false)?; + } let community_user_ban_form = CommunityPersonBanForm { community_id: data.community_id, diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index c31940fba..49cd6893a 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -31,7 +31,9 @@ pub async fn ban_from_site( // Make sure user is an admin is_admin(&local_user_view)?; - is_valid_body_field(&data.reason, false)?; + if let Some(reason) = &data.reason { + is_valid_body_field(reason, false)?; + } let expires = check_expire_time(data.expires)?; diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index bdba817cc..193f9d269 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -21,7 +21,7 @@ use lemmy_db_schema::{ person::{Person, PersonUpdateForm}, }, traits::Crud, - utils::diesel_option_overwrite, + utils::{diesel_string_update, diesel_url_update}, }; use lemmy_db_views::structs::{LocalUserView, SiteView}; use lemmy_utils::{ @@ -42,18 +42,24 @@ pub async fn save_user_settings( let slur_regex = local_site_to_slur_regex(&site_view.local_site); 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 bio = diesel_string_update( + process_markdown_opt(&data.bio, &slur_regex, &url_blocklist, &context) + .await? + .as_deref(), ); - replace_image(&data.avatar, &local_user_view.person.avatar, &context).await?; - replace_image(&data.banner, &local_user_view.person.banner, &context).await?; - let avatar = proxy_image_link_opt_api(&data.avatar, &context).await?; - let banner = proxy_image_link_opt_api(&data.banner, &context).await?; - let display_name = diesel_option_overwrite(data.display_name.clone()); - let matrix_user_id = diesel_option_overwrite(data.matrix_user_id.clone()); + let avatar = diesel_url_update(data.avatar.as_deref())?; + replace_image(&avatar, &local_user_view.person.avatar, &context).await?; + let avatar = proxy_image_link_opt_api(avatar, &context).await?; + + let banner = diesel_url_update(data.banner.as_deref())?; + replace_image(&banner, &local_user_view.person.banner, &context).await?; + let banner = proxy_image_link_opt_api(banner, &context).await?; + + let display_name = diesel_string_update(data.display_name.as_deref()); + let matrix_user_id = diesel_string_update(data.matrix_user_id.as_deref()); let email_deref = data.email.as_deref().map(str::to_lowercase); - let email = diesel_option_overwrite(email_deref.clone()); + let email = diesel_string_update(email_deref.as_deref()); if let Some(Some(email)) = &email { let previous_email = local_user_view.local_user.email.clone().unwrap_or_default(); diff --git a/crates/api/src/post/get_link_metadata.rs b/crates/api/src/post/get_link_metadata.rs index 17346790a..0669408aa 100644 --- a/crates/api/src/post/get_link_metadata.rs +++ b/crates/api/src/post/get_link_metadata.rs @@ -4,14 +4,19 @@ use lemmy_api_common::{ post::{GetSiteMetadata, GetSiteMetadataResponse}, request::fetch_link_metadata, }; -use lemmy_utils::error::LemmyResult; +use lemmy_utils::{ + error::{LemmyErrorExt, LemmyResult}, + LemmyErrorType, +}; +use url::Url; #[tracing::instrument(skip(context))] pub async fn get_link_metadata( data: Query, context: Data, ) -> LemmyResult> { - let metadata = fetch_link_metadata(&data.url, &context).await?; + let url = Url::parse(&data.url).with_lemmy_type(LemmyErrorType::InvalidUrl)?; + let metadata = fetch_link_metadata(&url, &context).await?; Ok(Json(GetSiteMetadataResponse { metadata })) } diff --git a/crates/api/src/site/registration_applications/approve.rs b/crates/api/src/site/registration_applications/approve.rs index 0fb55ffc8..823af54c4 100644 --- a/crates/api/src/site/registration_applications/approve.rs +++ b/crates/api/src/site/registration_applications/approve.rs @@ -10,7 +10,7 @@ use lemmy_db_schema::{ registration_application::{RegistrationApplication, RegistrationApplicationUpdateForm}, }, traits::Crud, - utils::diesel_option_overwrite, + utils::diesel_string_update, }; use lemmy_db_views::structs::{LocalUserView, RegistrationApplicationView}; use lemmy_utils::{error::LemmyResult, LemmyErrorType}; @@ -26,7 +26,7 @@ pub async fn approve_registration_application( is_admin(&local_user_view)?; // Update the registration with reason, admin_id - let deny_reason = diesel_option_overwrite(data.deny_reason.clone()); + let deny_reason = diesel_string_update(data.deny_reason.as_deref()); let app_form = RegistrationApplicationUpdateForm { admin_id: Some(Some(local_user_view.person.id)), deny_reason, diff --git a/crates/api_common/src/post.rs b/crates/api_common/src/post.rs index 49327dac1..3d1bc4078 100644 --- a/crates/api_common/src/post.rs +++ b/crates/api_common/src/post.rs @@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; #[cfg(feature = "full")] use ts_rs::TS; -use url::Url; #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] @@ -20,8 +19,7 @@ use url::Url; pub struct CreatePost { pub name: String, pub community_id: CommunityId, - #[cfg_attr(feature = "full", ts(type = "string"))] - pub url: Option, + pub url: Option, /// An optional body for the post in markdown. pub body: Option, /// An optional alt_text, usable for image posts. @@ -30,9 +28,8 @@ pub struct CreatePost { pub honeypot: Option, pub nsfw: Option, pub language_id: Option, - #[cfg_attr(feature = "full", ts(type = "string"))] /// Instead of fetching a thumbnail, use a custom one. - pub custom_thumbnail: Option, + pub custom_thumbnail: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -114,17 +111,15 @@ pub struct CreatePostLike { pub struct EditPost { pub post_id: PostId, pub name: Option, - #[cfg_attr(feature = "full", ts(type = "string"))] - pub url: Option, + pub url: Option, /// An optional body for the post in markdown. pub body: Option, /// An optional alt_text, usable for image posts. pub alt_text: Option, pub nsfw: Option, pub language_id: Option, - #[cfg_attr(feature = "full", ts(type = "string"))] /// Instead of fetching a thumbnail, use a custom one. - pub custom_thumbnail: Option, + pub custom_thumbnail: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)] @@ -249,8 +244,7 @@ pub struct ListPostReportsResponse { #[cfg_attr(feature = "full", ts(export))] /// Get metadata for a given site. pub struct GetSiteMetadata { - #[cfg_attr(feature = "full", ts(type = "string"))] - pub url: Url, + pub url: String, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index 9bfb97b72..8a423ff7c 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -340,15 +340,15 @@ async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Lemm /// When adding a new avatar, banner or similar image, delete the old one. pub async fn replace_image( - new_image: &Option, + new_image: &Option>, old_image: &Option, context: &Data, ) -> LemmyResult<()> { - if let (Some(new_image), Some(old_image)) = (new_image, old_image) { + if let (Some(Some(new_image)), Some(old_image)) = (new_image, old_image) { // Note: Oftentimes front ends will include the current image in the form. // In this case, deleting `old_image` would also be deletion of `new_image`, // so the deletion must be skipped for the image to be kept. - if new_image != old_image.as_str() { + if new_image != old_image { // Ignore errors because image may be stored externally. let image = LocalImage::delete_by_url(&mut context.pool(), old_image) .await diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index bad3b8180..ba5756998 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -1004,26 +1004,25 @@ pub(crate) async fn proxy_image_link(link: Url, context: &LemmyContext) -> Lemmy } pub async fn proxy_image_link_opt_api( - link: &Option, + link: Option>, context: &LemmyContext, ) -> LemmyResult>> { - proxy_image_link_api(link, context).await.map(Some) + if let Some(Some(link)) = link { + proxy_image_link(link.into(), context) + .await + .map(Some) + .map(Some) + } else { + Ok(link) + } } pub async fn proxy_image_link_api( - link: &Option, + link: Option, context: &LemmyContext, ) -> LemmyResult> { - let link: Option = match link.as_ref().map(String::as_str) { - // An empty string is an erase - Some("") => None, - Some(str_url) => Url::parse(str_url) - .map(|u| Some(u.into())) - .with_lemmy_type(LemmyErrorType::InvalidUrl)?, - None => None, - }; - if let Some(l) = link { - proxy_image_link(l.into(), context).await.map(Some) + if let Some(link) = link { + proxy_image_link(link.into(), context).await.map(Some) } else { Ok(link) } @@ -1130,29 +1129,4 @@ mod tests { .is_ok() ); } - - #[tokio::test] - #[serial] - async fn test_diesel_option_overwrite_to_url() { - let context = LemmyContext::init_test_context().await; - - assert!(matches!( - proxy_image_link_api(&None, &context).await, - Ok(None) - )); - assert!(matches!( - proxy_image_link_opt_api(&Some(String::new()), &context).await, - Ok(Some(None)) - )); - assert!( - proxy_image_link_opt_api(&Some("invalid_url".to_string()), &context) - .await - .is_err() - ); - let example_url = "https://lemmy-alpha/image.png"; - assert!(matches!( - proxy_image_link_opt_api(&Some(example_url.to_string()), &context).await, - Ok(Some(Some(url))) if url == Url::parse(example_url).unwrap().into() - )); - } } diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index 2efd46964..636f83392 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -47,7 +47,7 @@ pub async fn create_comment( let slur_regex = local_site_to_slur_regex(&local_site); 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)?; + is_valid_body_field(&content, false)?; // Check for a community ban let post_id = data.post_id; diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 695ededfe..4c8cf9436 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -63,7 +63,9 @@ pub async fn update_comment( let slur_regex = local_site_to_slur_regex(&local_site); 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)?; + if let Some(content) = &content { + is_valid_body_field(content, false)?; + } let comment_id = data.comment_id; let form = CommentUpdateForm { diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index b0b6bea0e..4289b7d24 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -30,6 +30,7 @@ use lemmy_db_schema::{ }, }, traits::{ApubActor, Crud, Followable, Joinable}, + utils::diesel_url_create, }; use lemmy_db_views::structs::{LocalUserView, SiteView}; use lemmy_utils::{ @@ -61,11 +62,18 @@ pub async fn create_community( check_slurs(&data.title, &slur_regex)?; 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?; + + let icon = diesel_url_create(data.icon.as_deref())?; + let icon = proxy_image_link_api(icon, &context).await?; + + let banner = diesel_url_create(data.banner.as_deref())?; + let banner = proxy_image_link_api(banner, &context).await?; is_valid_actor_name(&data.name, local_site.actor_name_max_length as usize)?; - is_valid_body_field(&data.description, false)?; + + if let Some(desc) = &data.description { + is_valid_body_field(desc, false)?; + } // Double check for duplicate community actor_ids let community_actor_id = generate_local_apub_endpoint( diff --git a/crates/api_crud/src/community/update.rs b/crates/api_crud/src/community/update.rs index 33c6a47dd..6190a0ca7 100644 --- a/crates/api_crud/src/community/update.rs +++ b/crates/api_crud/src/community/update.rs @@ -21,7 +21,7 @@ use lemmy_db_schema::{ local_site::LocalSite, }, traits::Crud, - utils::{diesel_option_overwrite, naive_now}, + utils::{diesel_string_update, diesel_url_update, naive_now}, }; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{ @@ -40,18 +40,28 @@ pub async fn update_community( 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, &url_blocklist, &context).await?; - is_valid_body_field(&data.description, false)?; + + let description = diesel_string_update( + process_markdown_opt(&data.description, &slur_regex, &url_blocklist, &context) + .await? + .as_deref(), + ); + + if let Some(Some(desc)) = &description { + is_valid_body_field(desc, false)?; + } + let old_community = Community::read(&mut context.pool(), data.community_id) .await? .ok_or(LemmyErrorType::CouldntFindCommunity)?; - replace_image(&data.icon, &old_community.icon, &context).await?; - replace_image(&data.banner, &old_community.banner, &context).await?; - let description = diesel_option_overwrite(description); - let icon = proxy_image_link_opt_api(&data.icon, &context).await?; - let banner = proxy_image_link_opt_api(&data.banner, &context).await?; + let icon = diesel_url_update(data.icon.as_deref())?; + replace_image(&icon, &old_community.icon, &context).await?; + let icon = proxy_image_link_opt_api(icon, &context).await?; + + let banner = diesel_url_update(data.banner.as_deref())?; + replace_image(&banner, &old_community.banner, &context).await?; + let banner = proxy_image_link_opt_api(banner, &context).await?; // Verify its a mod (only mods can edit it) check_community_mod_action( diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 21a989d3f..0b0fad5dc 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -26,6 +26,7 @@ use lemmy_db_schema::{ post::{Post, PostInsertForm, PostLike, PostLikeForm, PostUpdateForm}, }, traits::{Crud, Likeable}, + utils::diesel_url_create, CommunityVisibility, }; use lemmy_db_views::structs::LocalUserView; @@ -37,7 +38,6 @@ use lemmy_utils::{ slurs::check_slurs, validation::{ check_url_scheme, - clean_url_params, is_url_blocked, is_valid_alt_text_field, is_valid_body_field, @@ -64,16 +64,27 @@ pub async fn create_post( let url_blocklist = get_url_blocklist(&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); + let url = diesel_url_create(data.url.as_deref())?; + let custom_thumbnail = diesel_url_create(data.custom_thumbnail.as_deref())?; 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)?; + + if let Some(url) = &url { + is_url_blocked(url, &url_blocklist)?; + check_url_scheme(url)?; + } + + if let Some(custom_thumbnail) = &custom_thumbnail { + check_url_scheme(custom_thumbnail)?; + } + + if let Some(alt_text) = &data.alt_text { + is_valid_alt_text_field(alt_text)?; + } + + if let Some(body) = &body { + is_valid_body_field(body, true)?; + } check_community_user_action( &local_user_view.person, @@ -156,7 +167,7 @@ pub async fn create_post( generate_post_link_metadata( updated_post.clone(), - custom_thumbnail, + custom_thumbnail.map(Into::into), |post| Some(SendActivityData::CreatePost(post)), Some(local_site), context.reset_request_count(), diff --git a/crates/api_crud/src/post/update.rs b/crates/api_crud/src/post/update.rs index 4b4bd9845..9e665aed6 100644 --- a/crates/api_crud/src/post/update.rs +++ b/crates/api_crud/src/post/update.rs @@ -20,16 +20,15 @@ use lemmy_db_schema::{ post::{Post, PostUpdateForm}, }, traits::Crud, - utils::{diesel_option_overwrite, naive_now}, + utils::{diesel_string_update, diesel_url_update, naive_now}, }; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, utils::{ - slurs::check_slurs_opt, + slurs::check_slurs, validation::{ check_url_scheme, - clean_url_params, is_url_blocked, is_valid_alt_text_field, is_valid_body_field, @@ -47,26 +46,43 @@ pub async fn update_post( ) -> LemmyResult> { let local_site = LocalSite::read(&mut context.pool()).await?; - // TODO No good way to handle a clear. - // Issue link: https://github.com/LemmyNet/lemmy/issues/2287 - let url = data.url.as_ref().map(clean_url_params); - let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params); + let url = diesel_url_update(data.url.as_deref())?; + + let custom_thumbnail = diesel_url_update(data.custom_thumbnail.as_deref())?; 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, &url_blocklist, &context).await?; + + let body = diesel_string_update( + process_markdown_opt(&data.body, &slur_regex, &url_blocklist, &context) + .await? + .as_deref(), + ); + + let alt_text = diesel_string_update(data.alt_text.as_deref()); if let Some(name) = &data.name { is_valid_post_title(name)?; + check_slurs(name, &slur_regex)?; } - 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)?; + if let Some(Some(body)) = &body { + is_valid_body_field(body, true)?; + } + + if let Some(Some(alt_text)) = &alt_text { + is_valid_alt_text_field(alt_text)?; + } + + if let Some(Some(url)) = &url { + is_url_blocked(url, &url_blocklist)?; + check_url_scheme(url)?; + } + + if let Some(Some(custom_thumbnail)) = &custom_thumbnail { + check_url_scheme(custom_thumbnail)?; + } let post_id = data.post_id; let orig_post = Post::read(&mut context.pool(), post_id) @@ -95,9 +111,9 @@ pub async fn update_post( let post_form = PostUpdateForm { name: data.name.clone(), - url: Some(url.map(Into::into)), - body: diesel_option_overwrite(body), - alt_text: diesel_option_overwrite(data.alt_text.clone()), + url, + body, + alt_text, nsfw: data.nsfw, language_id: data.language_id, updated: Some(Some(naive_now())), @@ -111,7 +127,7 @@ pub async fn update_post( generate_post_link_metadata( updated_post.clone(), - custom_thumbnail, + custom_thumbnail.flatten().map(Into::into), |post| Some(SendActivityData::UpdatePost(post)), Some(local_site), context.reset_request_count(), diff --git a/crates/api_crud/src/private_message/create.rs b/crates/api_crud/src/private_message/create.rs index e977a6c86..0381d196c 100644 --- a/crates/api_crud/src/private_message/create.rs +++ b/crates/api_crud/src/private_message/create.rs @@ -39,7 +39,7 @@ pub async fn create_private_message( let slur_regex = local_site_to_slur_regex(&local_site); 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)?; + is_valid_body_field(&content, false)?; check_person_block( local_user_view.person.id, diff --git a/crates/api_crud/src/private_message/update.rs b/crates/api_crud/src/private_message/update.rs index 2842fea65..364d5c2e3 100644 --- a/crates/api_crud/src/private_message/update.rs +++ b/crates/api_crud/src/private_message/update.rs @@ -41,7 +41,7 @@ pub async fn update_private_message( let slur_regex = local_site_to_slur_regex(&local_site); 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)?; + is_valid_body_field(&content, false)?; let private_message_id = data.private_message_id; PrivateMessage::update( diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index 466c7ff1d..6b1909966 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -11,7 +11,7 @@ use lemmy_api_common::{ local_site_rate_limit_to_rate_limit_config, local_site_to_slur_regex, process_markdown_opt, - proxy_image_link_opt_api, + proxy_image_link_api, }, }; use lemmy_db_schema::{ @@ -23,7 +23,7 @@ use lemmy_db_schema::{ tagline::Tagline, }, traits::Crud, - utils::{diesel_option_overwrite, naive_now}, + utils::{diesel_string_update, diesel_url_create, naive_now}, }; use lemmy_db_views::structs::{LocalUserView, SiteView}; use lemmy_utils::{ @@ -61,21 +61,25 @@ pub async fn create_site( let slur_regex = local_site_to_slur_regex(&local_site); 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?; + + let icon = diesel_url_create(data.icon.as_deref())?; + let icon = proxy_image_link_api(icon, &context).await?; + + let banner = diesel_url_create(data.banner.as_deref())?; + let banner = proxy_image_link_api(banner, &context).await?; let site_form = SiteUpdateForm { name: Some(data.name.clone()), - sidebar: diesel_option_overwrite(sidebar), - description: diesel_option_overwrite(data.description.clone()), - icon, - banner, + sidebar: diesel_string_update(sidebar.as_deref()), + description: diesel_string_update(data.description.as_deref()), + icon: Some(icon), + banner: Some(banner), actor_id: Some(actor_id), last_refreshed_at: Some(naive_now()), inbox_url, private_key: Some(Some(keypair.private_key)), public_key: Some(keypair.public_key), - content_warning: diesel_option_overwrite(data.content_warning.clone()), + content_warning: diesel_string_update(data.content_warning.as_deref()), ..Default::default() }; @@ -91,16 +95,16 @@ pub async fn create_site( enable_nsfw: data.enable_nsfw, community_creation_admin_only: data.community_creation_admin_only, require_email_verification: data.require_email_verification, - application_question: diesel_option_overwrite(data.application_question.clone()), + application_question: diesel_string_update(data.application_question.as_deref()), private_instance: data.private_instance, default_theme: data.default_theme.clone(), default_post_listing_type: data.default_post_listing_type, default_sort_type: data.default_sort_type, - legal_information: diesel_option_overwrite(data.legal_information.clone()), + legal_information: diesel_string_update(data.legal_information.as_deref()), application_email_admins: data.application_email_admins, hide_modlog_mod_names: data.hide_modlog_mod_names, updated: Some(Some(naive_now())), - slur_filter_regex: diesel_option_overwrite(data.slur_filter_regex.clone()), + slur_filter_regex: diesel_string_update(data.slur_filter_regex.as_deref()), actor_name_max_length: data.actor_name_max_length, federation_enabled: data.federation_enabled, captcha_enabled: data.captcha_enabled, @@ -179,7 +183,9 @@ fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) -> )?; // Ensure that the sidebar has fewer than the max num characters... - is_valid_body_field(&create_site.sidebar, false)?; + if let Some(body) = &create_site.sidebar { + is_valid_body_field(body, false)?; + } application_question_check( &local_site.application_question, diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index 7efa9b568..f6377038d 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -27,7 +27,7 @@ use lemmy_db_schema::{ tagline::Tagline, }, traits::Crud, - utils::{diesel_option_overwrite, naive_now}, + utils::{diesel_string_update, diesel_url_update, naive_now}, RegistrationMode, }; use lemmy_db_views::structs::{LocalUserView, SiteView}; @@ -67,22 +67,29 @@ pub async fn update_site( SiteLanguage::update(&mut context.pool(), discussion_languages.clone(), &site).await?; } - replace_image(&data.icon, &site.icon, &context).await?; - replace_image(&data.banner, &site.banner, &context).await?; - let slur_regex = local_site_to_slur_regex(&local_site); 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?; + let sidebar = diesel_string_update( + process_markdown_opt(&data.sidebar, &slur_regex, &url_blocklist, &context) + .await? + .as_deref(), + ); + + let icon = diesel_url_update(data.icon.as_deref())?; + replace_image(&icon, &site.icon, &context).await?; + let icon = proxy_image_link_opt_api(icon, &context).await?; + + let banner = diesel_url_update(data.banner.as_deref())?; + replace_image(&banner, &site.banner, &context).await?; + let banner = proxy_image_link_opt_api(banner, &context).await?; let site_form = SiteUpdateForm { name: data.name.clone(), - sidebar: diesel_option_overwrite(sidebar), - description: diesel_option_overwrite(data.description.clone()), + sidebar, + description: diesel_string_update(data.description.as_deref()), icon, banner, - content_warning: diesel_option_overwrite(data.content_warning.clone()), + content_warning: diesel_string_update(data.content_warning.as_deref()), updated: Some(Some(naive_now())), ..Default::default() }; @@ -99,16 +106,16 @@ pub async fn update_site( enable_nsfw: data.enable_nsfw, community_creation_admin_only: data.community_creation_admin_only, require_email_verification: data.require_email_verification, - application_question: diesel_option_overwrite(data.application_question.clone()), + application_question: diesel_string_update(data.application_question.as_deref()), private_instance: data.private_instance, default_theme: data.default_theme.clone(), default_post_listing_type: data.default_post_listing_type, default_sort_type: data.default_sort_type, - legal_information: diesel_option_overwrite(data.legal_information.clone()), + legal_information: diesel_string_update(data.legal_information.as_deref()), application_email_admins: data.application_email_admins, hide_modlog_mod_names: data.hide_modlog_mod_names, updated: Some(Some(naive_now())), - slur_filter_regex: diesel_option_overwrite(data.slur_filter_regex.clone()), + slur_filter_regex: diesel_string_update(data.slur_filter_regex.as_deref()), actor_name_max_length: data.actor_name_max_length, federation_enabled: data.federation_enabled, captcha_enabled: data.captcha_enabled, @@ -229,7 +236,9 @@ fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> Lemm )?; // Ensure that the sidebar has fewer than the max num characters... - is_valid_body_field(&edit_site.sidebar, false)?; + if let Some(body) = &edit_site.sidebar { + is_valid_body_field(body, false)?; + } application_question_check( &local_site.application_question, diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 59f4920d3..7e4254840 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -219,7 +219,10 @@ impl Object for ApubPost { } else { None }; - check_url_scheme(&url)?; + + if let Some(url) = &url { + check_url_scheme(url)?; + } let alt_text = first_attachment.cloned().and_then(Attachment::alt_text); diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index c6170fcd4..4267bb360 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -29,6 +29,7 @@ use i_love_jesus::CursorKey; use lemmy_utils::{ error::{LemmyErrorExt, LemmyErrorType, LemmyResult}, settings::SETTINGS, + utils::validation::clean_url_params, }; use once_cell::sync::Lazy; use regex::Regex; @@ -287,37 +288,35 @@ pub fn is_email_regex(test: &str) -> bool { EMAIL_REGEX.is_match(test) } -pub fn diesel_option_overwrite(opt: Option) -> Option> { +/// Takes an API text input, and converts it to an optional diesel DB update. +pub fn diesel_string_update(opt: Option<&str>) -> Option> { match opt { // An empty string is an erase - Some(unwrapped) => { - if !unwrapped.eq("") { - Some(Some(unwrapped)) - } else { - Some(None) - } - } + Some("") => Some(None), + Some(str) => Some(Some(str.into())), None => None, } } -pub fn diesel_option_overwrite_to_url(opt: &Option) -> LemmyResult>> { - match opt.as_ref().map(String::as_str) { +/// Takes an optional API URL-type input, and converts it to an optional diesel DB update. +/// Also cleans the url params. +pub fn diesel_url_update(opt: Option<&str>) -> LemmyResult>> { + match opt { // An empty string is an erase Some("") => Ok(Some(None)), Some(str_url) => Url::parse(str_url) - .map(|u| Some(Some(u.into()))) + .map(|u| Some(Some(clean_url_params(&u).into()))) .with_lemmy_type(LemmyErrorType::InvalidUrl), None => Ok(None), } } -pub fn diesel_option_overwrite_to_url_create(opt: &Option) -> LemmyResult> { - match opt.as_ref().map(String::as_str) { - // An empty string is nothing - Some("") => Ok(None), +/// Takes an optional API URL-type input, and converts it to an optional diesel DB create. +/// Also cleans the url params. +pub fn diesel_url_create(opt: Option<&str>) -> LemmyResult> { + match opt { Some(str_url) => Url::parse(str_url) - .map(|u| Some(u.into())) + .map(|u| Some(clean_url_params(&u).into())) .with_lemmy_type(LemmyErrorType::InvalidUrl), None => Ok(None), } @@ -569,7 +568,6 @@ impl Queries { } #[cfg(test)] -#[allow(clippy::unwrap_used)] #[allow(clippy::indexing_slicing)] mod tests { @@ -593,26 +591,24 @@ mod tests { #[test] fn test_diesel_option_overwrite() { - assert_eq!(diesel_option_overwrite(None), None); - assert_eq!(diesel_option_overwrite(Some(String::new())), Some(None)); + assert_eq!(diesel_string_update(None), None); + assert_eq!(diesel_string_update(Some("")), Some(None)); assert_eq!( - diesel_option_overwrite(Some("test".to_string())), + diesel_string_update(Some("test")), Some(Some("test".to_string())) ); } #[test] - fn test_diesel_option_overwrite_to_url() { - assert!(matches!(diesel_option_overwrite_to_url(&None), Ok(None))); - assert!(matches!( - diesel_option_overwrite_to_url(&Some(String::new())), - Ok(Some(None)) - )); - assert!(diesel_option_overwrite_to_url(&Some("invalid_url".to_string())).is_err()); + fn test_diesel_option_overwrite_to_url() -> LemmyResult<()> { + assert!(matches!(diesel_url_update(None), Ok(None))); + assert!(matches!(diesel_url_update(Some("")), Ok(Some(None)))); + assert!(diesel_url_update(Some("invalid_url")).is_err()); let example_url = "https://example.com"; assert!(matches!( - diesel_option_overwrite_to_url(&Some(example_url.to_string())), - Ok(Some(Some(url))) if url == Url::parse(example_url).unwrap().into() + diesel_url_update(Some(example_url)), + Ok(Some(Some(url))) if url == Url::parse(example_url)?.into() )); + Ok(()) } } diff --git a/crates/utils/src/utils/validation.rs b/crates/utils/src/utils/validation.rs index a913e6243..c07a129b4 100644 --- a/crates/utils/src/utils/validation.rs +++ b/crates/utils/src/utils/validation.rs @@ -158,14 +158,12 @@ pub fn is_valid_post_title(title: &str) -> LemmyResult<()> { } /// This could be post bodies, comments, or any description field -pub fn is_valid_body_field(body: &Option, post: bool) -> LemmyResult<()> { - if let Some(body) = body { - if post { - max_length_check(body, POST_BODY_MAX_LENGTH, LemmyErrorType::InvalidBodyField)?; - } else { - max_length_check(body, BODY_MAX_LENGTH, LemmyErrorType::InvalidBodyField)?; - }; - } +pub fn is_valid_body_field(body: &str, post: bool) -> LemmyResult<()> { + if post { + max_length_check(body, POST_BODY_MAX_LENGTH, LemmyErrorType::InvalidBodyField)?; + } else { + max_length_check(body, BODY_MAX_LENGTH, LemmyErrorType::InvalidBodyField)?; + }; Ok(()) } @@ -173,16 +171,14 @@ pub fn is_valid_bio_field(bio: &str) -> LemmyResult<()> { max_length_check(bio, BIO_MAX_LENGTH, LemmyErrorType::BioLengthOverflow) } -pub fn is_valid_alt_text_field(alt_text: &Option) -> LemmyResult<()> { - if let Some(alt_text) = alt_text { - max_length_check( - alt_text, - ALT_TEXT_MAX_LENGTH, - LemmyErrorType::AltTextLengthOverflow, - ) - } else { - Ok(()) - } +pub fn is_valid_alt_text_field(alt_text: &str) -> LemmyResult<()> { + max_length_check( + alt_text, + ALT_TEXT_MAX_LENGTH, + LemmyErrorType::AltTextLengthOverflow, + )?; + + Ok(()) } /// Checks the site name length, the limit as defined in the DB. @@ -287,23 +283,17 @@ pub fn check_site_visibility_valid( } } -pub fn check_url_scheme(url: &Option) -> LemmyResult<()> { - if let Some(url) = url { - if !ALLOWED_POST_URL_SCHEMES.contains(&url.scheme()) { - Err(LemmyErrorType::InvalidUrlScheme.into()) - } else { - Ok(()) - } - } else { - Ok(()) +pub fn check_url_scheme(url: &Url) -> LemmyResult<()> { + if !ALLOWED_POST_URL_SCHEMES.contains(&url.scheme()) { + Err(LemmyErrorType::InvalidUrlScheme)? } + + Ok(()) } -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)? - } +pub fn is_url_blocked(url: &Url, blocklist: &RegexSet) -> LemmyResult<()> { + if blocklist.is_match(url.as_str()) { + Err(LemmyErrorType::BlockedUrl)? } Ok(()) @@ -350,12 +340,11 @@ pub fn build_url_str_without_scheme(url_str: &str) -> LemmyResult { } #[cfg(test)] -#[allow(clippy::unwrap_used)] #[allow(clippy::indexing_slicing)] mod tests { use crate::{ - error::LemmyErrorType, + error::{LemmyErrorType, LemmyResult}, utils::validation::{ build_and_check_regex, check_site_visibility_valid, @@ -379,15 +368,17 @@ mod tests { use url::Url; #[test] - fn test_clean_url_params() { - let url = Url::parse("https://example.com/path/123?utm_content=buffercf3b2&utm_medium=social&username=randomuser&id=123").unwrap(); + fn test_clean_url_params() -> LemmyResult<()> { + let url = Url::parse("https://example.com/path/123?utm_content=buffercf3b2&utm_medium=social&username=randomuser&id=123")?; let cleaned = clean_url_params(&url); - let expected = Url::parse("https://example.com/path/123?username=randomuser&id=123").unwrap(); + let expected = Url::parse("https://example.com/path/123?username=randomuser&id=123")?; assert_eq!(expected.to_string(), cleaned.to_string()); - let url = Url::parse("https://example.com/path/123").unwrap(); + let url = Url::parse("https://example.com/path/123")?; let cleaned = clean_url_params(&url); assert_eq!(url.to_string(), cleaned.to_string()); + + Ok(()) } #[test] @@ -465,7 +456,7 @@ mod tests { } #[test] - fn test_valid_site_name() { + fn test_valid_site_name() -> LemmyResult<()> { let valid_names = [ (0..SITE_NAME_MAX_LENGTH).map(|_| 'A').collect::(), String::from("A"), @@ -496,12 +487,13 @@ mod tests { assert!(result.is_err()); assert!( - result.unwrap_err().error_type.eq(&expected_err.clone()), + result.is_err_and(|e| e.error_type.eq(&expected_err.clone())), "Testing {}, expected error {}", invalid_name, expected_err ); }); + Ok(()) } #[test] @@ -513,10 +505,7 @@ mod tests { assert!( invalid_result.is_err() - && invalid_result - .unwrap_err() - .error_type - .eq(&LemmyErrorType::BioLengthOverflow) + && invalid_result.is_err_and(|e| e.error_type.eq(&LemmyErrorType::BioLengthOverflow)) ); } @@ -537,10 +526,9 @@ mod tests { assert!( invalid_result.is_err() - && invalid_result - .unwrap_err() + && invalid_result.is_err_and(|e| e .error_type - .eq(&LemmyErrorType::SiteDescriptionLengthOverflow) + .eq(&LemmyErrorType::SiteDescriptionLengthOverflow)) ); } @@ -570,7 +558,7 @@ mod tests { assert!(result.is_err()); assert!( - result.unwrap_err().error_type.eq(&expected_err.clone()), + result.is_err_and(|e| e.error_type.eq(&expected_err.clone())), "Testing regex {:?}, expected error {}", regex_str, expected_err @@ -591,38 +579,38 @@ mod tests { } #[test] - fn test_check_url_scheme() { - assert!(check_url_scheme(&None).is_ok()); - assert!(check_url_scheme(&Some(Url::parse("http://example.com").unwrap())).is_ok()); - assert!(check_url_scheme(&Some(Url::parse("https://example.com").unwrap())).is_ok()); - assert!(check_url_scheme(&Some(Url::parse("https://example.com").unwrap())).is_ok()); - assert!(check_url_scheme(&Some(Url::parse("ftp://example.com").unwrap())).is_err()); - assert!(check_url_scheme(&Some(Url::parse("javascript:void").unwrap())).is_err()); + fn test_check_url_scheme() -> LemmyResult<()> { + assert!(check_url_scheme(&Url::parse("http://example.com")?).is_ok()); + assert!(check_url_scheme(&Url::parse("https://example.com")?).is_ok()); + assert!(check_url_scheme(&Url::parse("https://example.com")?).is_ok()); + assert!(check_url_scheme(&Url::parse("ftp://example.com")?).is_err()); + assert!(check_url_scheme(&Url::parse("javascript:void")?).is_err()); 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()); + assert!(check_url_scheme(&Url::parse(magnet_link)?).is_ok()); + + Ok(()) } #[test] - fn test_url_block() { + fn test_url_block() -> LemmyResult<()> { 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(&Url::parse("https://example.blog")?, &set).is_ok()); - assert!(is_url_blocked(&Some(Url::parse("https://example.org").unwrap()), &set).is_ok()); + assert!(is_url_blocked(&Url::parse("https://example.org")?, &set).is_ok()); - assert!(is_url_blocked(&None, &set).is_ok()); + assert!(is_url_blocked(&Url::parse("https://example.com")?, &set).is_err()); - assert!(is_url_blocked(&Some(Url::parse("https://example.com").unwrap()), &set).is_err()); + Ok(()) } #[test] - fn test_url_parsed() { + fn test_url_parsed() -> LemmyResult<()> { // Make sure the scheme is removed, and uniques also assert_eq!( &check_urls_are_valid(&vec![ @@ -630,8 +618,7 @@ mod tests { "http://example.com".to_string(), "https://example.com".to_string(), "https://example.com/test?q=test2&q2=test3#test4".to_string(), - ]) - .unwrap(), + ])?, &vec![ "example.com".to_string(), "example.com/test?q=test2&q2=test3#test4".to_string() @@ -639,5 +626,6 @@ mod tests { ); assert!(check_urls_are_valid(&vec!["https://example .com".to_string()]).is_err()); + Ok(()) } } From 3d2532208954f206bc6740ef474fe392d608e09f Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 6 Jun 2024 10:43:40 -0400 Subject: [PATCH 28/74] Version 0.19.4-rc.9 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ crates/utils/translations | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 647e8e915..31eb4400a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2710,7 +2710,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "activitypub_federation", "actix-web", @@ -2739,7 +2739,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "activitypub_federation", "actix-web", @@ -2777,7 +2777,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "accept-language", "activitypub_federation", @@ -2800,7 +2800,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "activitypub_federation", "actix-web", @@ -2838,7 +2838,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "anyhow", "clap", @@ -2853,7 +2853,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "activitypub_federation", "anyhow", @@ -2894,7 +2894,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "actix-web", "chrono", @@ -2916,7 +2916,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "chrono", "diesel", @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "diesel", "diesel-async", @@ -2949,7 +2949,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "activitypub_federation", "anyhow", @@ -2974,7 +2974,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "activitypub_federation", "actix-web", @@ -2999,7 +2999,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "activitypub_federation", "actix-cors", @@ -3042,7 +3042,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 9b9958725..2ef7b3056 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.8" +version = "0.19.4-rc.9" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.8", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.8", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.8", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.8", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.8", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.8", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.8", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.8", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.8", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.8", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.8", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.9", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.9", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.9", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.9", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.9", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.9", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.9", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.9", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.9", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.9", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.9", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } diff --git a/crates/utils/translations b/crates/utils/translations index 3b43a3bb5..b3bdd9cf7 160000 --- a/crates/utils/translations +++ b/crates/utils/translations @@ -1 +1 @@ -Subproject commit 3b43a3bb56af0cde6712594e4dce78038e186185 +Subproject commit b3bdd9cf78a234438dcc7ccb904739280eda5915 From b0447ad94de962c6deb58708deb88057c7e76278 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 6 Jun 2024 20:44:36 -0400 Subject: [PATCH 29/74] Upgrading lemmy-js-client version to 0.19.4 (#4787) * Upgrading lemmy-js-client version to 0.19.4 * Upgrading deps before renovate. --- Cargo.lock | 310 +++++++++++++++++++-------------------- Cargo.toml | 14 +- api_tests/package.json | 2 +- api_tests/pnpm-lock.yaml | 10 +- scripts/upgrade_deps.sh | 3 + 5 files changed, 165 insertions(+), 174 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31eb4400a..e721a7971 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ checksum = "8f27d075294830fcab6f66e320dab524bc6d048f4a151698e153205559113772" [[package]] name = "activitypub_federation" -version = "0.5.7" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69876675c80e73ab5e15e07b414cd3aa7c4c4e91f81fa43b52ea3ef28cbc225c" +checksum = "ac8ff2d0151ce9ac02eb29e4a58b41d28693f141f7963d4bfabd2f9d402ecec7" dependencies = [ "activitystreams-kinds", "actix-web", @@ -157,7 +157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -315,7 +315,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -453,9 +453,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -497,9 +497,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c90a406b4495d129f00461241616194cb8a032c8d1c53c657f0961d5f8e0498" +checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" dependencies = [ "flate2", "futures-core", @@ -510,11 +510,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 4.0.3", + "event-listener", "event-listener-strategy", "pin-project-lite", ] @@ -538,7 +538,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -549,7 +549,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -585,9 +585,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-lc-rs" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8487b59d62764df8231cb371c459314df895b41756df457a1fb1243d65c89195" +checksum = "474d7cec9d0a1126fad1b224b767fcbf351c23b0309bb21ec210bcfd379926a5" dependencies = [ "aws-lc-sys", "mirai-annotations", @@ -598,9 +598,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c15eb61145320320eb919d9bab524617a7aa4216c78d342fae3a758bc33073e4" +checksum = "7505fc3cb7acbf42699a43a79dd9caa4ed9e99861dfbb837c5c0fb5a0a8d2980" dependencies = [ "bindgen", "cc", @@ -624,7 +624,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "itoa", "matchit 0.7.3", "memchr", @@ -716,7 +716,7 @@ dependencies = [ "async-trait", "futures-channel", "futures-util", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "tokio", ] @@ -771,7 +771,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.65", + "syn 2.0.66", "which", ] @@ -843,9 +843,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6221fe77a248b9117d431ad93761222e1cf8ff282d9d1d5d9f53d6299a1cf76" +checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -967,9 +967,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -978,9 +978,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" dependencies = [ "clap_builder", "clap_derive", @@ -988,9 +988,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" dependencies = [ "anstream", "anstyle", @@ -1000,21 +1000,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "clokwerk" @@ -1104,7 +1104,7 @@ dependencies = [ "ron", "serde", "serde_json", - "toml 0.8.13", + "toml 0.8.14", "yaml-rust", ] @@ -1307,7 +1307,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1329,7 +1329,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1399,7 +1399,7 @@ checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1431,7 +1431,7 @@ checksum = "d150dea618e920167e5973d70ae6ece4385b7164e0d799fe7c122dd0a5d912ad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1452,7 +1452,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1462,7 +1462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1529,7 +1529,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1540,7 +1540,7 @@ checksum = "d5adf688c584fe33726ce0e2898f608a2a92578ac94a4a92fcecf73214fe0716" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1552,7 +1552,7 @@ dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1582,7 +1582,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1716,7 +1716,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1761,20 +1761,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "4.0.3" +version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", @@ -1783,11 +1772,11 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.4.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ - "event-listener 4.0.3", + "event-listener", "pin-project-lite", ] @@ -1841,12 +1830,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "finl_unicode" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" - [[package]] name = "flagset" version = "0.4.5" @@ -1975,7 +1958,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -2248,7 +2231,7 @@ dependencies = [ "markup5ever 0.12.1", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -2353,9 +2336,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -2419,7 +2402,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.28", + "hyper 0.14.29", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -2432,7 +2415,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.28", + "hyper 0.14.29", "native-tls", "tokio", "tokio-native-tls", @@ -2440,9 +2423,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", "futures-channel", @@ -2475,7 +2458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8215279f83f9b829403812f845aa2d0dd5966332aa2fd0334a375256f3dd0322" dependencies = [ "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -2875,7 +2858,7 @@ dependencies = [ "once_cell", "pretty_assertions", "regex", - "rustls 0.23.8", + "rustls 0.23.9", "serde", "serde_json", "serde_with", @@ -3274,7 +3257,7 @@ dependencies = [ "html5ever 0.27.0", "markup5ever 0.12.1", "tendril", - "xml5ever 0.18.0", + "xml5ever 0.18.1", ] [[package]] @@ -3452,10 +3435,10 @@ dependencies = [ "crossbeam-channel", "crossbeam-epoch", "crossbeam-utils", - "event-listener 5.3.0", + "event-listener", "futures-util", "once_cell", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "quanta", "rustc_version", "smallvec", @@ -3479,11 +3462,10 @@ checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -3609,7 +3591,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -3840,9 +3822,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core 0.9.10", @@ -3990,9 +3972,9 @@ dependencies = [ [[package]] name = "pict-rs" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27cb4fd629bb8a115b8ae2701e2c355f6e5e9ad6bf22d9d0e7b7b645fb0f81dc" +checksum = "f60cdba5d277139be805efb823d2c2a9801f508dd9e5f724225a75a4834b60b4" dependencies = [ "actix-form-data", "actix-web", @@ -4023,7 +4005,7 @@ dependencies = [ "reqwest 0.12.4", "reqwest-middleware 0.3.1", "reqwest-tracing 0.5.0", - "rustls 0.23.8", + "rustls 0.23.9", "rustls-channel-resolver", "rustls-pemfile 2.1.2", "rusty-s3", @@ -4041,7 +4023,7 @@ dependencies = [ "tokio-postgres", "tokio-postgres-generic-rustls", "tokio-util", - "toml 0.8.13", + "toml 0.8.14", "tracing", "tracing-actix-web", "tracing-error", @@ -4070,7 +4052,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4215,14 +4197,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] name = "proc-macro2" -version = "1.0.83" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -4261,7 +4243,7 @@ dependencies = [ "lazy_static", "libc", "memchr", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "procfs", "protobuf", "thiserror", @@ -4310,7 +4292,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4434,7 +4416,7 @@ checksum = "a25d631e41bfb5fdcde1d4e2215f62f7f0afa3ff11e26563765bd6ea1d229aeb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4491,7 +4473,7 @@ dependencies = [ "time", "tokio", "tokio-postgres", - "toml 0.8.13", + "toml 0.8.14", "url", "walkdir", ] @@ -4507,7 +4489,7 @@ dependencies = [ "quote", "refinery-core", "regex", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4575,7 +4557,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-tls", "ipnet", "js-sys", @@ -4841,9 +4823,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.8" +version = "0.23.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79adb16721f56eb2d843e67676896a61ce7a0fa622dc18d3e372477a029d2740" +checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" dependencies = [ "aws-lc-rs", "log", @@ -4862,7 +4844,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fede2a247359da6b4998f7723ec6468c2d6a577a5d8c17e54f21806426ad2290" dependencies = [ "nanorand", - "rustls 0.23.8", + "rustls 0.23.9", ] [[package]] @@ -5048,7 +5030,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5120,7 +5102,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5132,7 +5114,7 @@ dependencies = [ "futures", "log", "once_cell", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "scc", "serial_test_derive", ] @@ -5145,7 +5127,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5288,7 +5270,7 @@ checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5354,7 +5336,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "phf_shared 0.10.0", "precomputed-hash", "serde", @@ -5374,13 +5356,13 @@ dependencies = [ [[package]] name = "stringprep" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" dependencies = [ - "finl_unicode", "unicode-bidi", "unicode-normalization", + "unicode-properties", ] [[package]] @@ -5409,15 +5391,15 @@ checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5439,9 +5421,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.65" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -5561,7 +5543,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5644,21 +5626,21 @@ checksum = "8d9ef545650e79f30233c0003bcc2504d7efac6dad25fca40744de773fe2049c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", "libc", "mio", "num_cpus", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", "socket2", @@ -5679,13 +5661,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5711,7 +5693,7 @@ dependencies = [ "futures-channel", "futures-util", "log", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "percent-encoding", "phf 0.11.2", "pin-project-lite", @@ -5731,7 +5713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8e98c31c29b2666fb28720739e11476166be4ead1610a37dcd7414bb124413a" dependencies = [ "aws-lc-rs", - "rustls 0.23.8", + "rustls 0.23.9", "tokio", "tokio-postgres", "tokio-rustls 0.26.0", @@ -5745,7 +5727,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04fb792ccd6bbcd4bba408eb8a292f70fc4a3589e5d793626f45190e6454b6ab" dependencies = [ "ring", - "rustls 0.23.8", + "rustls 0.23.9", "tokio", "tokio-postgres", "tokio-rustls 0.26.0", @@ -5769,7 +5751,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.8", + "rustls 0.23.9", "rustls-pki-types", "tokio", ] @@ -5812,14 +5794,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -5846,15 +5828,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.8", + "winnow 0.6.13", ] [[package]] @@ -5873,7 +5855,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-timeout", "percent-encoding", "pin-project", @@ -5903,7 +5885,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-timeout", "percent-encoding", "pin-project", @@ -5930,7 +5912,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-timeout", "percent-encoding", "pin-project", @@ -6005,9 +5987,9 @@ dependencies = [ [[package]] name = "tracing-actix-web" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa069bd1503dd526ee793bb3fce408895136c95fc86d2edb2acf1c646d7f0684" +checksum = "4ee9e39a66d9b615644893ffc1704d2a89b5b315b7fd0228ad3182ca9a306b19" dependencies = [ "actix-web", "mutually_exclusive_features", @@ -6026,7 +6008,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -6159,9 +6141,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +checksum = "1b2cb4fbb9995eeb36ac86fadf24031ccd58f99d6b4b2d7b911db70bddb80d90" [[package]] name = "try-lock" @@ -6189,7 +6171,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", "termcolor", ] @@ -6210,7 +6192,7 @@ checksum = "1f718dfaf347dcb5b983bfc87608144b0bad87970aebcbea5ce44d2a30c08e63" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -6256,10 +6238,16 @@ dependencies = [ ] [[package]] -name = "unicode-width" -version = "0.1.12" +name = "unicode-properties" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" + +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -6396,7 +6384,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -6430,7 +6418,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6513,9 +6501,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +checksum = "3c452ad30530b54a4d8e71952716a212b08efd0f3562baa66c29a618b07da7c3" dependencies = [ "rustls-pki-types", ] @@ -6743,9 +6731,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -6820,9 +6808,9 @@ dependencies = [ [[package]] name = "xml5ever" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c376f76ed09df711203e20c3ef5ce556f0166fa03d39590016c0fd625437fad" +checksum = "9bbb26405d8e919bc1547a5aa9abc95cbfa438f04844f5fdd9dc7596b748bf69" dependencies = [ "log", "mac", @@ -6861,14 +6849,14 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -6881,7 +6869,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 2ef7b3056..1c77b9836 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,7 +105,7 @@ activitypub_federation = { version = "0.5.6", default-features = false, features diesel = "2.1.6" diesel_migrations = "2.1.0" diesel-async = "0.4.1" -serde = { version = "1.0.202", features = ["derive"] } +serde = { version = "1.0.203", features = ["derive"] } serde_with = "3.8.1" actix-web = { version = "4.6.0", default-features = false, features = [ "macros", @@ -116,7 +116,7 @@ actix-web = { version = "4.6.0", default-features = false, features = [ "cookies", ] } tracing = "0.1.40" -tracing-actix-web = { version = "0.7.10", default-features = false } +tracing-actix-web = { version = "0.7.11", default-features = false } tracing-error = "0.2.0" tracing-log = "0.2.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } @@ -139,13 +139,13 @@ anyhow = { version = "1.0.86", features = [ diesel_ltree = "0.3.1" typed-builder = "0.18.2" serial_test = "3.1.1" -tokio = { version = "1.37.0", features = ["full"] } +tokio = { version = "1.38.0", features = ["full"] } regex = "1.10.4" once_cell = "1.19.0" diesel-derive-newtype = "2.1.2" diesel-derive-enum = { version = "2.1.0", features = ["postgres"] } strum = "0.26.2" -strum_macros = "0.26.2" +strum_macros = "0.26.4" itertools = "0.13.0" futures = "0.3.30" http = "0.2.12" @@ -157,7 +157,7 @@ ts-rs = { version = "7.1.1", features = [ "chrono-impl", "no-serde-warnings", ] } -rustls = { version = "0.23.8", features = ["ring"] } +rustls = { version = "0.23.9", features = ["ring"] } futures-util = "0.3.30" tokio-postgres = "0.7.10" tokio-postgres-rustls = "0.12.0" @@ -165,7 +165,7 @@ urlencoding = "2.1.3" enum-map = "2.7" moka = { version = "0.12.7", features = ["future"] } i-love-jesus = { version = "0.1.0" } -clap = { version = "4.5.4", features = ["derive", "env"] } +clap = { version = "4.5.6", features = ["derive", "env"] } pretty_assertions = "1.4.0" derive-new = "0.6.0" @@ -197,7 +197,7 @@ tracing-opentelemetry = { workspace = true, optional = true } opentelemetry = { workspace = true, optional = true } console-subscriber = { version = "0.2.0", optional = true } opentelemetry-otlp = { version = "0.12.0", optional = true } -pict-rs = { version = "0.5.14", optional = true } +pict-rs = { version = "0.5.15", optional = true } tokio.workspace = true actix-cors = "0.7.0" futures-util = { workspace = true } diff --git a/api_tests/package.json b/api_tests/package.json index 31fbe2161..87f864012 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -28,7 +28,7 @@ "eslint": "^8.57.0", "eslint-plugin-prettier": "^5.1.3", "jest": "^29.5.0", - "lemmy-js-client": "0.19.4-alpha.18", + "lemmy-js-client": "0.19.4", "prettier": "^3.2.5", "ts-jest": "^29.1.0", "typescript": "^5.4.4" diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index a10c03298..a0d281196 100644 --- a/api_tests/pnpm-lock.yaml +++ b/api_tests/pnpm-lock.yaml @@ -33,8 +33,8 @@ importers: specifier: ^29.5.0 version: 29.7.0(@types/node@20.12.4) lemmy-js-client: - specifier: 0.19.4-alpha.18 - version: 0.19.4-alpha.18 + specifier: 0.19.4 + version: 0.19.4 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -1158,8 +1158,8 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} - lemmy-js-client@0.19.4-alpha.18: - resolution: {integrity: sha512-CUKRIiINZF2zOfK5WzBDF071LjMmRBFHwiSYBMGJyQP1zu8sPKCb/ptg25WWrf79Y4uOaVLctgHg3oEUXmSUmQ==} + lemmy-js-client@0.19.4: + resolution: {integrity: sha512-k3d+YRDj3+JuuEP+nuEg27efR/e4m8oMk2BoC8jq9AnMrwSAKfsN2F2vG70Zke0amXtOclDZrCSHkIpNw99ikg==} leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} @@ -3082,7 +3082,7 @@ snapshots: kleur@3.0.3: {} - lemmy-js-client@0.19.4-alpha.18: {} + lemmy-js-client@0.19.4: {} leven@3.1.0: {} diff --git a/scripts/upgrade_deps.sh b/scripts/upgrade_deps.sh index b20e9f35c..fd2eb6655 100755 --- a/scripts/upgrade_deps.sh +++ b/scripts/upgrade_deps.sh @@ -5,6 +5,9 @@ pushd ../ # Check unused deps cargo udeps --all-targets +# Update deps first +cargo update + # Upgrade deps cargo upgrade From 844b84a01ab00cae565db5c6ce0f1b50f8425bae Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 6 Jun 2024 20:46:03 -0400 Subject: [PATCH 30/74] Version 0.19.4-rc.10 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e721a7971..57a366519 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2693,7 +2693,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "activitypub_federation", "actix-web", @@ -2722,7 +2722,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "activitypub_federation", "actix-web", @@ -2760,7 +2760,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "accept-language", "activitypub_federation", @@ -2783,7 +2783,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "activitypub_federation", "actix-web", @@ -2821,7 +2821,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "anyhow", "clap", @@ -2836,7 +2836,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "activitypub_federation", "anyhow", @@ -2877,7 +2877,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "actix-web", "chrono", @@ -2899,7 +2899,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "chrono", "diesel", @@ -2920,7 +2920,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "diesel", "diesel-async", @@ -2932,7 +2932,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "activitypub_federation", "anyhow", @@ -2957,7 +2957,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "activitypub_federation", "actix-web", @@ -2982,7 +2982,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "activitypub_federation", "actix-cors", @@ -3025,7 +3025,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 1c77b9836..b7acadc07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.9" +version = "0.19.4-rc.10" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.9", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.9", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.9", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.9", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.9", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.9", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.9", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.9", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.9", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.9", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.9", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.10", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.10", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.10", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.10", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.10", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.10", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.10", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.10", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.10", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.10", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.10", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } From 5d31f0d51667b77743f16bbbe6e56e542dd5d6a4 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 6 Jun 2024 23:02:38 -0400 Subject: [PATCH 31/74] Version 0.19.4-rc.11 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57a366519..75fcdd4b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2693,7 +2693,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "activitypub_federation", "actix-web", @@ -2722,7 +2722,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "activitypub_federation", "actix-web", @@ -2760,7 +2760,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "accept-language", "activitypub_federation", @@ -2783,7 +2783,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "activitypub_federation", "actix-web", @@ -2821,7 +2821,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "anyhow", "clap", @@ -2836,7 +2836,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "activitypub_federation", "anyhow", @@ -2877,7 +2877,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "actix-web", "chrono", @@ -2899,7 +2899,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "chrono", "diesel", @@ -2920,7 +2920,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "diesel", "diesel-async", @@ -2932,7 +2932,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "activitypub_federation", "anyhow", @@ -2957,7 +2957,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "activitypub_federation", "actix-web", @@ -2982,7 +2982,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "activitypub_federation", "actix-cors", @@ -3025,7 +3025,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index b7acadc07..6deb495c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.10" +version = "0.19.4-rc.11" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.10", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.10", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.10", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.10", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.10", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.10", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.10", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.10", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.10", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.10", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.10", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4-rc.11", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4-rc.11", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4-rc.11", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4-rc.11", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4-rc.11", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4-rc.11", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4-rc.11", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4-rc.11", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4-rc.11", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4-rc.11", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4-rc.11", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } From 1e11faf741174f98b4a6358f42f83a8e629aae42 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Fri, 7 Jun 2024 04:42:34 -0700 Subject: [PATCH 32/74] Improve comment in triggers.sql (#4789) * Clarified existing info * Added prohibition of inconsistent update order --- .../db_schema/replaceable_schema/triggers.sql | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/db_schema/replaceable_schema/triggers.sql b/crates/db_schema/replaceable_schema/triggers.sql index fa5b01018..98af3e546 100644 --- a/crates/db_schema/replaceable_schema/triggers.sql +++ b/crates/db_schema/replaceable_schema/triggers.sql @@ -5,12 +5,17 @@ -- (even if only other columns are updated) because triggers can run after the deletion of referenced rows and -- before the automatic deletion of the row that references it. This is not a problem for insert or delete. -- --- After a row update begins, a concurrent update on the same row can't begin until the whole --- transaction that contains the first update is finished. To reduce this locking, statements in --- triggers should be ordered based on the likelihood of concurrent writers. For example, updating --- site_aggregates should be done last because the same row is updated for all local stuff. If --- it were not last, then the locking period for concurrent writers would extend to include the --- time consumed by statements that come after. +-- Triggers that update multiple tables should use this order: person_aggregates, comment_aggregates, +-- post_aggregates, community_aggregates, site_aggregates +-- * The order matters because the updated rows are locked until the end of the transaction, and statements +-- in a trigger don't use separate transactions. This means that updates closer to the beginning cause +-- longer locks because the duration of each update extends the durations of the locks caused by previous +-- updates. Long locks are worse on rows that have more concurrent transactions trying to update them. The +-- listed order starts with tables that are less likely to have such rows. +-- https://www.postgresql.org/docs/16/transaction-iso.html#XACT-READ-COMMITTED +-- * Using the same order in every trigger matters because a deadlock is possible if multiple transactions +-- update the same rows in a different order. +-- https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-DEADLOCKS -- -- -- Create triggers for both post and comments From f5f2b5ffc6185302851e245c35c87ff19b0b13e9 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 7 Jun 2024 07:51:56 -0400 Subject: [PATCH 33/74] Version 0.19.4 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ docker/docker-compose.yml | 4 ++-- docker/federation/docker-compose.yml | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75fcdd4b1..85760aec4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2693,7 +2693,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lemmy_api" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2722,7 +2722,7 @@ dependencies = [ [[package]] name = "lemmy_api_common" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2760,7 +2760,7 @@ dependencies = [ [[package]] name = "lemmy_api_crud" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "accept-language", "activitypub_federation", @@ -2783,7 +2783,7 @@ dependencies = [ [[package]] name = "lemmy_apub" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2821,7 +2821,7 @@ dependencies = [ [[package]] name = "lemmy_db_perf" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "anyhow", "clap", @@ -2836,7 +2836,7 @@ dependencies = [ [[package]] name = "lemmy_db_schema" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "activitypub_federation", "anyhow", @@ -2877,7 +2877,7 @@ dependencies = [ [[package]] name = "lemmy_db_views" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "actix-web", "chrono", @@ -2899,7 +2899,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_actor" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "chrono", "diesel", @@ -2920,7 +2920,7 @@ dependencies = [ [[package]] name = "lemmy_db_views_moderator" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "diesel", "diesel-async", @@ -2932,7 +2932,7 @@ dependencies = [ [[package]] name = "lemmy_federate" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "activitypub_federation", "anyhow", @@ -2957,7 +2957,7 @@ dependencies = [ [[package]] name = "lemmy_routes" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "activitypub_federation", "actix-web", @@ -2982,7 +2982,7 @@ dependencies = [ [[package]] name = "lemmy_server" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "activitypub_federation", "actix-cors", @@ -3025,7 +3025,7 @@ dependencies = [ [[package]] name = "lemmy_utils" -version = "0.19.4-rc.11" +version = "0.19.4" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 6deb495c2..f80d147db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.19.4-rc.11" +version = "0.19.4" edition = "2021" description = "A link aggregator for the fediverse" license = "AGPL-3.0" @@ -88,17 +88,17 @@ unused_self = "deny" unwrap_used = "deny" [workspace.dependencies] -lemmy_api = { version = "=0.19.4-rc.11", path = "./crates/api" } -lemmy_api_crud = { version = "=0.19.4-rc.11", path = "./crates/api_crud" } -lemmy_apub = { version = "=0.19.4-rc.11", path = "./crates/apub" } -lemmy_utils = { version = "=0.19.4-rc.11", path = "./crates/utils", default-features = false } -lemmy_db_schema = { version = "=0.19.4-rc.11", path = "./crates/db_schema" } -lemmy_api_common = { version = "=0.19.4-rc.11", path = "./crates/api_common" } -lemmy_routes = { version = "=0.19.4-rc.11", path = "./crates/routes" } -lemmy_db_views = { version = "=0.19.4-rc.11", path = "./crates/db_views" } -lemmy_db_views_actor = { version = "=0.19.4-rc.11", path = "./crates/db_views_actor" } -lemmy_db_views_moderator = { version = "=0.19.4-rc.11", path = "./crates/db_views_moderator" } -lemmy_federate = { version = "=0.19.4-rc.11", path = "./crates/federate" } +lemmy_api = { version = "=0.19.4", path = "./crates/api" } +lemmy_api_crud = { version = "=0.19.4", path = "./crates/api_crud" } +lemmy_apub = { version = "=0.19.4", path = "./crates/apub" } +lemmy_utils = { version = "=0.19.4", path = "./crates/utils", default-features = false } +lemmy_db_schema = { version = "=0.19.4", path = "./crates/db_schema" } +lemmy_api_common = { version = "=0.19.4", path = "./crates/api_common" } +lemmy_routes = { version = "=0.19.4", path = "./crates/routes" } +lemmy_db_views = { version = "=0.19.4", path = "./crates/db_views" } +lemmy_db_views_actor = { version = "=0.19.4", path = "./crates/db_views_actor" } +lemmy_db_views_moderator = { version = "=0.19.4", path = "./crates/db_views_moderator" } +lemmy_federate = { version = "=0.19.4", path = "./crates/federate" } activitypub_federation = { version = "0.5.6", default-features = false, features = [ "actix-web", ] } diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 2a04debdd..3d965e911 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -23,7 +23,7 @@ services: lemmy: # use "image" to pull down an already compiled lemmy. make sure to comment out "build". - # image: dessalines/lemmy:0.19.3 + # image: dessalines/lemmy:0.19.4 # platform: linux/x86_64 # no arm64 support. uncomment platform if using m1. # use "build" to build your local lemmy server image for development. make sure to comment out "image". # run: docker compose up --build @@ -53,7 +53,7 @@ services: lemmy-ui: # use "image" to pull down an already compiled lemmy-ui. make sure to comment out "build". - image: dessalines/lemmy-ui:0.19.4-rc.3 + image: dessalines/lemmy-ui:0.19.4 # platform: linux/x86_64 # no arm64 support. uncomment platform if using m1. # use "build" to build your local lemmy ui image for development. make sure to comment out "image". # run: docker compose up --build diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index ec131a2b8..fe243aa52 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.7" x-ui-default: &ui-default init: true - image: dessalines/lemmy-ui:0.19.3 + image: dessalines/lemmy-ui:0.19.4 # assuming lemmy-ui is cloned besides lemmy directory # build: # context: ../../../lemmy-ui From b559e0206bff4937d037a6d41a96ffbe069f8739 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Fri, 7 Jun 2024 07:27:49 -0700 Subject: [PATCH 34/74] Replace wav with hound (#4788) * Update lib.rs * Update Cargo.toml * Update lib.rs * cargo.lock * fix simultaneous mutable references --- Cargo.lock | 17 +---------------- crates/api/Cargo.toml | 2 +- crates/api/src/lib.rs | 35 ++++++++++++++++++++--------------- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85760aec4..a933cc603 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2704,6 +2704,7 @@ dependencies = [ "captcha", "chrono", "elementtree", + "hound", "lemmy_api_common", "lemmy_db_schema", "lemmy_db_views", @@ -2717,7 +2718,6 @@ dependencies = [ "totp-rs", "tracing", "url", - "wav", ] [[package]] @@ -4708,12 +4708,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "riff" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b1a3d5f46d53f4a3478e2be4a5a5ce5108ea58b100dcd139830eae7f79a3a1" - [[package]] name = "ring" version = "0.17.8" @@ -6442,15 +6436,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wav" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d97402f69875b579ec37f2aa52d1f455a1d6224251edba32e8c18a5da2698d" -dependencies = [ - "riff", -] - [[package]] name = "web-sys" version = "0.3.69" diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index 846583c37..b98b15d62 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -33,7 +33,7 @@ anyhow = { workspace = true } tracing = { workspace = true } chrono = { workspace = true } url = { workspace = true } -wav = "1.0.1" +hound = "3.5.1" 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 c20e4ff9c..2b8e12d37 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -44,33 +44,38 @@ pub mod site; pub mod sitemap; /// Converts the captcha to a base64 encoded wav audio file -#[allow(deprecated)] pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> LemmyResult { let letters = captcha.as_wav(); // Decode each wav file, concatenate the samples let mut concat_samples: Vec = Vec::new(); - let mut any_header: Option = None; + let mut any_header: Option = None; for letter in letters { let mut cursor = Cursor::new(letter.unwrap_or_default()); - let (header, samples) = wav::read(&mut cursor)?; - any_header = Some(header); - if let Some(samples16) = samples.as_sixteen() { - concat_samples.extend(samples16); - } else { - Err(LemmyErrorType::CouldntCreateAudioCaptcha)? - } + let reader = hound::WavReader::new(&mut cursor)?; + any_header = Some(reader.spec()); + let samples16 = reader + .into_samples::() + .collect::, _>>() + .with_lemmy_type(LemmyErrorType::CouldntCreateAudioCaptcha)?; + concat_samples.extend(samples16); } // Encode the concatenated result as a wav file let mut output_buffer = Cursor::new(vec![]); if let Some(header) = any_header { - wav::write( - header, - &wav::BitDepth::Sixteen(concat_samples), - &mut output_buffer, - ) - .with_lemmy_type(LemmyErrorType::CouldntCreateAudioCaptcha)?; + let mut writer = hound::WavWriter::new(&mut output_buffer, header) + .with_lemmy_type(LemmyErrorType::CouldntCreateAudioCaptcha)?; + let mut writer16 = writer.get_i16_writer(concat_samples.len() as u32); + for sample in concat_samples { + writer16.write_sample(sample); + } + writer16 + .flush() + .with_lemmy_type(LemmyErrorType::CouldntCreateAudioCaptcha)?; + writer + .finalize() + .with_lemmy_type(LemmyErrorType::CouldntCreateAudioCaptcha)?; Ok(base64.encode(output_buffer.into_inner())) } else { From 9236cf7d21ba968294efb4a0075ed183556724da Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 7 Jun 2024 11:26:43 -0400 Subject: [PATCH 35/74] Remove ansible tagging lines. (#4790) --- scripts/release.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 74f3c0b95..1cf7b168a 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -10,7 +10,7 @@ third_semver=$(echo $new_tag | cut -d "." -f 3) CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" cd $CWD/../ -# The ansible and docker installs should only update for non release-candidates +# The docker installs should only update for non release-candidates # IE, when the third semver is a number, not '2-rc' if [ ! -z "${third_semver##*[!0-9]*}" ]; then pushd docker @@ -20,14 +20,6 @@ if [ ! -z "${third_semver##*[!0-9]*}" ]; then git add docker-compose.yml git add federation/docker-compose.yml popd - - # Setting the version for Ansible - pushd ../lemmy-ansible - echo $new_tag > "VERSION" - git add "VERSION" - git commit -m"Updating VERSION" - git push - popd fi # Update crate versions From b2a480f55ce7fd327d46b81f43697069c9befdbd Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 7 Jun 2024 12:39:23 -0400 Subject: [PATCH 36/74] Fixing sed command for postgres upgrade. (#4791) - Context: https://github.com/LemmyNet/lemmy-ansible/issues/245 --- scripts/postgres_15_to_16_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/postgres_15_to_16_upgrade.sh b/scripts/postgres_15_to_16_upgrade.sh index f2ac0d5d6..d83803a4f 100755 --- a/scripts/postgres_15_to_16_upgrade.sh +++ b/scripts/postgres_15_to_16_upgrade.sh @@ -24,7 +24,7 @@ echo "Removing the old postgres folder" sudo rm -rf volumes/postgres echo "Updating docker compose to use postgres version 16." -sudo sed -i "s/image: .*postgres:.*/image: docker.io/postgres:16-alpine/" ./docker-compose.yml +sudo sed -i "s/image: .*postgres:.*/image: docker.io\/postgres:16-alpine/" ./docker-compose.yml echo "Starting up new postgres..." sudo docker compose up -d postgres From 046375171ef6048d9ac9365bcaf10d1de179217b Mon Sep 17 00:00:00 2001 From: dullbananas Date: Wed, 12 Jun 2024 17:35:27 -0700 Subject: [PATCH 37/74] Don't change encoding style in `clean_url_params` (#4802) * Don't change encoding style in `clean_url_params` Fixes #4801 * fmt * fix --- crates/utils/src/utils/validation.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/utils/src/utils/validation.rs b/crates/utils/src/utils/validation.rs index c07a129b4..8891411a5 100644 --- a/crates/utils/src/utils/validation.rs +++ b/crates/utils/src/utils/validation.rs @@ -11,8 +11,10 @@ static VALID_MATRIX_ID_REGEX: Lazy = Lazy::new(|| { }); // taken from https://en.wikipedia.org/wiki/UTM_parameters static CLEAN_URL_PARAMS_REGEX: Lazy = Lazy::new(|| { - Regex::new(r"^utm_source|utm_medium|utm_campaign|utm_term|utm_content|gclid|gclsrc|dclid|fbclid$") - .expect("compile regex") + Regex::new( + r"^(utm_source|utm_medium|utm_campaign|utm_term|utm_content|gclid|gclsrc|dclid|fbclid)=", + ) + .expect("compile regex") }); const ALLOWED_POST_URL_SCHEMES: [&str; 3] = ["http", "https", "magnet"]; @@ -256,12 +258,11 @@ pub fn build_and_check_regex(regex_str_opt: &Option<&str>) -> LemmyResult