From 5d793e42108a6f8d8ed7428419156d43da2d2484 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 28 Feb 2025 11:24:08 +0100 Subject: [PATCH 1/5] Get rid of `Option>` in api structs (fixes #2820) --- crates/api/src/local_user/save_settings.rs | 5 ++--- crates/api/src/site/leave_admin.rs | 4 ++-- crates/api_common/src/community.rs | 6 ++---- crates/api_common/src/person.rs | 3 +-- crates/api_common/src/post.rs | 6 ++---- crates/api_common/src/site.rs | 15 +++++---------- crates/api_crud/src/community/create.rs | 17 ++++++++--------- crates/api_crud/src/community/update.rs | 17 ++++++++--------- crates/api_crud/src/site/read.rs | 6 +++--- crates/api_crud/src/site/update.rs | 16 +++++++--------- 10 files changed, 40 insertions(+), 55 deletions(-) diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index 33fd011add..2a5320de5e 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -105,9 +105,8 @@ pub async fn save_user_settings( .await .ok(); - if let Some(discussion_languages) = data.discussion_languages.clone() { - LocalUserLanguage::update(&mut context.pool(), discussion_languages, local_user_id).await?; - } + let discussion_languages = data.discussion_languages.clone(); + LocalUserLanguage::update(&mut context.pool(), discussion_languages, local_user_id).await?; let local_user_form = LocalUserUpdateForm { email, diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index 40742a8191..bb306aeb91 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -69,8 +69,8 @@ pub async fn leave_admin( version: VERSION.to_string(), all_languages, discussion_languages, - oauth_providers: Some(oauth_providers), - admin_oauth_providers: None, + oauth_providers, + admin_oauth_providers: vec![], blocked_urls, tagline, my_user: None, diff --git a/crates/api_common/src/community.rs b/crates/api_common/src/community.rs index 3bd6c9b1a6..70cd6f204a 100644 --- a/crates/api_common/src/community.rs +++ b/crates/api_common/src/community.rs @@ -71,8 +71,7 @@ pub struct CreateCommunity { /// Whether to restrict posting only to moderators. #[cfg_attr(feature = "full", ts(optional))] pub posting_restricted_to_mods: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub discussion_languages: Option>, + pub discussion_languages: Vec, #[cfg_attr(feature = "full", ts(optional))] pub visibility: Option, } @@ -187,8 +186,7 @@ pub struct EditCommunity { /// Whether to restrict posting only to moderators. #[cfg_attr(feature = "full", ts(optional))] pub posting_restricted_to_mods: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub discussion_languages: Option>, + pub discussion_languages: Vec, #[cfg_attr(feature = "full", ts(optional))] pub visibility: Option, } diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 895de1de97..678977564f 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -157,8 +157,7 @@ pub struct SaveUserSettings { #[cfg_attr(feature = "full", ts(optional))] pub show_read_posts: Option, /// A list of languages you are able to see discussion in. - #[cfg_attr(feature = "full", ts(optional))] - pub discussion_languages: Option>, + pub discussion_languages: Vec, /// Open links in a new tab #[cfg_attr(feature = "full", ts(optional))] pub open_links_in_new_tab: Option, diff --git a/crates/api_common/src/post.rs b/crates/api_common/src/post.rs index c9fc33be10..db3cfa172c 100644 --- a/crates/api_common/src/post.rs +++ b/crates/api_common/src/post.rs @@ -36,8 +36,7 @@ pub struct CreatePost { /// Instead of fetching a thumbnail, use a custom one. #[cfg_attr(feature = "full", ts(optional))] pub custom_thumbnail: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub tags: Option>, + pub tags: Vec, /// Time when this post should be scheduled. Null means publish immediately. #[cfg_attr(feature = "full", ts(optional))] pub scheduled_publish_time: Option, @@ -176,8 +175,7 @@ pub struct EditPost { /// Instead of fetching a thumbnail, use a custom one. #[cfg_attr(feature = "full", ts(optional))] pub custom_thumbnail: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub tags: Option>, + pub tags: Vec, /// Time when this post should be scheduled. Null means publish immediately. #[cfg_attr(feature = "full", ts(optional))] pub scheduled_publish_time: Option, diff --git a/crates/api_common/src/site.rs b/crates/api_common/src/site.rs index c0b75e21fb..ef4d1dd68f 100644 --- a/crates/api_common/src/site.rs +++ b/crates/api_common/src/site.rs @@ -202,8 +202,7 @@ pub struct CreateSite { pub application_email_admins: Option, #[cfg_attr(feature = "full", ts(optional))] pub hide_modlog_mod_names: Option, - #[cfg_attr(feature = "full", ts(optional))] - pub discussion_languages: Option>, + pub discussion_languages: Vec, #[cfg_attr(feature = "full", ts(optional))] pub slur_filter_regex: Option, #[cfg_attr(feature = "full", ts(optional))] @@ -310,8 +309,7 @@ pub struct EditSite { #[cfg_attr(feature = "full", ts(optional))] pub hide_modlog_mod_names: Option, /// A list of allowed discussion languages. - #[cfg_attr(feature = "full", ts(optional))] - pub discussion_languages: Option>, + pub discussion_languages: Vec, /// A regex string of items to filter. #[cfg_attr(feature = "full", ts(optional))] pub slur_filter_regex: Option, @@ -358,8 +356,7 @@ pub struct EditSite { #[cfg_attr(feature = "full", ts(optional))] pub captcha_difficulty: Option, /// A list of blocked URLs - #[cfg_attr(feature = "full", ts(optional))] - pub blocked_urls: Option>, + pub blocked_urls: Vec, #[cfg_attr(feature = "full", ts(optional))] pub registration_mode: Option, /// Whether to email admins for new reports. @@ -417,10 +414,8 @@ pub struct GetSiteResponse { #[cfg_attr(feature = "full", ts(optional))] pub tagline: Option, /// A list of external auth methods your site supports. - #[cfg_attr(feature = "full", ts(optional))] - pub oauth_providers: Option>, - #[cfg_attr(feature = "full", ts(optional))] - pub admin_oauth_providers: Option>, + pub oauth_providers: Vec, + pub admin_oauth_providers: Vec, pub blocked_urls: Vec, // If true then uploads for post images or markdown images are disabled. Only avatars, icons and // banners can be set. diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index de218fe2d6..0c1f11cd77 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -135,16 +135,15 @@ pub async fn create_community( // Update the discussion_languages if that's provided let community_id = inserted_community.id; - if let Some(languages) = data.discussion_languages.clone() { - let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; - // check that community languages are a subset of site languages - // https://stackoverflow.com/a/64227550 - let is_subset = languages.iter().all(|item| site_languages.contains(item)); - if !is_subset { - Err(LemmyErrorType::LanguageNotAllowed)? - } - CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; + let languages = data.discussion_languages.clone(); + let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; + // check that community languages are a subset of site languages + // https://stackoverflow.com/a/64227550 + let is_subset = languages.iter().all(|item| site_languages.contains(item)); + if !is_subset { + Err(LemmyErrorType::LanguageNotAllowed)? } + CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; build_community_response(&context, local_user_view, community_id).await } diff --git a/crates/api_crud/src/community/update.rs b/crates/api_crud/src/community/update.rs index eded217dd1..22cb54df7b 100644 --- a/crates/api_crud/src/community/update.rs +++ b/crates/api_crud/src/community/update.rs @@ -57,16 +57,15 @@ pub async fn update_community( .await?; let community_id = data.community_id; - if let Some(languages) = data.discussion_languages.clone() { - let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; - // check that community languages are a subset of site languages - // https://stackoverflow.com/a/64227550 - let is_subset = languages.iter().all(|item| site_languages.contains(item)); - if !is_subset { - Err(LemmyErrorType::LanguageNotAllowed)? - } - CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; + let languages = data.discussion_languages.clone(); + let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; + // check that community languages are a subset of site languages + // https://stackoverflow.com/a/64227550 + let is_subset = languages.iter().all(|item| site_languages.contains(item)); + if !is_subset { + Err(LemmyErrorType::LanguageNotAllowed)? } + CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; let community_form = CommunityUpdateForm { title: data.title.clone(), diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index 8f3a08de13..f9b3c38692 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -39,7 +39,7 @@ pub async fn get_site_v4( .map(|l| l.local_user.admin) .unwrap_or_default() { - site_response.admin_oauth_providers = None; + site_response.admin_oauth_providers = vec![]; } Ok(Json(site_response)) @@ -64,8 +64,8 @@ async fn read_site(context: &LemmyContext) -> LemmyResult { discussion_languages, blocked_urls, tagline, - oauth_providers: Some(oauth_providers), - admin_oauth_providers: Some(admin_oauth_providers), + oauth_providers, + admin_oauth_providers, image_upload_disabled: context.settings().pictrs()?.image_upload_disabled, }) } diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index a0374baeb7..a6a36c83ee 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -57,9 +57,8 @@ pub async fn update_site( validate_update_payload(&local_site, &data)?; - if let Some(discussion_languages) = data.discussion_languages.clone() { - SiteLanguage::update(&mut context.pool(), discussion_languages.clone(), &site).await?; - } + let discussion_languages = data.discussion_languages.clone(); + SiteLanguage::update(&mut context.pool(), discussion_languages.clone(), &site).await?; let slur_regex = slur_regex(&context).await?; let url_blocklist = get_url_blocklist(&context).await?; @@ -141,12 +140,11 @@ pub async fn update_site( .await .ok(); - if let Some(url_blocklist) = data.blocked_urls.clone() { - // If this validation changes it must be synced with - // lemmy_utils::utils::markdown::create_url_blocklist_test_regex_set. - let parsed_urls = check_urls_are_valid(&url_blocklist)?; - LocalSiteUrlBlocklist::replace(&mut context.pool(), parsed_urls).await?; - } + let url_blocklist = data.blocked_urls.clone(); + // If this validation changes it must be synced with + // lemmy_utils::utils::markdown::create_url_blocklist_test_regex_set. + let parsed_urls = check_urls_are_valid(&url_blocklist)?; + LocalSiteUrlBlocklist::replace(&mut context.pool(), parsed_urls).await?; // TODO can't think of a better way to do this. // If the server suddenly requires email verification, or required applications, no old users From 91d1d224e709d32071f45d1c0d9548da25ef0b07 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 28 Feb 2025 11:55:54 +0100 Subject: [PATCH 2/5] update js client --- api_tests/package.json | 2 +- api_tests/pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api_tests/package.json b/api_tests/package.json index ea01a50463..1d02f2b3fc 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -29,7 +29,7 @@ "eslint": "^9.20.0", "eslint-plugin-prettier": "^5.2.3", "jest": "^29.5.0", - "lemmy-js-client": "0.20.0-show-mod-reports.2", + "lemmy-js-client": "0.20.0-api-no-optional-vec.0", "prettier": "^3.5.0", "ts-jest": "^29.1.0", "tsoa": "^6.6.0", diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index c59cbee647..8aad26465e 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@22.13.1) lemmy-js-client: - specifier: 0.20.0-show-mod-reports.2 - version: 0.20.0-show-mod-reports.2 + specifier: 0.20.0-api-no-optional-vec.0 + version: 0.20.0-api-no-optional-vec.0 prettier: specifier: ^3.5.0 version: 3.5.0 @@ -1528,8 +1528,8 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} - lemmy-js-client@0.20.0-show-mod-reports.2: - resolution: {integrity: sha512-92Zgs5/Nf8h57U5kgL0Q9BZzoTG0JUTGSGg1e9DORzQFVfYv53dzKpdjNxvuHsxlmT4eOeZgCuyUGdRipYy6jw==} + lemmy-js-client@0.20.0-api-no-optional-vec.0: + resolution: {integrity: sha512-ymxp+sYW/JjuW8JRFgZXjlYdr9gw4AWjAQ1RYO0SPKWL1JeWytGkG9L+tKljW7UZNqWzhKUN6nsVcU1H1BQsiQ==} leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} @@ -4169,7 +4169,7 @@ snapshots: kleur@3.0.3: {} - lemmy-js-client@0.20.0-show-mod-reports.2: {} + lemmy-js-client@0.20.0-api-no-optional-vec.0: {} leven@3.1.0: {} From e69f39ae0918c2c12422b8ab5d303ea1320cbf2c Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 28 Feb 2025 14:42:55 +0100 Subject: [PATCH 3/5] only responses --- crates/api/src/local_user/save_settings.rs | 5 +++-- crates/api_common/src/community.rs | 6 ++++-- crates/api_common/src/person.rs | 3 ++- crates/api_common/src/post.rs | 6 ++++-- crates/api_common/src/site.rs | 9 ++++++--- crates/api_crud/src/community/create.rs | 17 +++++++++-------- crates/api_crud/src/community/update.rs | 17 +++++++++-------- crates/api_crud/src/site/update.rs | 16 +++++++++------- 8 files changed, 46 insertions(+), 33 deletions(-) diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index 2a5320de5e..33fd011add 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -105,8 +105,9 @@ pub async fn save_user_settings( .await .ok(); - let discussion_languages = data.discussion_languages.clone(); - LocalUserLanguage::update(&mut context.pool(), discussion_languages, local_user_id).await?; + if let Some(discussion_languages) = data.discussion_languages.clone() { + LocalUserLanguage::update(&mut context.pool(), discussion_languages, local_user_id).await?; + } let local_user_form = LocalUserUpdateForm { email, diff --git a/crates/api_common/src/community.rs b/crates/api_common/src/community.rs index 70cd6f204a..3bd6c9b1a6 100644 --- a/crates/api_common/src/community.rs +++ b/crates/api_common/src/community.rs @@ -71,7 +71,8 @@ pub struct CreateCommunity { /// Whether to restrict posting only to moderators. #[cfg_attr(feature = "full", ts(optional))] pub posting_restricted_to_mods: Option, - pub discussion_languages: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub discussion_languages: Option>, #[cfg_attr(feature = "full", ts(optional))] pub visibility: Option, } @@ -186,7 +187,8 @@ pub struct EditCommunity { /// Whether to restrict posting only to moderators. #[cfg_attr(feature = "full", ts(optional))] pub posting_restricted_to_mods: Option, - pub discussion_languages: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub discussion_languages: Option>, #[cfg_attr(feature = "full", ts(optional))] pub visibility: Option, } diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 678977564f..895de1de97 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -157,7 +157,8 @@ pub struct SaveUserSettings { #[cfg_attr(feature = "full", ts(optional))] pub show_read_posts: Option, /// A list of languages you are able to see discussion in. - pub discussion_languages: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub discussion_languages: Option>, /// Open links in a new tab #[cfg_attr(feature = "full", ts(optional))] pub open_links_in_new_tab: Option, diff --git a/crates/api_common/src/post.rs b/crates/api_common/src/post.rs index db3cfa172c..c9fc33be10 100644 --- a/crates/api_common/src/post.rs +++ b/crates/api_common/src/post.rs @@ -36,7 +36,8 @@ pub struct CreatePost { /// Instead of fetching a thumbnail, use a custom one. #[cfg_attr(feature = "full", ts(optional))] pub custom_thumbnail: Option, - pub tags: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub tags: Option>, /// Time when this post should be scheduled. Null means publish immediately. #[cfg_attr(feature = "full", ts(optional))] pub scheduled_publish_time: Option, @@ -175,7 +176,8 @@ pub struct EditPost { /// Instead of fetching a thumbnail, use a custom one. #[cfg_attr(feature = "full", ts(optional))] pub custom_thumbnail: Option, - pub tags: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub tags: Option>, /// Time when this post should be scheduled. Null means publish immediately. #[cfg_attr(feature = "full", ts(optional))] pub scheduled_publish_time: Option, diff --git a/crates/api_common/src/site.rs b/crates/api_common/src/site.rs index ef4d1dd68f..601aed5bd6 100644 --- a/crates/api_common/src/site.rs +++ b/crates/api_common/src/site.rs @@ -202,7 +202,8 @@ pub struct CreateSite { pub application_email_admins: Option, #[cfg_attr(feature = "full", ts(optional))] pub hide_modlog_mod_names: Option, - pub discussion_languages: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub discussion_languages: Option>, #[cfg_attr(feature = "full", ts(optional))] pub slur_filter_regex: Option, #[cfg_attr(feature = "full", ts(optional))] @@ -309,7 +310,8 @@ pub struct EditSite { #[cfg_attr(feature = "full", ts(optional))] pub hide_modlog_mod_names: Option, /// A list of allowed discussion languages. - pub discussion_languages: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub discussion_languages: Option>, /// A regex string of items to filter. #[cfg_attr(feature = "full", ts(optional))] pub slur_filter_regex: Option, @@ -356,7 +358,8 @@ pub struct EditSite { #[cfg_attr(feature = "full", ts(optional))] pub captcha_difficulty: Option, /// A list of blocked URLs - pub blocked_urls: Vec, + #[cfg_attr(feature = "full", ts(optional))] + pub blocked_urls: Option>, #[cfg_attr(feature = "full", ts(optional))] pub registration_mode: Option, /// Whether to email admins for new reports. diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index 0c1f11cd77..de218fe2d6 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -135,15 +135,16 @@ pub async fn create_community( // Update the discussion_languages if that's provided let community_id = inserted_community.id; - let languages = data.discussion_languages.clone(); - let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; - // check that community languages are a subset of site languages - // https://stackoverflow.com/a/64227550 - let is_subset = languages.iter().all(|item| site_languages.contains(item)); - if !is_subset { - Err(LemmyErrorType::LanguageNotAllowed)? + if let Some(languages) = data.discussion_languages.clone() { + let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; + // check that community languages are a subset of site languages + // https://stackoverflow.com/a/64227550 + let is_subset = languages.iter().all(|item| site_languages.contains(item)); + if !is_subset { + Err(LemmyErrorType::LanguageNotAllowed)? + } + CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; } - CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; build_community_response(&context, local_user_view, community_id).await } diff --git a/crates/api_crud/src/community/update.rs b/crates/api_crud/src/community/update.rs index 22cb54df7b..eded217dd1 100644 --- a/crates/api_crud/src/community/update.rs +++ b/crates/api_crud/src/community/update.rs @@ -57,15 +57,16 @@ pub async fn update_community( .await?; let community_id = data.community_id; - let languages = data.discussion_languages.clone(); - let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; - // check that community languages are a subset of site languages - // https://stackoverflow.com/a/64227550 - let is_subset = languages.iter().all(|item| site_languages.contains(item)); - if !is_subset { - Err(LemmyErrorType::LanguageNotAllowed)? + if let Some(languages) = data.discussion_languages.clone() { + let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?; + // check that community languages are a subset of site languages + // https://stackoverflow.com/a/64227550 + let is_subset = languages.iter().all(|item| site_languages.contains(item)); + if !is_subset { + Err(LemmyErrorType::LanguageNotAllowed)? + } + CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; } - CommunityLanguage::update(&mut context.pool(), languages, community_id).await?; let community_form = CommunityUpdateForm { title: data.title.clone(), diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index a6a36c83ee..a0374baeb7 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -57,8 +57,9 @@ pub async fn update_site( validate_update_payload(&local_site, &data)?; - let discussion_languages = data.discussion_languages.clone(); - SiteLanguage::update(&mut context.pool(), discussion_languages.clone(), &site).await?; + if let Some(discussion_languages) = data.discussion_languages.clone() { + SiteLanguage::update(&mut context.pool(), discussion_languages.clone(), &site).await?; + } let slur_regex = slur_regex(&context).await?; let url_blocklist = get_url_blocklist(&context).await?; @@ -140,11 +141,12 @@ pub async fn update_site( .await .ok(); - let url_blocklist = data.blocked_urls.clone(); - // If this validation changes it must be synced with - // lemmy_utils::utils::markdown::create_url_blocklist_test_regex_set. - let parsed_urls = check_urls_are_valid(&url_blocklist)?; - LocalSiteUrlBlocklist::replace(&mut context.pool(), parsed_urls).await?; + if let Some(url_blocklist) = data.blocked_urls.clone() { + // If this validation changes it must be synced with + // lemmy_utils::utils::markdown::create_url_blocklist_test_regex_set. + let parsed_urls = check_urls_are_valid(&url_blocklist)?; + LocalSiteUrlBlocklist::replace(&mut context.pool(), parsed_urls).await?; + } // TODO can't think of a better way to do this. // If the server suddenly requires email verification, or required applications, no old users From 0cfd77264a3b6a84cabd6fa44408ac6dd8805c94 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 28 Feb 2025 14:43:38 +0100 Subject: [PATCH 4/5] client update --- api_tests/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_tests/package.json b/api_tests/package.json index 1d02f2b3fc..9dd1b3ca6d 100644 --- a/api_tests/package.json +++ b/api_tests/package.json @@ -29,7 +29,7 @@ "eslint": "^9.20.0", "eslint-plugin-prettier": "^5.2.3", "jest": "^29.5.0", - "lemmy-js-client": "0.20.0-api-no-optional-vec.0", + "lemmy-js-client": "0.20.0-api-no-optional-vec.1", "prettier": "^3.5.0", "ts-jest": "^29.1.0", "tsoa": "^6.6.0", From 7d4ed8dab5de4a412dd53ea71a949a782c31401a Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 28 Feb 2025 15:21:29 +0100 Subject: [PATCH 5/5] update lockfile --- api_tests/pnpm-lock.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api_tests/pnpm-lock.yaml b/api_tests/pnpm-lock.yaml index 8aad26465e..18028e46fd 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@22.13.1) lemmy-js-client: - specifier: 0.20.0-api-no-optional-vec.0 - version: 0.20.0-api-no-optional-vec.0 + specifier: 0.20.0-api-no-optional-vec.1 + version: 0.20.0-api-no-optional-vec.1 prettier: specifier: ^3.5.0 version: 3.5.0 @@ -1528,8 +1528,8 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} - lemmy-js-client@0.20.0-api-no-optional-vec.0: - resolution: {integrity: sha512-ymxp+sYW/JjuW8JRFgZXjlYdr9gw4AWjAQ1RYO0SPKWL1JeWytGkG9L+tKljW7UZNqWzhKUN6nsVcU1H1BQsiQ==} + lemmy-js-client@0.20.0-api-no-optional-vec.1: + resolution: {integrity: sha512-oIlTCiriuZVzTMScix4ubJyIOf3x0FPpnxCfm12EYbiix3Z9D44XMWs3JTV+ipJgmiAqgAiGhI0fF35RNu3FjQ==} leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} @@ -4169,7 +4169,7 @@ snapshots: kleur@3.0.3: {} - lemmy-js-client@0.20.0-api-no-optional-vec.0: {} + lemmy-js-client@0.20.0-api-no-optional-vec.1: {} leven@3.1.0: {}