Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of Option<Vec<_>> in api structs (fixes #2820) #5463

Merged
merged 5 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1",
"prettier": "^3.5.0",
"ts-jest": "^29.1.0",
"tsoa": "^6.6.0",
Expand Down
10 changes: 5 additions & 5 deletions api_tests/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/api/src/site/leave_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions crates/api_common/src/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,8 @@ pub struct GetSiteResponse {
#[cfg_attr(feature = "full", ts(optional))]
pub tagline: Option<Tagline>,
/// A list of external auth methods your site supports.
#[cfg_attr(feature = "full", ts(optional))]
pub oauth_providers: Option<Vec<PublicOAuthProvider>>,
#[cfg_attr(feature = "full", ts(optional))]
pub admin_oauth_providers: Option<Vec<OAuthProvider>>,
pub oauth_providers: Vec<PublicOAuthProvider>,
pub admin_oauth_providers: Vec<OAuthProvider>,
pub blocked_urls: Vec<LocalSiteUrlBlocklist>,
// If true then uploads for post images or markdown images are disabled. Only avatars, icons and
// banners can be set.
Expand Down
6 changes: 3 additions & 3 deletions crates/api_crud/src/site/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -64,8 +64,8 @@ async fn read_site(context: &LemmyContext) -> LemmyResult<GetSiteResponse> {
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,
})
}