Use Pleroma-compliant instance version in /api/v1/instance
https://codeberg.org/silverpill/mitra/issues/4
This commit is contained in:
parent
d9f0095787
commit
9591be4df0
5 changed files with 16 additions and 4 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1686,7 +1686,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mitra"
|
||||
version = "0.2.0"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-files",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mitra"
|
||||
version = "0.2.0"
|
||||
version = "0.4.0"
|
||||
description = "Mitra backend"
|
||||
license = "AGPL-3.0"
|
||||
|
||||
|
|
|
@ -571,8 +571,9 @@ components:
|
|||
description: Admin-defined description of the site.
|
||||
type: string
|
||||
version:
|
||||
description: The version of Mitra server.
|
||||
description: Mastodon API compatibility version and the version of Mitra server.
|
||||
type: string
|
||||
example: '3.0.0 (compatible; Mitra 0.4.0)'
|
||||
registrations:
|
||||
description: Whether registrations are enabled.
|
||||
type: boolean
|
||||
|
|
|
@ -2,6 +2,7 @@ use serde::Serialize;
|
|||
|
||||
use crate::config::Config;
|
||||
use crate::ethereum::contracts::ADAPTER;
|
||||
use crate::mastodon_api::MASTODON_API_VERSION;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct InstanceInfo {
|
||||
|
@ -19,6 +20,14 @@ pub struct InstanceInfo {
|
|||
ipfs_gateway_url: Option<String>,
|
||||
}
|
||||
|
||||
fn get_full_api_version(version: &str) -> String {
|
||||
format!(
|
||||
"{0} (compatible; Mitra {1})",
|
||||
MASTODON_API_VERSION,
|
||||
version,
|
||||
)
|
||||
}
|
||||
|
||||
impl From<&Config> for InstanceInfo {
|
||||
fn from(config: &Config) -> Self {
|
||||
Self {
|
||||
|
@ -26,7 +35,7 @@ impl From<&Config> for InstanceInfo {
|
|||
title: config.instance_title.clone(),
|
||||
short_description: config.instance_short_description.clone(),
|
||||
description: config.instance_description.clone(),
|
||||
version: config.version.clone(),
|
||||
version: get_full_api_version(&config.version),
|
||||
registrations: config.registrations_open,
|
||||
login_message: config.login_message.clone(),
|
||||
blockchain_explorer_url: config.blockchain.as_ref()
|
||||
|
|
|
@ -8,3 +8,5 @@ pub mod oauth;
|
|||
pub mod search;
|
||||
pub mod statuses;
|
||||
pub mod timelines;
|
||||
|
||||
pub const MASTODON_API_VERSION: &str = "3.0.0";
|
||||
|
|
Loading…
Reference in a new issue