aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/src/federation.rs18
-rw-r--r--base/src/lib.rs13
2 files changed, 21 insertions, 10 deletions
diff --git a/base/src/federation.rs b/base/src/federation.rs
index 9cd04ae..0041e26 100644
--- a/base/src/federation.rs
+++ b/base/src/federation.rs
@@ -3,10 +3,10 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
-use crate::CONF;
+use crate::SECRETS;
use anyhow::anyhow;
use jellyclient::{Instance, Session};
-use jellycommon::user::CreateSessionParams;
+use jellycommon::{config::FederationAccount, user::CreateSessionParams};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;
@@ -17,10 +17,12 @@ pub struct Federation {
impl Federation {
pub fn initialize() -> Self {
- let instances = CONF
- .remote_credentials
+ let instances = SECRETS
+ .federation
.iter()
- .map(|(k, (_, _, tls))| (k.to_owned(), Instance::new(k.to_owned(), *tls)))
+ .map(|(k, FederationAccount { tls, .. })| {
+ (k.to_owned(), Instance::new(k.to_owned(), *tls))
+ })
.collect::<HashMap<_, _>>();
Self {
@@ -40,8 +42,10 @@ impl Federation {
if let Some(s) = w.get(host) {
Ok(s.to_owned())
} else {
- let (username, password, _) = CONF
- .remote_credentials
+ let FederationAccount {
+ username, password, ..
+ } = SECRETS
+ .federation
.get(host)
.ok_or(anyhow!("no credentials of the remote server"))?;
let s = Arc::new(
diff --git a/base/src/lib.rs b/base/src/lib.rs
index a7b15c5..0001caa 100644
--- a/base/src/lib.rs
+++ b/base/src/lib.rs
@@ -10,7 +10,10 @@ pub mod federation;
pub mod permission;
pub mod temp;
-use jellycommon::{config::GlobalConfig, AssetLocation};
+use jellycommon::{
+ config::{GlobalConfig, SecretsConfig},
+ AssetLocation,
+};
use std::{fs::File, path::PathBuf, sync::LazyLock};
pub static CONF: LazyLock<GlobalConfig> = LazyLock::new(|| {
@@ -20,9 +23,13 @@ pub static CONF: LazyLock<GlobalConfig> = LazyLock::new(|| {
"First argument or JELLYTHING_CONFIG must specify the configuration to use.",
)
}))
- .unwrap(),
+ .expect("config cannot be read"),
)
- .unwrap()
+ .expect("config invalid")
+});
+pub static SECRETS: LazyLock<SecretsConfig> = LazyLock::new(|| {
+ serde_yaml::from_reader(File::open(&CONF.secrets_path).expect("secrets file missing"))
+ .expect("secrets config invalid")
});
pub trait AssetLocationExt {