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

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

* update js client

* only responses
This commit is contained in:
Nutomic 2025-02-28 15:07:07 +00:00 committed by GitHub
parent 253230a5cb
commit 359942272a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 15 deletions

View file

@ -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",

View file

@ -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.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-show-mod-reports.2:
resolution: {integrity: sha512-92Zgs5/Nf8h57U5kgL0Q9BZzoTG0JUTGSGg1e9DORzQFVfYv53dzKpdjNxvuHsxlmT4eOeZgCuyUGdRipYy6jw==}
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-show-mod-reports.2: {}
lemmy-js-client@0.20.0-api-no-optional-vec.1: {}
leven@3.1.0: {}

View file

@ -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,

View file

@ -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.

View file

@ -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<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,
})
}