Make API response compatible with what IceCubes iOS client expects
This commit is contained in:
parent
60a27b5b11
commit
bb28bf800d
1 changed files with 35 additions and 1 deletions
|
@ -26,10 +26,30 @@ struct InstanceMediaLimits {
|
||||||
image_size_limit: usize,
|
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)]
|
#[derive(Serialize)]
|
||||||
struct InstanceConfiguration {
|
struct InstanceConfiguration {
|
||||||
statuses: InstanceStatusLimits,
|
statuses: InstanceStatusLimits,
|
||||||
media_attachments: InstanceMediaLimits,
|
media_attachments: InstanceMediaLimits,
|
||||||
|
polls: PollsLimits,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Default)]
|
||||||
|
struct Urls {
|
||||||
|
streaming_api: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct Rule {
|
||||||
|
id: String,
|
||||||
|
text: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://docs.joinmastodon.org/entities/V1_Instance/
|
/// https://docs.joinmastodon.org/entities/V1_Instance/
|
||||||
|
@ -46,6 +66,11 @@ pub struct InstanceInfo {
|
||||||
invites_enabled: bool,
|
invites_enabled: bool,
|
||||||
stats: InstanceStats,
|
stats: InstanceStats,
|
||||||
configuration: InstanceConfiguration,
|
configuration: InstanceConfiguration,
|
||||||
|
thumbnail: Option<String>,
|
||||||
|
email: String,
|
||||||
|
languages: Vec<String>,
|
||||||
|
rules: Vec<Rule>,
|
||||||
|
urls: Option<Urls>,
|
||||||
|
|
||||||
login_message: String,
|
login_message: String,
|
||||||
post_character_limit: usize, // deprecated
|
post_character_limit: usize, // deprecated
|
||||||
|
@ -53,7 +78,10 @@ pub struct InstanceInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_full_api_version(version: &str) -> String {
|
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 {
|
impl InstanceInfo {
|
||||||
|
@ -85,7 +113,13 @@ impl InstanceInfo {
|
||||||
.collect(),
|
.collect(),
|
||||||
image_size_limit: config.limits.media.file_size_limit,
|
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(),
|
login_message: config.login_message.clone(),
|
||||||
post_character_limit: config.limits.posts.character_limit,
|
post_character_limit: config.limits.posts.character_limit,
|
||||||
ipfs_gateway_url: config.ipfs_gateway_url.clone(),
|
ipfs_gateway_url: config.ipfs_gateway_url.clone(),
|
||||||
|
|
Loading…
Reference in a new issue