From 9ceb5b6386d5c5294f9b2bfd4bfd7c3daaead328 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 4 Jun 2024 05:04:16 -0700 Subject: [PATCH 01/57] 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 02/57] 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 03/57] 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 04/57] 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 05/57] 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 06/57] 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 07/57] 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 08/57] 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 09/57] 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 10/57] 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 11/57] 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 12/57] 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 13/57] 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 14/57] 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 15/57] 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 16/57] 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 17/57] 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 18/57] 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 19/57] 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 20/57] 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