2023-11-27 18:54:31 -08:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
2023-05-23 23:55:21 +08:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
2024-01-11 14:42:03 +08:00
|
|
|
use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
|
|
|
|
use flowy_server_pub::AuthenticatorType;
|
2023-07-05 20:57:09 +08:00
|
|
|
|
2023-05-23 23:55:21 +08:00
|
|
|
#[derive(Deserialize, Debug)]
|
2023-11-20 20:54:47 +08:00
|
|
|
pub struct AppFlowyDartConfiguration {
|
2023-11-27 18:54:31 -08:00
|
|
|
/// The root path of the application
|
|
|
|
pub root: String,
|
2024-01-30 09:33:34 +08:00
|
|
|
pub app_version: String,
|
2023-11-20 20:54:47 +08:00
|
|
|
/// This path will be used to store the user data
|
|
|
|
pub custom_app_path: String,
|
|
|
|
pub origin_app_path: String,
|
|
|
|
pub device_id: String,
|
2024-04-07 21:36:55 +08:00
|
|
|
pub platform: String,
|
2023-11-27 18:54:31 -08:00
|
|
|
pub authenticator_type: AuthenticatorType,
|
2023-11-20 20:54:47 +08:00
|
|
|
pub(crate) appflowy_cloud_config: AFCloudConfiguration,
|
2023-11-27 18:54:31 -08:00
|
|
|
#[serde(default)]
|
|
|
|
pub(crate) envs: HashMap<String, String>,
|
2023-05-23 23:55:21 +08:00
|
|
|
}
|
|
|
|
|
2023-11-20 20:54:47 +08:00
|
|
|
impl AppFlowyDartConfiguration {
|
|
|
|
pub fn from_str(s: &str) -> Self {
|
|
|
|
serde_json::from_str::<AppFlowyDartConfiguration>(s).unwrap()
|
2023-11-17 15:38:56 +08:00
|
|
|
}
|
|
|
|
|
2023-11-27 18:54:31 -08:00
|
|
|
pub fn write_env(&self) {
|
|
|
|
self.authenticator_type.write_env();
|
2024-01-12 06:26:43 +08:00
|
|
|
self.appflowy_cloud_config.write_env();
|
2023-11-27 18:54:31 -08:00
|
|
|
|
|
|
|
for (k, v) in self.envs.iter() {
|
|
|
|
std::env::set_var(k, v);
|
|
|
|
}
|
2023-05-23 23:55:21 +08:00
|
|
|
}
|
|
|
|
}
|