1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/// Data about a revolt instance obtained by
/// making a `GET /` on the api.
#[derive(serde::Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct RevoltConfiguration {
    pub revolt: String,
    pub features: RevoltInstanceFeatures,
    pub ws: String,
    pub app: String,
    pub vapid: String,
}

/// Data about Autumn (file server microservice).
#[derive(serde::Deserialize, Clone)]
#[serde(transparent)]
#[serde(deny_unknown_fields)]
pub struct Autumn(EnabledUrl);

impl Autumn {
    /// Is Autumn enabled?
    pub fn is_enabled(&self) -> bool {
        self.0.enabled
    }

    /// Get the url
    pub fn url(&self) -> &String {
        &self.0.url
    }
}

/// Data about January (image proxy and embed generator).
#[derive(serde::Deserialize, Clone)]
#[serde(transparent)]
#[serde(deny_unknown_fields)]
pub struct January(EnabledUrl);

impl January {
    /// Is January enabled?
    pub fn is_enabled(&self) -> bool {
        self.0.enabled
    }

    /// Get the url
    pub fn url(&self) -> &String {
        &self.0.url
    }
}

/// Data about Voso (legacy voice server).
#[derive(serde::Deserialize, Clone)]
#[serde(transparent)]
#[serde(deny_unknown_fields)]
pub struct Voso(EnabledUrlWs);

impl Voso {
    /// Is voso enabled?
    pub fn is_enabled(&self) -> bool {
        self.0.enabled
    }

    /// Get the url
    pub fn url(&self) -> &String {
        &self.0.url
    }

    /// Get the ws url.
    pub fn ws_url(&self) -> &String {
        &self.0.ws
    }
}

#[derive(serde::Deserialize, Clone)]
#[serde(deny_unknown_fields)]
struct EnabledUrl {
    enabled: bool,
    url: String,
}

#[derive(serde::Deserialize, Clone)]
#[serde(deny_unknown_fields)]
struct EnabledUrlWs {
    enabled: bool,
    url: String,
    ws: String,
}

/// Features

#[derive(serde::Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct RevoltInstanceFeatures {
    // pub registration: bool,
    pub captcha: CaptchaInfo,
    /// Uses email verification?
    pub email: bool,
    /// Is invite only?
    pub invite_only: bool,
    /// Autumn (file server microservice).
    pub autumn: Autumn,
    /// January (image proxy and embed generator)
    pub january: January,
    /// Voso (legacy voice server).
    pub voso: Voso,
}

/// Captcha feature
#[derive(serde::Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct CaptchaInfo {
    /// Whether it is enabled or not
    pub enabled: bool,
    /// The captcha key
    pub key: String,
}