From bb28bf800d7b7ebf806d3c1a44a6f58438d6cdab Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Wed, 26 Apr 2023 22:10:34 +0200 Subject: [PATCH] Make API response compatible with what IceCubes iOS client expects --- src/mastodon_api/instance/types.rs | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/mastodon_api/instance/types.rs b/src/mastodon_api/instance/types.rs index f84d3e6..b96ba71 100644 --- a/src/mastodon_api/instance/types.rs +++ b/src/mastodon_api/instance/types.rs @@ -26,10 +26,30 @@ struct InstanceMediaLimits { image_size_limit: usize, } +#[derive(Serialize, Default)] +struct PollsLimits { + max_options: usize, + max_option_characters_per_option: usize, + min_expiration: usize, + max_expiration: usize, +} + #[derive(Serialize)] struct InstanceConfiguration { statuses: InstanceStatusLimits, media_attachments: InstanceMediaLimits, + polls: PollsLimits, +} + +#[derive(Serialize, Default)] +struct Urls { + streaming_api: Option, +} + +#[derive(Serialize)] +struct Rule { + id: String, + text: String, } /// https://docs.joinmastodon.org/entities/V1_Instance/ @@ -46,6 +66,11 @@ pub struct InstanceInfo { invites_enabled: bool, stats: InstanceStats, configuration: InstanceConfiguration, + thumbnail: Option, + email: String, + languages: Vec, + rules: Vec, + urls: Option, login_message: String, post_character_limit: usize, // deprecated @@ -53,7 +78,10 @@ pub struct InstanceInfo { } fn get_full_api_version(version: &str) -> String { - format!("{0} (compatible; Reef {1})", MASTODON_API_VERSION, version,) + format!( + "{0} (compatible; FediMovies {1})", + MASTODON_API_VERSION, version, + ) } impl InstanceInfo { @@ -85,7 +113,13 @@ impl InstanceInfo { .collect(), image_size_limit: config.limits.media.file_size_limit, }, + polls: Default::default(), }, + thumbnail: None, + email: "".to_string(), + languages: vec![], + rules: vec![], + urls: None, login_message: config.login_message.clone(), post_character_limit: config.limits.posts.character_limit, ipfs_gateway_url: config.ipfs_gateway_url.clone(),